Without VLANs a switch is a single network: every broadcast reaches everyone, every device sees every other. A VLAN (virtual LAN) divides the switch into separate networks, e.g. administration, training and guests. Nothing passes between the VLANs without a router; this separates departments and enforces rules.
Access port and trunk
Port type
for
Frames
Access
end device, belongs to exactly one VLAN
without tag
Trunk
link between switches or to the router, carries several VLANs
with 802.1Q tag (VLAN number)
The 802.1Q tag is 4 bytes after the MAC addresses: EtherType 0x8100, priority and the 12-bit VLAN ID (1 to 4094). The native VLAN travels on the trunk without a tag; both ends must have the same native VLAN. With “allowed VLANs” a trunk only lets certain VLANs through.
Slow motion VLANs with trunk and spanning tree in the simulation
The 802.1Q tag
On the trunk the switch inserts 4 bytes after the source MAC: TPID 0x8100 and the VLAN number in it. At the access port it removes the tag again. Because the frame changes, the switch recomputes the FCS.
802.1QTag in the frame · IEEE 802.1Q
0481216202428
TPID16 bits0x8100
PCP3 bits0
DEI1 bit0
VLAN ID12 bits10
Each row has 32 bits (4 bytes), bit 0 on the left, as the RFCs draw their headers. Dashed: variable or optional. Point at a field for an explanation.
Field
Length
Example value
Meaning
TPID
16 bits (2 bytes)
0x8100
Tag protocol identifier 0x8100: a VLAN tag follows instead of the EtherType.
PCP
3 bits
0
Priority code point: priority 0 to 7 for quality of service (e.g. voice higher).
DEI
1 bit
0
Drop eligible indicator: this frame may be dropped first when congested.
VLAN ID
12 bits
10
VLAN number 1 to 4094 (0 and 4095 are reserved).
Values: Real frame from the demo “Router on a stick” (no. 7, 82 bytes), exactly as the packet list in leyoNET shows it.
Ethernet II + 802.1QFrame · IEEE 802.3, IEEE 802.1Q
Preamble7 bytes
SFD1 bytes
Destination MAC6 bytes02:00:00:00:01:00
Source MAC6 bytes02:00:00:00:03:00
TPID2 bytes0x8100
TCI2 bytes0x000a
EtherType2 bytes0x0800
Payload42–1500 bytes60 Byte
FCS4 bytes0xc04af1d0
Gap (IFG)12 bytes
Left to right, in the order the bytes are sent. Grey dashed: never part of a capture (layer 1 or line framing). Point at a field for an explanation.
Field
Length
Example value
Meaning
Preamble (layer 1)
7 bytes
10101010 × 7
Seven bytes 10101010: the receiver synchronises its clock. Part of the physical layer.
SFD (layer 1)
1 bytes
10101011
Start frame delimiter 10101011: the frame starts now.
Destination MAC
6 bytes
02:00:00:00:01:00
To whom? FF:FF:FF:FF:FF:FF is broadcast, a first byte with the lowest bit set is multicast.
Source MAC
6 bytes
02:00:00:00:03:00
From whom? The MAC address of the sending interface; the switch learns it.
TPID
2 bytes
0x8100
Tag protocol identifier 0x8100: a VLAN tag follows instead of the EtherType.
TCI
2 bytes
0x000a
Tag control information: priority (PCP), DEI and VLAN ID, 16 bits together.
EtherType
2 bytes
0x0800
What is inside: 0x0800 IPv4, 0x86DD IPv6, 0x0806 ARP, 0x8100 VLAN tag, 0x8864 PPPoE. Values from 0x0600 are types, smaller ones a length (IEEE 802.3).
Payload
42–1500 bytes
60 Byte
The layer-3 packet. Because of the 4-byte tag, 42 bytes are enough for the minimum length of 64 bytes.
FCS
4 bytes
0xc04af1d0
Frame check sequence: CRC-32 over the whole frame from the destination MAC. If it does not match, the receiver drops the frame.
Gap (IFG) (layer 1)
12 bytes
At least 12 bytes of silence before the next frame (interframe gap). Part of the physical layer.
Values: Real frame from the demo “Router on a stick” (no. 7, 82 bytes), exactly as the packet list in leyoNET shows it.
Routing between VLANs
Router on a stick: a router is connected to the switch with a trunk and has one subinterface per VLAN (eth0.10) that serves as the gateway.
Layer 3 switch: the switch routes itself via VLAN interfaces (SVIs), see Layer 3 switch.
In leyoNET VLANs with a colour tint the ports on the canvas, the front panel and in the rack; an area with a VLAN documents the network.
How to do it in leyoNET
The same text as in the app’s help (F1 key).
VLANs
VLANs split one switch into separate networks. An access port belongs to exactly one VLAN, a trunk carries several (Trunks).
Under Tools → VLANs each VLAN gets a name and a colour. The colour automatically tints every port of that VLAN on the canvas and in the port table. Between VLANs you need a router (Router on a stick) or a layer 3 switch.
Creating VLANs: a switch only forwards VLANs it knows (tab Switching → VLANs on this switch or vlan 20, name Training). Assigning a new VLAN to an access port creates it, as on Cisco. A switch in the middle with trunks only still needs the VLANs, otherwise it drops the frames (console: «VLAN 20 is not created»). no vlan 20 deletes a VLAN, its ports become inactive. Files before version 1.2 have no list: there all VLANs in use count as created.
Trunks
A trunk links switches (or switch and router) and carries several VLANs on one cable. Each frame gets an 802.1Q tag with the VLAN number; the native VLAN runs untagged.
Allowed VLANs: by default a trunk carries all created VLANs. With switchport trunk allowed vlan 10,20 only these; … add 30, … remove 10, … except 1, … all, … none. switchport trunk native vlan 99 changes the untagged VLAN (set it the same on both sides). show interfaces trunk shows allowed and active VLANs per trunk. In the form, native VLAN and allowed VLANs are in the port table.
Router on a stick
A router with a single cable to the switch routes between VLANs: the switch port is a trunk and the router has one subinterface per VLAN (e.g. eth0.10) with its own IP as gateway.
See an example
VLAN and spanning tree
Three switches in a ring, two VLANs over trunks.
STP blocks one port (orange), then the office reaches its second computer over the trunk with an 802.1Q tag.
Structure of frames and packetsHow Ethernet frames, IPv4 and IPv6 packets, TCP segments and UDP datagrams nest inside each other, field by field according to the standards, with real bytes from leyoNET.