Sub topic 14
Finding the path MTU with ping
This chapter assumes you can read ping output (replies, timeouts, TTL), know that ICMP carries ping's messages, and can run commands in a terminal. It shows how to use ping to measure the largest packet that crosses a path without being split up.
What MTU means and why you would measure it
The maximum transmission unit (MTU) is the largest IP packet, in bytes, that a link can carry in one frame. Ethernet's usual MTU is 1500 bytes. The path MTU is the smallest MTU of any link between two hosts. A single narrow link, such as a PPPoE connection, a VPN tunnel, or a cloud overlay network, sets the limit for the whole path.
When a packet is bigger than the next link's MTU, a router has two options:
- Fragment it into smaller IPv4 packets. This works but costs performance, and some firewalls drop fragments.
- Drop it and tell the sender. This happens when the packet has the Don't Fragment (DF) bit set. The router sends back an ICMP Destination Unreachable message with code 4, "Fragmentation needed and DF set". That message normally carries the MTU of the link that was too small.
Modern TCP stacks set DF on their packets and rely on those ICMP messages to learn the path MTU. This is called Path MTU Discovery (PMTUD). You can run the same experiment by hand with ping.
The arithmetic: payload versus packet size
Ping's size option sets the payload, the data after the ICMP header. The packet on the wire is bigger:
| Part | IPv4 size |
|---|---|
| IP header (no options) | 20 bytes |
| ICMP echo header | 8 bytes |
| Payload (what `-l` or `-s` sets) | you choose |
Packet size = payload + 28 bytes. To test a 1500-byte packet, use a 1472-byte payload. This is why the topic's example uses 1472.
For IPv6 the IP header is 40 bytes, so the overhead is 48 bytes. A 1500-byte packet needs a 1452-byte payload.
Testing with the Don't Fragment bit
On Windows, -f sets DF and -l sets the payload size:
ping -f -l 1472 8.8.8.8If the whole path carries 1500-byte packets, you get normal replies. If a link is smaller, you see one of these results:
Packet needs to be fragmented but DF set.A router or your own host reported the problem. The size is too big.Request timed out.The packet was dropped and no ICMP message came back. This may mean a PMTUD black hole, covered below, or ordinary loss.
Lower the payload and repeat until replies return. The largest payload that works, plus 28, is the path MTU.
ping -f -n 1 -l 1472 8.8.8.8
ping -f -n 1 -l 1464 8.8.8.8
ping -f -n 1 -l 1452 8.8.8.8Here -n 1 sends one request per size, which keeps the output short.
Linux and macOS use different flags for the same test:
# Linux: -M do forbids fragmentation, -s sets the payload size
ping -c 1 -M do -s 1472 8.8.8.8
# macOS: -D sets the Don't Fragment bit
ping -c 1 -D -s 1472 8.8.8.8On Linux, a message such as Frag needed and DF set (mtu = 1400) states the limiting MTU directly. Windows ping does not report it, so you find the value by trial.
Common MTU values
If your search ends at one of these numbers, you can guess what sits on the path.
| Path MTU | Max ping payload (IPv4) | Typical cause |
|---|---|---|
| 1500 | 1472 | Standard Ethernet |
| 1492 | 1464 | PPPoE (DSL), which uses 8 bytes for its header |
| 1480 | 1452 | Some IPv4-in-IPv6 or tunnel setups |
| 1400 to 1420 | 1372 to 1392 | Many VPN clients and cloud overlays |
| 9000 | 8972 | Jumbo frames inside a data center |
Real values depend on the product and its configuration, so treat this table as a hint only.
Finding the limit with a search
Stepping down by hand is slow. Because the answer lies between two numbers, a binary search finds it in about 11 tries. This script does that on Linux:
#!/bin/sh
# Usage: ./pmtu.sh [target]
target=${1:-8.8.8.8}
low=0
high=1472
while [ "$low" -lt "$high" ]; do
mid=$(( (low + high + 1) / 2 ))
if ping -c 1 -W 2 -M do -s "$mid" "$target" >/dev/null 2>&1; then
low=$mid
else
high=$((mid - 1))
fi
done
echo "Largest working payload: $low bytes"
echo "Estimated path MTU: $((low + 28)) bytes"The search assumes that a failure means "too big". A single lost packet can push the answer too low. Run the script twice, or confirm the result by hand with two or three pings at the final size and at one byte above it.
On Windows, a simple loop checks a short list of likely sizes. The find "TTL=" test works because a successful reply contains TTL=, while a fragmentation error does not. On non-English Windows the word may differ, so check your own output first.
@echo off
set target=8.8.8.8
for %%s in (1472 1464 1452 1432 1400 1372) do (
ping -f -n 1 -w 1000 -l %%s %target% | find "TTL=" >nul && echo %%s OK || echo %%s failed
)Linux also has tracepath, which discovers the path MTU hop by hop without root access and prints pmtu values as it goes.
The process as a flow
Why the result can be wrong
Several things can mislead you here, just as in the earlier chapter on filtering.
- PMTUD black holes. Some firewalls drop all ICMP, including the "fragmentation needed" message. The sender never learns the limit, and big packets vanish silently. The classic symptom is that small requests and TCP handshakes work, but large page loads or uploads hang. Your ping test shows timeouts for large sizes and replies for small ones.
- Targets that ignore ping. If the destination does not answer echo requests at all, every size fails and you learn nothing. First confirm that a small, normal ping works.
- Asymmetric paths. Your test checks the forward direction only for the large packet. The echo reply is the same size, so a limit on the return route can also cause failures. You cannot always tell which direction failed.
- Local limits. If your own interface MTU is smaller than the test size, your host rejects the packet before it leaves. On Windows,
netsh interface ipv4 show subinterfaceslists the MTU of each interface. On Linux,ip link showdoes. - IPv6. Routers never fragment IPv6 packets, so PMTUD is required. Routers report the problem with ICMPv6 "Packet Too Big", and filtering that message breaks IPv6 traffic.
Putting it together
- Confirm that a normal ping to the target works. Without that, an MTU test means nothing.
- Ping with DF set and a 1472-byte payload.
- If it fails, reduce the payload and repeat, by hand or with the search script.
- Add 28 (IPv4) to the largest working payload to get the path MTU.
- Compare the number with the table above to guess the cause, and check your own interface MTU.
- If small pings work and large ones time out without any error message, suspect a black hole and look at ICMP filtering on the path.
Exercise
On Windows, ping -f -l 1472 192.0.2.10 times out, but ping -f -l 1400 192.0.2.10 replies, and ping -f -l 1464 192.0.2.10 replies. A plain ping 192.0.2.10 also works. What is the likely path MTU, what is a probable cause, and what should you check about the 1472 timeout?
Show answer
The largest confirmed payload is 1464, so the path MTU is probably 1464 + 28 = 1492 bytes, which is typical of PPPoE. Because 1472 timed out instead of showing "Packet needs to be fragmented but DF set", the ICMP "fragmentation needed" message may be filtered. That would be a possible PMTUD black hole. To confirm, try payload sizes between 1465 and 1471 and repeat the 1472 test a few times to rule out random loss.
Exercise
What payload size would you give ping -f -l to test whether an IPv6 path carries 1500-byte packets, and why does it differ from the IPv4 value?
Show answer
Use 1452. An IPv6 header is 40 bytes and the ICMPv6 echo header is 8 bytes, so the overhead is 48 bytes, and 1500 - 48 = 1452. IPv4 uses a 20-byte header, giving 28 bytes of overhead and a 1472-byte payload. (Add -6 to the Windows ping command to force IPv6.)