qinqIEEE 802.1ad Provider Bridge Double VLAN Tagging (S-Tag + C-Tag)Double-Tag Like an ISP (0x88a8 S-Tag -> 0x8100 C-Tag)
What It Does on the Wire
Because one VLAN tag was too mainstream for carriers: qinq 500 innervlan 20 stacks an outer 0x88a8 S-Tag -> inner 0x8100 C-Tag on any packet line.
IEEE 802.1ad Provider Bridging (qinq) encapsulates customer VLAN traffic inside a carrier Service VLAN tag, emitting two consecutive 4-byte VLAN headers on the wire: an outer IEEE 802.1ad S-Tag (TPID 0x88a8) followed by an inner IEEE 802.1Q C-Tag (TPID 0x8100).
Like vlan, qinq works both as a standalone Layer 2 protocol on MAC-only provider switches and as an inline cross-layer modifier on any L3, L4, or L7 packet statement—allowing carrier engineers and security teams to test double-tagged BGP, PPPoE/DHCP subscriber flows, or VLAN-hopping IDS signatures in one line.
Metro Ethernet UNI / NNI Service Multiplexing
Verify carrier edge switches push, swap, or pop outer S-VLAN tags (qinq 500) while preserving customer C-VLAN tags (innervlan 10..innervlan 20) intact.
Deep Packet Inspection & Suricata Double-Tag Parsing
Confirm NDR sensors, firewalls, and packet brokers properly strip both 0x88a8 and 0x8100 headers before inspecting inner TLS, DNS, or SMB payloads.
Carrier Peering BGP & BFD Session Validation
Synthesize sub-interface QinQ eBGP and BFD control captures to validate router sub-interface encapsulation dot1q <s-vid> second-dot1q <c-vid> stanzas.
Minimal Quickstart (qinq_quickstart.frasm)
Hit Preview Packets to compile in-browser and eyeball timestamps + wire byte lengths, or ship it straight to the Playground.
host pe_nni_a { mac 00:25:90:aa:00:01 }host pe_nni_b { mac 00:25:90:bb:00:02 }compile { pe_nni_a -> pe_nni_b qinq 500 innervlan 20}What the Compiler Calculates So You Don't Have To
- Always writes two complete 4-byte VLAN tags: outer TPID
0x88a8(S-VLAN, default100) followed immediately by inner TPID0x8100(C-VLAN, defaultinnervlan 1). - Applies
pcp(0..7) anddei(0|1) cleanly to the tag control headers and preserves the inner payload EtherType (0x0800IPv4,0x86ddIPv6,0x0806ARP). - Validates both outer S-VLAN and
innervlanC-VLAN bounds (0..=4095) during semantic validation.
Provider NNI Trunk Carrying Multiple Customer C-VLANs Inside S-VLAN 1200
Models a Metro Ethernet provider trunk (S-VLAN 1200) carrying two distinct customer tenants: Tenant A (innervlan 100) running BGP peering and Tenant B (innervlan 200) running ICMPv6.
host ce_v4_a { ip 172.20.0.1 mac 00:1b:21:c1:00:01 }host ce_v4_b { ip 172.20.0.2 mac 00:1b:21:c1:00:02 }host ce_v6_a { ip 2001:db8:200::1 mac 00:1b:21:c2:00:01 }host ce_v6_b { ip 2001:db8:200::2 mac 00:1b:21:c2:00:02 }compile { // Tenant A: eBGP Keepalive inside S-VLAN 1200 / C-VLAN 100 ce_v4_a -> ce_v4_b tcp syn srcport 51179 dstport 179 win 65535 mss 1452 qinq 1200 innervlan 100 pcp 6 wait 1ms ce_v4_a <- ce_v4_b tcp syn ack win 65535 mss 1452 qinq 1200 innervlan 100 pcp 6 wait 1ms ce_v4_a -> ce_v4_b tcp ack qinq 1200 innervlan 100 pcp 6 wait 1ms ce_v4_a -> ce_v4_b bgp keepalive qinq 1200 innervlan 100 pcp 6 wait 3ms // Tenant B: IPv6 Echo inside S-VLAN 1200 / C-VLAN 200 ce_v6_a -> ce_v6_b icmp echorequest id 42 seq 1 qinq 1200 innervlan 200 pcp 3 wait 1ms ce_v6_a <- ce_v6_b icmp echoreply id 42 seq 1 qinq 1200 innervlan 200 pcp 3}# 1. Eyeball relative timestamps, ports & wire lengths in your terminal
frameassembly show qinq_metro_nni.frasm
# 2. Compile .frasm -> classic .pcap (tcpdump/tcpreplay/Suricata) or nanosecond .pcapng
frameassembly qinq_metro_nni.frasm qinq_metro_nni.pcap
frameassembly qinq_metro_nni.frasm qinq_metro_nni.pcapng
# 3. Round-trip .pcap <-> .frasm whenever you want to scrub or tweak an existing capture
frameassembly reverse qinq_metro_nni.pcap qinq_metro_nni_edited.frasmAll qinq Keywords & Header Options
Every sub-keyword and header option is lowercase [a-z0-9]+ with zero underscores — mix and match them in any order after qinq:
src_host -> dst_host qinq [<outer_svlan 0..4095>] [innervlan <inner_cvlan 0..4095>] [pcp <0..7>] [dei <0|1>]| Keyword / Option | Accepted Value | Default | Effect on Packet |
|---|---|---|---|
| qinq [<0..4095>] | 12-bit outer S-VLAN ID (0..4095) | 100 | Sets the 12-bit Service VLAN ID inside the outer IEEE 802.1ad (0x88a8) header. |
| innervlan <0..4095> | 12-bit inner C-VLAN ID (0..4095) | 1 | Sets the 12-bit Customer VLAN ID inside the inner IEEE 802.1Q (0x8100) header. |
| pcp <0..7> | 3-bit unsigned integer (0..7) | 0 | Sets the Priority Code Point bits on the VLAN tag header. |
| dei <0|1> | 1-bit flag (0 or 1) | 0 | Sets the Drop Eligible Indicator bit on the outer S-Tag. |
Cross-Layer Wrappers Valid with qinq
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
5 options
Cross-Layer Wrappers Valid with qinq
802.1Q VLAN / QinQ / MPLS tags, IPv4/IPv6 QoS & TTL fields, wait gaps, and transport overrides allowed on this protocol
| Option | Range / Format | Default | Effect on Packet |
|---|---|---|---|
| wait <number><ns|us|ms|s|m> | Time gap (ns, us, ms, s, m) | 10ms | Advances the packet timestamp clock after sending this packet and before the next packet (wait 0ns sends back-to-back). |
| payload "<text>" | hexpayload "<hex>" | Quoted text or hex bytes (choose one) | Omitted | Appends or overrides raw payload bytes ("deadbeef" or "de:ad:be:ef") and updates packet lengths and checksums. |
| srcmac <mac> | dstmac <mac> | Colon, hyphen, or Cisco dot MAC | Host MAC / RFC multicast MAC | Overrides the 14-byte Ethernet II source or destination MAC address for this single packet. |
| vlan <0..4095> [pcp <0..7>] [dei <0|1>] | VLAN ID 0..4095, PCP 0..7, DEI 0..1 | Untagged | Wraps the packet in an IEEE 802.1Q VLAN tag (0x8100) with optional 802.1p QoS priority. |
| mpls <0..1048575> [exp|tc <0..7>] [bos <0|1>] [mplsttl <0..255>] | Label 0..1048575, exp/tc 0..7, bos 0..1, ttl 0..255 | Unlabeled (at most 1 mpls tag per packet) | Inserts a 32-bit MPLS label header (0x8847) ahead of the Layer 3 header. |
Gotchas & Quick Fixes
Always Spell innervlan Without Underscores
a -> b qinq 500 inner_vlan 20a -> b qinq 500 innervlan 20Legacy underscored spellings such as inner_vlan or c_vlan are rejected by the v3.1.2 lexer with a self-healing diagnostic suggesting innervlan.
Account for 8 Extra Header Bytes on Path MTU Tests
Assuming 1500B Ethernet payload without baby-giant MTUa -> b tcp syn mss 1452 qinq 500 innervlan 20QinQ adds 8 bytes (0x88a8 + 0x8100) to the Layer 2 header, increasing a standard 1514-byte Ethernet frame to 1522 bytes on carrier trunks.