Do VLAN Tags and QinQ Reduce Your MTU? 1500, 1504, 1522 and the 1438 Mystery

A friend who had been through the MTU and MSS calculator on stealthtunnel.uk sent me a challenge. For IPsec ESP with NAT-T on a standard 1500 byte link, the tool said the inner MTU was 1435. He expected 1438. His case was Cisco SD-WAN IPsec tunnels over a DIA circuit with a 1504 MTU, with QinQ on the link, so there were four extra bytes floating about as well.

He was right about the 1438. The QinQ part is worth its own post, because “does a VLAN tag cost me MTU?” has a better answer than yes or no. Two separate things are going on, so I’ll take them in turn.

What the MTU actually counts

The MTU is the largest IP packet an interface will send. In Ethernet terms that is the payload of the frame. It does not include the Ethernet header, any VLAN tags or the frame check sequence. A VLAN tag is inserted into the Ethernet header, between the source MAC address and the EtherType, so it makes the frame bigger without touching the IP packet.

Frame typeEthernet headerLargest IP packetLargest frame on the wire (with FCS)
Untagged1415001518
802.1Q, one tag1815001522
QinQ (802.1ad), two tags2215001526

The jump from 1518 to 1522 is IEEE 802.3ac, and it exists for exactly this reason: the standard raised the maximum frame size so that a tag would not eat into the payload.

So a tag only costs you MTU if something on the path still enforces the old frame limit.

When a tag costs MTU and when it does not

SituationIP MTU you can use
Every device accepts 1522 byte frames, one tag1500
A device caps frames at 1518, one tag1496
A device caps frames at 1518, QinQ1492

The first row is how most modern kit behaves. The other two are the ones that produce the classic “small packets work, big ones hang” fault shortly after somebody adds a VLAN. You cannot tell which one you have from the config alone, so you find out by testing the path.

QinQ has a wrinkle of its own, and it is where the 1504 comes from. In a provider QinQ service the provider’s edge adds an outer S-tag. From the provider’s side, your frame, including its own 802.1Q tag, is simply payload. Answers on the Cisco community forums put it this way: on Cisco switches the system mtu counts payload only, so at the default 1500 a single tagged frame can be 1522 bytes, but with Q-in-Q the system MTU has to be raised to 1504 (a 1526 byte frame) to carry tagged 1500 byte packets. Packetlife’s QinQ walkthrough also tells you to check that every switch supports 1504 before you start.

Those are community answers rather than platform documentation, and behaviour varies between models, so check yours.

That gives one reading of the “1504 DIA link” in my friend’s setup: 1504 bytes of provider-side payload, four of which are his own tag, leaving an IP MTU of 1500. I have not seen his config, so treat that as a hypothesis that happens to reconcile the numbers, not a diagnosis.

Finding out which one you have

Do not guess. Ask the path. The ping payload is the MTU minus 28 bytes (20 for IP, 8 for ICMP), so these two commands test a 1500 byte IP MTU:

ping -M do -s 1472 -c 4 10.8.0.1
ping -M do -s 1473 -c 4 10.8.0.1

The first should pass and the second should fail. If 1472 fails but 1468 passes, something is capping the frame and the tag has cost you 4 bytes.

To see the tags themselves, capture on the parent interface, not on the VLAN sub-interface, with link-level headers switched on:

sudo tcpdump -e -n -i eth0 -c 5 icmp

tcpdump -e reports the frame length without the FCS, so a full-size untagged frame shows 1514, a single-tagged one 1518 and a QinQ one 1522. Some NICs strip the VLAN tag before the capture sees it. If the tag is missing, sudo ethtool -K eth0 rxvlan off turns that off for the test.

Why the calculator said 1435

The calculator’s ESP NAT-T figure assumes AES-GCM. These are the fixed bytes:

FieldBytesWhere it comes from
Outer IPv4 header20
UDP (NAT-T, port 4500)8
ESP header (SPI and sequence number)8RFC 4303 section 2
IV8RFC 4106: the GCM IV must be eight octets
ICV16RFC 4106: a 16 octet ICV is mandatory to support
Fixed total60

After the payload comes the ESP trailer: padding, then a Pad Length byte and a Next Header byte. RFC 4303 section 2.4 requires those two bytes to be right-aligned in a 4 byte word, and the ciphertext to end on a 4 byte boundary. RFC 4106 says to use the minimum padding, which will be fewer than four bytes. For AES-GCM, then, the padding is 0 to 3 bytes.

My calculator takes the worst case: 3 bytes of padding plus the 2 byte trailer, 5 bytes in total. That makes 65 bytes of overhead and an answer of 1435. It is safe for every packet size, because it assumes the unluckiest packet.

But “what is the biggest packet that fits?” is a different question, because the biggest packet is the one that lands exactly on the boundary and needs no padding at all. On a 1500 byte link, 1500 minus the 60 fixed bytes leaves 1440 for the inner packet, its padding and the 2 byte trailer. 1440 is a multiple of 4, so an inner packet of 1438 with no padding fits exactly. A 1439 byte packet would need 3 bytes of padding, which makes 1444 + 60 = 1504. That does not fit. The true maximum is 1438.

The general rule for AES-GCM ESP with NAT-T over IPv4 is:

max inner packet = floor((link MTU - 60) / 4) x 4 - 2
Link IP MTUCalculator (worst case)Exact maximum
150414391442
150014351438
149914341434
149614311434
149214271430

The gap is between 0 and 3 bytes depending on where the link MTU falls against that 4 byte boundary. It is widest on round numbers like 1500, which is, naturally, where everyone tests.

That lines up with my friend’s figures. A 1504 payload minus his 4 byte tag gives a 1500 byte IP MTU and an exact 1438. If the 1504 were a straight IP MTU it would be 1442. Both are exact, both are defensible, and neither is 1435, which is the safe worst case.

I did look for a Cisco figure for SD-WAN IPsec tunnels. The Cisco pages I found give ranges that depend on the cipher, so I am not going to quote one here. The arithmetic above is for AES-GCM only. With AES-CBC the IV is 16 bytes and the padding can run to 15, so the numbers differ.

To check the exact figure on your own link, through the tunnel:

ping -M do -s 1410 -c 4 10.8.0.1
ping -M do -s 1411 -c 4 10.8.0.1

1410 plus 28 is 1438. If the path matches the arithmetic, the first passes and the second fails. If the device doing the encapsulation fragments, clamps or ignores the DF bit, you will see something different, and that is useful information too. If you would rather not bisect by hand, pmtud-sweeper automates it.

What I changed on the calculator

The calculator now has a VLAN tags option (none, 802.1Q or QinQ) and a frame size limit setting:

  • Capped, tags use up MTU subtracts 4 or 8 bytes from the link.
  • Not capped, MTU unchanged leaves the MTU alone and tells you the frame on the wire grows to 1522 or 1526 bytes, so every device in the path has to accept it.

The same controls are on the diagram on the stealthtunnel.uk front page, with the S-tag and C-tag drawn as their own segments. The ESP figure stays at the worst case, and the page now says plainly that the true maximum can be up to 3 bytes higher. The don’t-fragment ping settles it. For the longer story on why this all matters, see MTU, MSS and tunnels.

If you want the rest of the packet anatomy, IPsec Deep Dive Part 2 covers ESP field by field, Part 3 covers where NAT-T’s extra 8 bytes come from, and Pivoting and Tunneling Part 4 covers what stacked tunnels do to your MTU.

What to take away

  • A VLAN tag lives in the Ethernet header. It changes the frame size, not the IP MTU, unless something on the path caps the frame.
  • With QinQ, ask what the provider’s path actually carries. 1504 on the circuit is common, and it may already include your own tag.
  • A worst-case padding figure is a safe default and can sit up to 3 bytes under the real maximum for AES-GCM. Measure the real one with a don’t-fragment ping.
  • Do not trust anyone’s number blindly, including the calculator’s.

Sources:

  • IEEE 802.1Q: the 802.3ac frame size increase from 1518 to 1522 bytes, and the 802.1ad S-tag and C-tag.
  • Cisco community: MTU explanation: system MTU counts payload only, and the Q-in-Q 1504 / 1526 byte figures (community answers, not platform documentation).
  • Packetlife: IEEE 802.1Q tunneling: verify switches support 1504 bytes before configuring.
  • RFC 4303: ESP header, trailer and the 4 byte alignment rules (section 2.4).
  • RFC 4106: AES-GCM in ESP, the 8 byte IV, the 16 byte ICV and minimal padding.