Sub topic 12
Size limits: MTU, MSS and fragmentation
This chapter assumes you know what encapsulation is, can read the TCP, IPv4 and Ethernet header fields from earlier chapters, and can run commands in a Linux terminal.
Why size limits exist
Every link layer has a maximum payload size per frame. This is the MTU (maximum transmission unit). On standard Ethernet it is 1500 bytes. The MTU counts the IP packet (IP header plus everything inside it). It does not count the 14-byte Ethernet header or the 4-byte frame check sequence.
The MSS (maximum segment size) is a TCP setting. It is the largest amount of application data one TCP segment may carry. It does not include the TCP or IP headers.
With no options, the numbers fit together like this:
| Item | Bytes |
|---|---|
| Link MTU | 1500 |
| IPv4 header | 20 |
| TCP header | 20 |
| MSS | 1460 |
Each side announces its MSS in the TCP options of its SYN packet. The sender then cuts the byte stream into segments no larger than the smaller of the two announced values. This keeps packets under the MTU of the local link, so IP rarely has to split them.
Fragmentation
A router may need to forward a packet onto a link with a smaller MTU than the packet. IPv4 allows two outcomes:
- If the Don't Fragment (DF) flag is clear, the router splits the packet into fragments. Each fragment gets its own IP header. The Identification field is copied to every fragment, and the Fragment Offset field says where each piece belongs. Only the final destination reassembles them.
- If the DF flag is set, the router drops the packet and sends back an ICMP "Fragmentation needed" message that includes the MTU of the next link.
Fragmentation has costs. If one fragment is lost, the receiver discards the whole packet, and TCP must resend all of it. Firewalls may also drop fragments because only the first one carries the TCP or UDP header. For these reasons, modern TCP stacks set DF and rely on Path MTU Discovery (PMTUD). The sender starts with a full-size packet and reduces its size when an ICMP message reports a smaller MTU. IPv6 routers never fragment. Only the sending host may.
Measuring the path MTU
The first command below lists the MTU of each local interface. The second sends a ping with DF set (-M do). The payload is 1472 bytes, and 8 bytes of ICMP header plus 20 bytes of IP header bring the packet to exactly 1500.
ip link show
ping -M do -s 1472 example.comIf a link on the path has a smaller MTU, the ping fails with a message such as Frag needed and DF set or message too long. Lower -s until it succeeds. The largest working value plus 28 is the path MTU.
Common errors
- Black-hole connections. A firewall blocks ICMP "Fragmentation needed" messages, so PMTUD never learns the smaller MTU. Small requests work, but large transfers hang. The cause is often a VPN or tunnel (see the tunneling chapter), whose extra header reduces the usable MTU below 1500.
- Forgetting the headers. A tunnel adding 50 bytes of headers leaves 1450 bytes for the inner packet. The MSS must shrink to match, and many routers do this by rewriting the MSS option in SYN packets ("MSS clamping").
- Mixing up MTU and MSS. MTU includes the IP header and sits at the link and network layers. MSS excludes the IP and TCP headers and applies only to TCP.
Exercise
A VPN tunnel adds 60 bytes of headers to every packet, and the physical link MTU is 1500. What MTU is available to the inner packet, and what MSS should TCP use for IPv4 with no TCP options?
Show answer
The inner MTU is 1500 - 60 = 1440 bytes. The MSS is 1440 - 20 (IP header) - 20 (TCP header) = 1400 bytes.
Exercise
A router with DF set on an incoming 1500-byte packet needs to send it onto a link with MTU 1400. What happens?
Show answer
The router drops the packet and returns an ICMP "Fragmentation needed" message that contains the next-hop MTU of 1400. The sender then lowers its packet size.