VLAN Tag

A VLAN tag is a method used to identify and segregate networks at the Data Link Layer or Layer 2 of the OSI model. VLAN tags are used in Ethernet frames to differentiate between virtual networks on the same physical network infrastructure. In particular, VLAN tags are added to the frame when traversing trunk links. VLAN tags are defined by the IEEE 802.1Q standard and is often referred to as 802.1Q encapsulation.

The following diagram shows the placement of the tag within the Ethernet frame:

8021q-frame-headers.png

The tag contains the following information:

  • Tag Protocol Identifier- This is the first field of the tag, and it is always set to an EtherType value of 0x8100. This is done to distinguish VLAN-tagged frames from untagged frames.
  • Priority Code Point (PCP) - This is a 3-bit field used for QoS which contains the Class of Service (CoS) values used for Layer 2 QoS.
  • Canonical Format Indicator (CFI) - Now referred to as the Drop Eligible Indicator (DEI). In most cases, this field is used to indicate frames eligible to be dropped in the presence of congestion (DEI = 1). In its original usage as CFI, it was set to 1 to indicate that the MAC address is in non-canonical format (e.g., token ring or FDDI format).
  • VLAN Identifier - The VLAN ID is a 12 bit field specifying the VLAN to which the frame belongs. The VLAN ID range is from 0 to 4095, however, 0 and 4095 are reserved.

When a switch receives an Ethernet frame with a VLAN tag, it uses these fields, especially the VLAN ID, to determine how to forward the frame within the network. Frames with different IDs are treated as belonging to separate VLANs, effectively segregating network traffic even though it may be traveling over the same physical network infrastructure.

https://networklessons.com/switching/802-1q-encapsulation-explained