The Maximal Transfer Unit (MTU
) controls the maximum ethernet packet size that a computer will send before the packet is fragmented. Once a packet is fragmented it must be reassembled which is an operation that takes time and slows down the connection.
To measure the optimal MTU
for a connection between two hosts, we will send an ICMP
packet sized with some standard values and then increment and decrement until we see no fragmentation messages.
On Linux this can be done with:
ping -c 10 -M do -s 1472 www.google.com
where:
-c 10
means send only 10
packets,-M do
means to not fragment the packet,1472
is the size in bytes of the packet,www.google.com
is to whom to send the packet.The output of that command will most likely be the following:
PING www.google.com (173.194.44.83) 1472(1500) bytes of data. 1480 bytes from ham02s14-in-f19.1e100.net (173.194.44.83): icmp_req=1 ttl=53 time=12.8 ms
which means that the packet was sent and received successfully.
Next thing is to increment 1472
by 1
and issue the command again to check whether the packet gets fragmented. In case you see the following output from the command above:
PING www.google.com (173.194.44.84) 1473(1501) bytes of data. From 192.168.1.6 icmp_seq=1 Frag needed and DF set (mtu = 0)
it means that a size of 1473
is too much, so the last good known value is 1472
.
Depending on the operating system, the MTU
can be set per interface. You have to add 28
(the size of the packet header to the value that you have found to be working) and set that as the new size. In this case so the optimal working MTU
is 1500
.
On Linux, assuming that the interface is eth0
, issue the following command:
ifconfig eth0 mtu 1500
to set the MTU
to 1500
.
For Windows and Linux, the following commands can be used:
Operating System | Command |
---|---|
Windows | ping -f -l 1472 www.google.com |
OSX | ping -D -s 1472 www.google.com |