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. The standard also contains provisions for a quality of service prioritization scheme commonly known as IEEE 802.1p and defines the Generic Attribute Registration Protocol.
Portions of the network which are VLAN-aware (i.e., IEEE 802.1Q conformant) can include VLAN tags. Traffic on a VLAN-unaware (i.e., IEEE 802.1D conformant) portion of the network will not contain VLAN tags. When a frame enters the VLAN-aware portion of the network, a tag is added to represent the VLAN membership of the frame's port or the port/protocol combination, depending on whether port-based or port-and-protocol-based VLAN classification is being used. Each frame must be distinguishable as being within exactly one VLAN. A frame in the VLAN-aware portion of the network that does not contain a VLAN tag is assumed to be flowing on the native (or default) VLAN.
The standard was developed by IEEE 802.1, a working group of the IEEE 802 standards committee, and continues to be actively revised with notable revisions including IEEE 802.1ak, IEEE 802.1Qat and IEEE 802.1Qay.
802.1Q does not actually encapsulate the original frame. Instead, for Ethernet frames, it adds a 32-bit field between the source MAC address and the EtherType/length fields of the original frame, leaving the minimum frame size unchanged at 64 bytes (octets) and extending the maximum frame size from 1,518 bytes to 1,522 bytes (for the payload a 42-octet minimum applies when 802.1Q is present; when absent, a 46-octet minimum applies. IEEE 802.3-2005 Clause 3.5). Two bytes are used for the tag protocol identifier (TPID), the other two bytes for tag control information (TCI). The TCI field is further divided into PCP, DEI, and VID.
|16 bits||3 bits||1 bit||12 bits|
- Tag protocol identifier (TPID): a 16-bit field set to a value of 0x8100 in order to identify the frame as an IEEE 802.1Q-tagged frame. This field is located at the same position as the EtherType/length field in untagged frames, and is thus used to distinguish the frame from untagged frames.
- Tag control information (TCI)
- Priority code point (PCP): a 3-bit field which refers to the IEEE 802.1p priority. It indicates the frame priority level. Values are from 0 (best effort) to 7 (highest); 1 represents the lowest priority. These values can be used to prioritize different classes of traffic (voice, video, data, etc.). See also Class of Service or CoS.
- Drop eligible indicator (DEI): a 1-bit field. (formerly CFI[note 1]) May be used separately or in conjunction with PCP to indicate frames eligible to be dropped in the presence of congestion.
- VLAN identifier (VID): a 12-bit field specifying the VLAN to which the frame belongs. The hexadecimal values of 0x000 and 0xFFF are reserved. All other values may be used as VLAN identifiers, allowing up to 4,094 VLANs. The reserved value 0x000 indicates that the frame does not belong to any VLAN; in this case, the 802.1Q tag specifies only a priority and is referred to as a priority tag. On bridges, VLAN 1 (the default VLAN ID) is often reserved for a management VLAN; this is vendor-specific.
For frames using IEEE 802.2/SNAP encapsulation with an OUI field of 00-00-00 (so that the protocol ID field in the SNAP header is an EtherType), as would be the case on LANs other than Ethernet, the EtherType value in the SNAP header is set to 0x8100 and the aforementioned extra 4 bytes are appended after the SNAP header.
Because inserting the VLAN tag changes the frame, 802.1Q encapsulation forces a recalculation of the original frame check sequence field in the Ethernet trailer.
The IEEE 802.3ac standard increased the maximum Ethernet frame size from 1518 bytes to 1522 bytes to accommodate the four-byte VLAN tag. Some network devices that do not support the larger frame size will process the frame successfully but may report them as a "baby giant" anomalies.
With the IEEE standard 802.1ad, double-tagging can be useful for Internet service providers, allowing them to use VLANs internally while mixing traffic from clients that are already VLAN-tagged. The outer (next to source MAC and representing ISP VLAN) S-TAG (service tag) comes first, followed by the inner C-TAG (customer tag). In such cases, 802.1ad specifies a TPID of 0x88a8 for service-provider outer S-TAG.
Non-standard triple-tagging is also possible. The third tag of 4 bytes allows extended addressing and also a small hop-count. The 66-bit addressing plan now uses a fixed (non-stacking) QinQinQ format. The result is three 32-bit tags plus the 16-bit EtherType/length for a total of 112 bits. The two 48-bit (MAC) address fields add another 96 bits. The total header is 208-bits compared to a 320-bit IPv6 header. The 66-bit addressing is 18 + 48. The 18 bits are encoded 6 bits per 32-bit tag in the 12-bit VID fields. The 16-bit EtherType/length field can contain the payload size or an EtherType for payloads that contain their own Length, such as IPv4.
|16 bits||3 bits||1 bit||12 bits|
The contents of TPID0+TPID1+TPID2 contain the 48-bit MAC address of the source device.
Trunk ports and the native VLAN
The terminology of trunk ports and native VLANs is non-standard. Annex D to the 1998 802.1Q standard uses the concept of trunk links, but the current standard does not use the terms trunk or native.
Some vendors (most notably Cisco) use the concepts of a) trunk ports and b) native VLAN. The proprietary term native VLAN is similar to the 802.1Q PVID (port VLAN identifier), which is used "to associate a VID with untagged and priority-tagged received frames." A trunk port can refer a port that sends and receives tagged frames on all VLANs, except the native VLAN, if one is configured. The term trunk may also be used to refer to a connection using link aggregation.
Frames belonging to the native VLAN do not carry VLAN tags when sent over the trunk. Conversely, if an untagged frame is received on a trunk port, the frame is associated with the native VLAN configured on that port.
For example, if an 802.1Q port has VLANs 2, 3 and 4 assigned to it, with VLAN 2 being the native VLAN, frames on VLAN 2 that are sent from the aforementioned port are not given an 802.1Q header (i.e. they are plain Ethernet frames). Frames that are received on that port and have no 802.1Q header are assigned to VLAN 2. Tagging of frames sent to or received from VLANs 3 and 4 is the same as if no native VLAN had been configured – all frames on those VLANs must carry tags to identify their VLAN membership.
Note that unexpected results may occur if the native VLAN configuration is not the same on all sending and receiving ports on a link. Continuing the above example, if VLAN 2 is not configured as the native VLAN on some other 802.1Q port, that port will send tagged frames on VLAN 2. When the local port, on which VLAN 2 is configured as the native VLAN, receives these unexpectedly tagged frames, it will still assign them to VLAN 2, but it will send only untagged frames for VLAN 2. On receipt, the distant port will either associate the untagged frames with a different VLAN ID (the one locally configured as the native VLAN) or it will discard the untagged frames if it has no native VLAN configured. (Symmetrically, this remote port will send only untagged frames on its configured native VLAN, which will be associated with a different VLAN ID by the local port.)
Multiple VLAN Registration Protocol
In addition, IEEE 802.1Q defines the Multiple VLAN Registration Protocol (MVRP), an application of the Multiple Registration Protocol, allowing bridges to negotiate the set of VLANs to be used over a specific link.
MVRP replaced the slower GARP VLAN Registration Protocol (GVRP) in 2007 with the IEEE 802.1ak-2007 amendment.
Multiple Spanning Tree Protocol
- This field was formerly designated Canonical Format Indicator (CFI) with a value of 0 indicating a MAC address in canonical format. It is always set to zero for Ethernet. CFI was used for compatibility between Ethernet and Token Ring networks. If a frame received at an Ethernet port had a CFI set to 1, then that frame would not be bridged to an untagged port.
- VLAN Trunking Protocol (VTP), a Cisco proprietary VLAN management protocol
- Cisco Inter-Switch Link (ISL), an older VLAN trunking protocol that is proprietary to Cisco
- Dynamic Trunking Protocol (DTP), another Cisco proprietary networking protocol.
- IEEE Std. 802.1Q-2003, Virtual Bridged Local Area Networks (PDF; 3.5 MiB). ISBN 0-7381-3663-8.
- IEEE Std. 802.1Q-2005, Virtual Bridged Local Area Networks (PDF; 2.3 MiB). ISBN 0-7381-3662-X.
- IEEE Std. 802.1Q-2011, Media Access Control (MAC) Bridges and Virtual Bridged Local Area Networks (PDF; 6.0 MiB). ISBN 978-0-7381-6708-4.
- ISL & 802.1q Frame Formats
- IEEE 802.1Q-2011 clause 9.6
- IEEE 802.1Q-2005 clause 9.6
- IEEE 802.1Q-2011 clause 6.9.3
- Understanding Baby Giant/Jumbo Frames Support on Catalyst