# Stamp 802.1Q VLAN, Double-Tagged QinQ & MPLS Without an IXIA Rack

> **FrameAssembly v3.3.0** · Operational Playbook (Routing, VLANs & Overlays) · Canonical URL: https://frameassembly-lang.dev/use-cases/vlan-qinq-mpls-qos

Your laptop NIC driver loves eating VLAN tags. Writing Ethernet bytes straight to a .pcap means every 0x88a8 S-Tag and MPLS label survives.

- **Category:** Routing, VLANs & Overlays
- **Capture Filename:** `qinq_mpls_trunk.frasm` (3 Ethernet frames)
- **Protocols Exercised:** `vlan`, `rtp`, `qinq`, `mpls`, `tls`

## Operational Problem

Normal OS sockets won’t let unprivileged users emit outer 802.1ad QinQ S-tags, 20-bit MPLS labels, or 802.1p priority bits—and desktop NIC drivers famously strip 802.1Q tags before Wireshark even sees them.

When a carrier hands you a new Metro Ethernet circuit or you’re tuning VoIP strict-priority queues, you just want to know whether S-VLAN 2000 + C-VLAN 150 + MPLS 40960 + DSCP 46 make it to the other side unscathed.

Renting a hardware traffic generator or wiring up three spare lab routers just to push four shim bytes onto an Ethernet header is ridiculous when you can type qinq 2000 innervlan 150 mpls 40960 exp 5 on one line.

## Scenario & Topology: Voice VLAN 110 (DSCP EF) + Carrier QinQ 2000/150 + MPLS 40960 Check

- **Topology:** `Branch CPE (10.220.1.10) <-> Carrier QinQ 2000/150 + MPLS 40960 <-> HQ Edge (10.220.1.200)`

Three frames cover the whole trunk check: (1) a Voice VLAN 110 G.711 RTP packet stamped with pcp 5 and dscp 46 (EF); followed by (2 & 3) cpe -> hq and cpe <- hq double-tagged 802.1ad frames (qinq 2000 innervlan 150) carrying MPLS label 40960 (exp 5) and a TLS handshake.

## FrameAssembly Workflow

Writes raw 802.1Q (0x8100), 802.1ad (0x88a8), MPLS (0x8847), and DSCP EF headers straight into a 3-frame .pcap.

### Adapt It for Your Network

1. Set branch_cpe and hq_gateway to your circuit endpoints.
2. Drop vlan, pcp, dei, dscp, qinq <outer> innervlan <inner>, and mpls <label> right in front of any protocol.
3. Compile -> verify tag stacks in tshark -> replay onto your trunk NIC.

## Runnable Capture Specification (`qinq_mpls_trunk.frasm`)

```frameassembly
host branch_cpe { ip 10.220.1.10 }
host hq_gateway { ip 10.220.1.200 }

flow metro_trunk(cpe, hq) {
    cpe -> hq vlan 110 pcp 5 dei 0 dscp 46 rtp pt 0 seq 1 timestamp 160 payload "G711_VOICE_EF" wait 5ms
    cpe -> hq qinq 2000 innervlan 150 mpls 40960 exp 5 tls clienthello sni "wan.example.com" wait 5ms
    cpe <- hq qinq 2000 innervlan 150 mpls 40960 exp 5 tls serverhello wait 5ms
}

compile {
    metro_trunk(branch_cpe, hq_gateway)
}
```

## Equivalent CLI Commands

```bash
# 1. Build the VLAN, QinQ, MPLS & DSCP QoS capture
frameassembly qinq_mpls_trunk.frasm qinq_mpls_trunk.pcap

# 2. Verify VLAN IDs, 802.1p PCP priority, DSCP markings, and MPLS labels in tshark
tshark -r qinq_mpls_trunk.pcap -T fields -e frame.number -e vlan.id -e vlan.priority -e mpls.label -e ip.dsfield.dscp

# 3. Replay onto your 802.1Q / 802.1ad trunk interface
sudo tcpreplay -i eth0 qinq_mpls_trunk.pcap
```

## Protocol Reference Links

- [`vlan` — IEEE 802.1Q Virtual LAN Tagging & 802.1p QoS](https://frameassembly-lang.dev/docs/protocols/vlan) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/vlan.md))
- [`rtp` — Real-time Transport Protocol Audio & Video Streams](https://frameassembly-lang.dev/docs/protocols/rtp) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/rtp.md))
- [`qinq` — IEEE 802.1ad Provider Bridge Double VLAN Tagging (S-Tag + C-Tag)](https://frameassembly-lang.dev/docs/protocols/qinq) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/qinq.md))
- [`mpls` — Multiprotocol Label Switching Unicast Shim](https://frameassembly-lang.dev/docs/protocols/mpls) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/mpls.md))
- [`tls` — Transport Layer Security Record & Handshake Layer](https://frameassembly-lang.dev/docs/protocols/tls) ([Raw .md](https://frameassembly-lang.dev/docs/protocols/tls.md))
