MTU and your network experience
MTU is a very critical setting and metric of any computer network.
It is the maximum number of bytes that can be sent and received over a particular connection, at once.
A smaller MTU results in more data packets being sent.
A larger MTU results in larger and fewer packets and is more efficient.
However, you can’t blindly set an arbitrary high MTU and be happy. The right MTU depends on your hardware and ISP.
Setting MTU too low will result in poor performance while setting it too high will result in packets fragmentation and poor performance as well.
Today we’re going to discuss the ways of determining the proper MTU size for your home router.
Test directly!
It is crucial to test your MTU best router setting without a router!
Otherwise, your packets will be fragmented if they exceed the router’s own MTU setting.
Our MTU testing commands will instruct the end server to not fragment the packets, but any intermediate servers which have a lower MTU will result in fragmentation of packets.
That’s why it is crucial to test up your MTU without the router.
That means you have to unplug your router and set the WAN network connection on your computer, for testing.
Once you hook up your WAN cable to your computer/laptop/etc. you can proceed to test.
Finding the sweet MTU with ping
To test if a given value of MTU is fine, we are going to use ping
on Linux. A value of 1500 is a good starting point.
The -s
option of ping
specifies how many bytes of data we want to send to the destination server.
It is important to note that ping
will actually send 28 bytes on top of that, which is the standard size of a TCP header.
So to test if MTU if 1500 is good for you, supply ping -s
with a payload of 1500 - 28
ping 1.1.1.1 -Mdo -c1 -s 1472
What do all the options mean?
-Mdo
stands for “prohibit fragmentation, even local one”-c1
specifies the count of ping requests, we are fine with just one-s 1472
specifies the payload data size
Here’s a sample output:
PING 1.1.1.1 (1.1.1.1) 1472(1500) bytes of data.
ping: local error: Message too long, mtu=1492
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms
Note, how ping
tells us the correct MTU value should be 1492.
Why is it 8 bytes less than the “standard”? Because in the case of a PPPoE connection that we use, the PPPoE protocol has an overhead of 8 bytes
Now, armed with the knowledge about the right MTU, repeat your test with 1492 - 28
and there will be no fragmentation:
ping 1.1.1.1 -Mdo -c1 -s 1464
PING 1.1.1.1 (1.1.1.1) 1464(1492) bytes of data.
1472 bytes from 1.1.1.1: icmp_seq=1 ttl=58 time=30.9 ms
--- 1.1.1.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 30.940/30.940/30.940/0.000 ms
Now we can set the right value for MTU (1492) in the router settings. Make sure to use the value that will not cause fragmentation based on the tests above.