master
Raw Download raw file

date: “2016-12-01” draft: false title: “VLAN”


IEEE 802.1Q is the networking standard that supports virtual LANs (VLANs) on an Ethernet network. The standard defines a system of VLAN tagging for Ethernet frames and the accompanying procedures to be used by bridges and switches in handling such frames

Ethernet+VLAN tag Headers

byte  0  1  2  3  4  5  6  7  8  9 10 11 12 13 14 15 16 17 18            
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+- D ...-+--+--+--+--+
    |   Destination   |     Source      | TPID| TCI |  E  | . A .. |    CRC    |
    |   MAC Address   |   MAC Address   |     |     |  T  | .. T . | Checksum  |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+-... A -+--+--+--+--+

Ethernet+VLAN total byte count = 6+6+2+2+2+4 = 24 Bytes

Ethernet+VLAN tag Headers Descriptions

Bytes Field Description
ether[0:4], ether[4:2] Dest MAC Address
ether[6:4], ether[8:2] Src MAC Address
ether[12:2] TPID Tag Protocol ID = 0x8100
ether[14:2] TCI Tag control information (PCP + DEI + VLAN)
ether[14] & 0xE0 PCP Priority Control Point - 3bits
ether[14] & 0x10 DEI Drop Eligible Indicator
ether[14:2] & 0x0FFF VID VLAN Identifier - 12 bits
ether[16:2] EtherType protocol of payload

Ethernet+VLAN Example Packets

  • ether[12:2] = 0x8100 - frame is an IEEE 802.1Q
  • ether[14:2] & 0x0FFF = 1 - frame has the default VLAN ID (1)
  • see also Ethernet

Ethernet+VLAN BPF Shortcuts

BPF Shortcut Syntax Description
vlan [vlan_id] IEEE 802.1Q VLAN packet. If [vlan_id] is specified test if frame has the specified vlan

Additional resources