Network MTU maximum size path discovery (PMTU) testing with ping


MTU (MAximum Transmit Unit) plays central role in available throughput. And while with the Internet the maximum size isn’t going to surpass 1500 bytes, on MPLS/IPL/etc lines, owned by 1 provider, it is possible to get better MTU.

THe easiest way to test for the maximum size of the packets that can pass without fragmenting is to use ping with appropriate option.

The idea is to send pings increasing each time their size, until we get an error.

Linux:

# for ii in {1450..2500..20} ; do ping -c 2 -M do -s ${ii} 194.90.1.5; done

Here:

  • I ping the destination 194.90.1.5

  • The ping size starts at 1450 bytes, and increases by 20 bytes each new ping until 2500 bytes

  • -M do sets dont-fragment bit on the pings.

Windows:

for /L %A in (1450,20,2500) do ping -f -l %A -n 2  194.90.1.5

Same as for Linux - send 2 pings each time, start with the size -l of 1450, increase each time by 20 bytes, and -f set dont-fragment bit.

As for the expected error message, it is "Packet needs to be fragmented but DF set." for Windows, and "error: Message too long, mtu=" for the Linux, once ping size is larger than possible over the path.

In the examples below the maximum MTU is 1500 bytes:

Windows:

> for /L %A in (1450,20,1550) do ping -f -l %A -n 2  194.90.1.5
> ping -f -l 1450 -n 2  194.90.1.5

Pinging 194.90.1.5 with 1450 bytes of data:
Reply from 194.90.1.5: bytes=1450 time=4ms TTL=59
Reply from 194.90.1.5: bytes=1450 time=6ms TTL=59

Ping statistics for 194.90.1.5:
    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 4ms, Maximum = 6ms, Average = 5ms

C:\WINDOWS\system32>ping -f -l 1470 -n 2  194.90.1.5

Pinging 194.90.1.5 with 1470 bytes of data:
Reply from 10.120.12.1: Packet needs to be fragmented but DF set.
Packet needs to be fragmented but DF set.

Linux:

# for ii in {1450..2000..20} ; do ping -c 2 -M do -s ${ii} 194.90.1.5; done
PING 194.90.1.5 (194.90.1.5) 1450(1478) bytes of data.
1458 bytes from 194.90.1.5: icmp_seq=1 ttl=45 time=54.2 ms
1458 bytes from 194.90.1.5: icmp_seq=2 ttl=45 time=54.2 ms

--- 194.90.1.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 54.267/54.276/54.285/0.009 ms
PING 194.90.1.5 (194.90.1.5) 1470(1498) bytes of data.
1478 bytes from 194.90.1.5: icmp_seq=1 ttl=45 time=54.2 ms
1478 bytes from 194.90.1.5: icmp_seq=2 ttl=45 time=54.2 ms

--- 194.90.1.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 54.201/54.208/54.216/0.232 ms
PING 194.90.1.5 (194.90.1.5) 1490(1518) bytes of data.
From 172.31.16.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)
ping: local error: Message too long, mtu=1500

Resources