Sub topic 12
Size limits: MTU, MSS and fragmentation
This chapter assumes you know how encapsulation wraps data in TCP, IP and Ethernet headers. It also assumes you can read the IPv4 header fields and run commands in a Linux terminal. Here you will see why a packet cannot be any size, what happens when one is too large, and how to find the limit on a real path.
Why size limits exist
Every link layer technology has a maximum payload for one frame. This limit is the MTU (maximum transmission unit). It is measured at the network layer: it counts the IP header and everything inside it, but not the Ethernet header or the frame check sequence.
On standard Ethernet the MTU is 1500 bytes. The frame on the wire is then at most 14 bytes of Ethernet header, 1500 bytes of IP packet and 4 bytes of FCS, which is 1518 bytes.
The MTU belongs to each link, not to the whole path. A path of three links can have MTUs of 1500, 1492 and 9000. The smallest value on the path is the path MTU. A sender that ignores it has packets dropped or split somewhere in the middle.
| Link type | Typical MTU (bytes) |
|---|---|
| Standard Ethernet | 1500 |
| PPPoE (DSL) | 1492 |
| Ethernet "jumbo frames" | about 9000, set by configuration |
| Linux loopback | 65536 |
| IPv6 minimum every link must support | 1280 |
MTU, MSS and where each applies
The MSS (maximum segment size) is a TCP concept. It is the largest amount of TCP data a host is willing to receive in one segment, excluding the IP and TCP headers.
Each side announces its MSS in a TCP option on its SYN packet. With an MTU of 1500, an IPv4 header of 20 bytes and a TCP header of 20 bytes, the usual value is:
MSS = MTU - IP header - TCP header = 1500 - 20 - 20 = 1460The sender then uses the smaller of the two announced values. TCP is the layer that cuts a byte stream into pieces, so MSS lets it cut pieces that fit in a packet without further splitting. UDP has no MSS. The application hands UDP a datagram of any size, and the IP layer has to deal with it.
The table shows the three limits together.
| Limit | Layer | Counts | Set by |
|---|---|---|---|
| MTU | Link / network | IP header plus payload | The link and its configuration |
| MSS | Transport (TCP) | TCP data only | Each endpoint, from its own MTU |
| Path MTU | Network | IP header plus payload | The smallest MTU along the path |
Fragmentation in IPv4
If an IPv4 packet is larger than the MTU of the next link and the Don't Fragment (DF) flag is clear, the router may split it into fragments. Each fragment is a full IP packet with its own header. Three header fields make reassembly possible:
- Identification is the same value in every fragment of one original packet.
- More Fragments (MF) flag is set on all fragments except the last.
- Fragment offset gives the position of this fragment's data in the original payload, counted in units of 8 bytes. This is 13 bits wide.
Because the offset counts 8-byte units, every fragment except the last must carry a payload that is a multiple of 8 bytes. Only the final destination reassembles the packet. Routers in between forward fragments as ordinary packets.
Worked example
An IP packet has a 20-byte header and 3980 bytes of payload (4000 bytes in total). It meets a link with MTU 1500. Each fragment can hold 1500 - 20 = 1480 bytes of payload, and 1480 is divisible by 8.
| Fragment | Total length | Payload bytes | Offset field | MF |
|---|---|---|---|---|
| 1 | 1500 | 1480 | 0 | 1 |
| 2 | 1500 | 1480 | 185 | 1 |
| 3 | 1040 | 1020 | 370 | 0 |
The offset of fragment 2 is 1480 / 8 = 185, and of fragment 3 is 2960 / 8 = 370. This script reproduces the table for any size:
def fragment(total_len, mtu, ihl=20):
"""Return (total_length, payload, offset_units, more_fragments) per fragment."""
payload_len = total_len - ihl
per_fragment = (mtu - ihl) // 8 * 8 # round down to a multiple of 8
result = []
sent = 0
while sent < payload_len:
chunk = min(per_fragment, payload_len - sent)
more = (sent + chunk) < payload_len
result.append((ihl + chunk, chunk, sent // 8, int(more)))
sent += chunk
return result
for row in fragment(4000, 1500):
print(row)The output is (1500, 1480, 0, 1), (1500, 1480, 185, 1) and (1040, 1020, 370, 0).
Why fragmentation is avoided
- One lost fragment loses the whole packet. The receiver cannot rebuild the datagram, so the sender must retransmit all of it (TCP) or the data is lost (UDP).
- Receivers must buffer. They hold fragments until the rest arrive or a timer expires, which costs memory and is a known denial-of-service target.
- Later fragments have no transport header. Only fragment 1 carries the TCP or UDP header, so a firewall or NAT that filters on ports cannot classify the others without reassembling.
- Cost on routers. Fragmenting is slower than plain forwarding.
Path MTU Discovery
Modern hosts avoid fragmentation by finding the path MTU. TCP on IPv4 normally sets the DF flag, and the process runs as follows:
- The sender transmits a packet with DF set, sized to its local MTU.
- A router finds the next link too small. It cannot fragment because of DF, so it drops the packet.
- The router returns an ICMP message, Type 3 Code 4 ("Fragmentation needed and DF set"), which includes the MTU of the next link.
- The sender lowers its estimate for that destination and resends smaller packets.
IPv6 removes router fragmentation entirely. Only the sending host may fragment, and routers that cannot forward a packet reply with ICMPv6 "Packet Too Big".
The black hole problem
Some firewalls drop all ICMP traffic. The sender then never learns the limit. Small packets work, such as the TCP handshake and short requests, but any packet near full size silently disappears. The typical symptom is a connection that opens and then stalls when a large response starts. This is called a PMTUD black hole.
Common fixes:
- Allow ICMP "fragmentation needed" (and ICMPv6 "Packet Too Big") through firewalls.
- MSS clamping: a router or firewall rewrites the MSS option in passing SYN packets to a smaller value, so TCP never builds packets that are too big.
- Lower the MTU on the interface of the affected host.
Measuring the path MTU
On Linux, ip link show lists each interface and its mtu. The ping command can probe the path with DF set:
ip link show
ping -M do -s 1472 example.comThe -s 1472 value is the ICMP data size. Add 8 bytes of ICMP header and 20 bytes of IPv4 header and the packet is exactly 1500 bytes. If a smaller MTU exists, ping reports an error such as "message too long" or "Frag needed". Reduce -s until it succeeds, then add 28 to get the path MTU. tracepath example.com does this search automatically and prints pmtu values.
Tunnels reduce the usable MTU
A tunnel puts a whole packet inside another packet, so the outer headers use part of the outer link's MTU. The inner packet gets only what is left.
| Encapsulation | Added overhead (bytes) | Inner MTU on a 1500 link |
|---|---|---|
| PPPoE | 8 | 1492 |
| GRE (basic, IPv4) | 24 | 1476 |
| VXLAN over IPv4 | 50 | 1450 |
Forgetting this is the most common cause of black holes. A VPN client with an inner MTU of 1500 sends packets that, once wrapped, exceed 1500 and are dropped or fragmented. Tunnel software usually sets a smaller MTU on its virtual interface for this reason. Hosts behind it then derive a smaller MSS.
Seeing sizes in a capture
When you run sudo tcpdump -i eth0 -e -nn -v -c 5 tcp port 80, the -e option prints the Ethernet frame length and the -v option prints the IP length and flags. A normal data packet on Ethernet shows a frame length up to 1514 (1500 plus the 14-byte Ethernet header) and the DF flag. The SYN packet shows options [mss 1460,...].
Common mistakes
- Treating the MTU as the maximum TCP data size. The data limit is the MSS, which is 40 bytes smaller on IPv4 with no options.
- Counting the Ethernet header in the MTU. It is not included.
- Blocking all ICMP "for security" and creating PMTUD black holes.
- Setting jumbo frames on some hosts but not on every switch and router in the path.
- Expecting an offset in bytes. The fragment offset field is in 8-byte units.
Exercise
A host on Ethernet with MTU 1500 sends a TCP segment over IPv4 with no options. (a) What MSS does it announce? (b) A tunnel on the path adds 50 bytes of overhead on a 1500-byte link. What is the largest inner IP packet, and what MSS should be clamped for TCP over IPv4?
Show answer
(a) 1500 - 20 (IP) - 20 (TCP) = 1460 bytes. (b) The largest inner packet is 1500 - 50 = 1450 bytes, so the MSS should be clamped to 1450 - 40 = 1410 bytes.
Exercise
An IPv4 packet with a 20-byte header and 2980 bytes of payload crosses a link with MTU 1000. How many fragments are produced, and what are their fragment offset values?
Show answer
Each fragment holds at most 980 payload bytes, which rounds down to 976 (a multiple of 8). The 2980 bytes split into 976, 976, 976 and 52, so there are 4 fragments. The offsets are 0, 122, 244 and 366, because 976 / 8 = 122.
Exercise
Users report that a website loads its first page header but then hangs, and the problem appears only through a VPN. Small requests work. What is the likely cause, and what are two fixes?
Show answer
Full-size packets exceed the path MTU after tunnel encapsulation, and the ICMP "fragmentation needed" messages are being blocked, so PMTUD fails (a black hole). Fixes: lower the MTU on the VPN interface, clamp the TCP MSS on the tunnel endpoint, or allow ICMP type 3 code 4 through the firewalls.