Technology Introduction
Access  Q-in-Q
 
1 
Q-in-Q 
Introduction to Q-in-Q 
In the VLAN tag field defined in IEEE 802.1Q, only 12 bits are used for VLAN IDs, so a 
device can support a maximum of 4,094 VLANs. In actual applications, however, a 
large number of VLAN are required to isolate users, especially in metropolitan area 
networks (MANs), and 4,094 VLANs are far from satisfying such requirements.  
The port Q-in-Q feature provided by the device enables the encapsulation of double 
VLAN  tags  within  an  Ethernet  frame,  with  the  inner  VLAN  tag  being  the  customer 
network VLAN tag while the outer one being the VLAN tag assigned by the service 
provider to the customer. In the backbone network of the service provider (the public 
network), frames are forwarded based on the outer VLAN tag only, while the customer 
network VLAN tag is shielded during data transmission. 
Figure 1 shows the structure of 802.1Q-tagged and double-tagged Ethernet frames. 
The Q-in-Q feature enables a device to support up to 4,094 x 4,094 VLANs to satisfy 
the requirement for the amount of VLANs in the MAN.  
Etype
DA SA
User
VLANTag
Etype DATA FCS
DA SA
Nested
VLANTag
DATA
User
VLANTag
6bytes 6bytes
Single-taggedf
structu
Double-t
4bytes
6bytes 6bytes 4bytes 4bytes
4b 2bytes
2bytes
46 to1500 bytes
46to1500byt
FCS
rame
re
aggedframestructure
ytes
4bytes es
Outer
VLAN
tag
Inner
VLAN
tag
 
Figure 1 802.1Q-tagged frame structure vs. double-tagged Ethernet frame structure  
Advantages of Q-in-Q:  
  Addresses the shortage of public VLAN ID resource  
  Enables customers to plan their own VLAN IDs, with running into conflicts with 
public network VLAN IDs.  
  Provides a simple Layer 2 VPN solution for small-sized MANs or intranets. 
 
Technology Introduction 
Access  Q-in-Q
 
2 
  Note: 
The Q-in-Q feature requires configurations only on the service provider network, and 
not on the customer network.  
 
Implementations of Q-in-Q 
There are two types of Q-in-Q implementations: basic Q-in-Q and selective Q-in-Q.  
1)  Basic Q-in-Q 
Basic Q-in-Q is a port-based feature, which is implemented through VLAN VPN.  
With the VLAN VPN feature enabled on a port, when a frame arrives at the port, the port 
will tag it with the ports default VLAN tag, regardless of whether the frame is tagged or 
untagged. If the received frame is already tagged, this frame becomes a double-tagged 
frame; if it is an untagged frame, it is tagged with the ports default VLAN tag.  
2)  Selective Q-in-Q 
Selective Q-in-Q is a more flexible, VLAN-based implementation of Q-in-Q. In addition 
to all the functions of basic Q-in-Q, selective Q-in-Q can take different actions based on 
different VLANs, including:  
  Tagging the frame with different outer VLAN tags based on different inner VLAN 
IDs.  
  Marking the outer VLAN priority based on the existing inner VLAN priority.  
  Modifying the inner customer VLAN ID while tagging the frame with an outer VLAN 
lag.  
Adjustable TPID Value of Q-in-Q Frames  
A VLAN tag uses the tag protocol identifier (TPID) field to identify the protocol type of 
the tag. The value of this field, as defined in IEEE 802.1Q, is 0x8100.  
Figure 2 shows the 802.1Q-defined tag structure of an Ethernet frame.  
User Priority CFI
DA SA VLAN Tag Etype DATA
TPID VLAN ID
6bytes 6bytes 4bytes
2bytes 3bits 1bit 12 bits
2bytes 46 to 1500 bytes
FCS
4bytes
 
Figure 2 VLAN Tag structure of an Ethernet frame 
On devices of different vendors, the TPID of the outer VLAN tag of Q-in-Q frames may 
have different default values. You can set and/or modify this TPID value, so that the 
Technology Introduction 
Access  Q-in-Q
 
3 
Q-in-Q frames, when arriving at the public network, carries the TPID value of a specific 
vendor to allow interoperation with devices of that vendor.  
The TPID in an Ethernet frame has the same position with the protocol type field in a 
frame  without  a  VLAN  tag.  To  avoid  chaotic  packet  forwarding  and  receiving,  you 
cannot set the TPID value to any of the values in the table below.  
Table 1 Reserved protocol type values 
Protocol type  Value 
ARP  0x0806 
PUP  0x0200 
RARP  0x8035 
IP  0x0800 
IPv6  0x86DD 
PPPoE  0x8863/0x8864 
MPLS  0x8847/0x8848 
IPX/SPX  0x8137 
IS-IS  0x8000 
LACP  0x8809 
802.1x  0x888E 
Cluster  0x88A7 
Reserved  0xFFFD/0xFFFE/0xFFFF 
 
Selective Q-in-Q  
Inner-to-Outer VLAN Priority Mapping 
When  a  frame  is  tagged  with  an  outer  VLAN  tag  upon  its  arrival  at  a  basic 
Q-in-Qenabled port, the default priority in the outer VLAN tag is the priority in the inner 
VLAN  tag.  Through  the  following  configuration  steps,  you  can  change  this  priority 
mapping relation and assign different outer VLAN priorities for different inner VLAN 
priorities.  
Outer VLAN Tagging Policy 
The  outer  VLAN  tag  implemented  by  the  basic  Q-in-Q  feature  is  the  VLAN  tag 
corresponding to the ports default VLAN ID, while the selective Q-in-Q feature allows 
adding different outer VLAN tags based on different inner VLAN tags.  
Technology Introduction 
Access  Q-in-Q
 
4 
If the device supports the configuration of basic Q-in-Q and selective Q-in-Q at the 
same time on a port and if the two features are both enabled on the port, frames that 
meet the selective Q-in-Q condition are handled with selective Q-in-Q on this port, and 
other frames with basic Q-in-Q.