How to find the right MTU size for a Network in Linux

Share this article

In this article, we are going to explain how to find the right MTU size but first, we have to understand why MTU size and why it is important.

MTU Size

In computer networking, MTU stands for Maximum Transmission Unit. As the name suggests it is the unit that tells the largest data packet a device can accept or transfer via an internet connection. It is measured typically in bytes.

Eg. When you list the interface in your Linux dist. you will see all the information with ip a or ifconfig command. In the following code section, you see an example showing the commands’ output.

[foofunc@test centos]# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether fa:16:3e:3f:69:3c brd ff:ff:ff:ff:ff:ff
    inet 10.0.23.12/24 brd 10.0.23.255 scope global dynamic noprefixroute eth0
       valid_lft 80247sec preferred_lft 80247sec
    inet6 fe80::f816:3eff:fe3f:693c/64 scope link 
       valid_lft forever preferred_lft forever
[foofunc@test centos]# ifconfig 
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.0.23.12  netmask 255.255.255.0  broadcast 10.0.23.255
        inet6 fe80::f816:3eff:fe3f:693c  prefixlen 64  scopeid 0x20<link>
        ether fa:16:3e:3f:69:3c  txqueuelen 1000  (Ethernet)
        RX packets 62240  bytes 9129859 (8.7 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 29804  bytes 6365796 (6.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 13195350  bytes 2170537545 (2.0 GiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13195350  bytes 2170537545 (2.0 GiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0


In the above code section, we have seen the output of the ip a and ifconfig commands. Both commands list all the interfaces in the system and their properties. In this article, we will focus on MTU size. First line of the interface details shows mtu size, here in the code section of eth0 MTU size is 1500 bytes. In most of the system, you have seen MTU size is 1500 bytes. The following diagram illustrates what MTU looks like in a typical network data transmission. It is consist of A payload, with 1460 bytes
The TCP and IP headers, with 20 bytes each.

Significance of the MTU size

  • Setting the right MTU size is really important. It is the main reason in-network if your internet connection speed isn’t as fast as you would expect. You can also experience other performance-related issues.
  • We know that the larger the MTU size is, it can be put more data in packets. That means transmission would be faster and more efficient across the network but if errors occur the packet will take longer to retransmit.
  • If the MTU size is too small, which means more bandwidth is unnecessarily wasted on headers. It also leads to more resource consumption because more packets also mean the routers and the operating systems on both ends might have to work harder that takes more CPU time.

How to choose the right MTU size.

You can find the right MTU size through a ping test, it’s the simplest way. In the following code section we have shown few ping commands with different MTU size and showing how mtu size changes the time packet loss and other factors in packet transmission.

To check the right MTU size we used ping command with following options.

  • -f: Flood ping, for every ECHO_REQUEST sent a period “.” is printed, while for ever ECHO_REPLY received a backspace is printed. This provides a rapid display of how many packets are being dropped.
  • -l: specify size of the MTU in following example we have used 1450, 1000 and 9000 bytes MTU size
  • -C : Number of max packets to transmit, in our case we are using 100000.
[foofunc@test centos]#sudo ping -f -l 1450 10.0.25.13 -c 100000
WARNING: probably, rcvbuf is not enough to hold preload.
PING 10.0.25.13 (10.0.25.13) 56(84) bytes of data.
                                                                                                                                                                                                                  
--- 10.0.25.13 ping statistics ---
100000 packets transmitted, 100000 received, 0% packet loss, time 873ms
rtt min/avg/max/mdev = 0.076/1.405/5.108/0.680 ms, pipe 545, ipg/ewma 0.012/0.947 ms

[foofunc@test centos]# sudo ping -f -l 1000 10.0.25.13 -c 100000
PING 10.0.25.13 (10.0.25.13) 56(84) bytes of data.
                                                                                                                                                                                                                  
--- 10.0.25.13 ping statistics ---
100000 packets transmitted, 100000 received, 0% packet loss, time 912ms
rtt min/avg/max/mdev = 0.075/6.869/9.612/3.259 ms, pipe 1000, ipg/ewma 0.009/1.147 ms
[foofunc@test centos]# sudo ping -f -l 9000 10.0.25.13 -c 100000
WARNING: probably, rcvbuf is not enough to hold preload.
PING 10.0.25.13 (10.0.25.13) 56(84) bytes of data.
                                                                                                                                                                                                                  
--- 10.0.25.13 ping statistics ---
100000 packets transmitted, 95043 received, 4.957% packet loss, time 915ms
rtt min/avg/max/mdev = 0.095/4.959/11.337/3.426 ms, pipe 1603, ipg/ewma 0.009/1.855 ms

In the above example I have tested the ping commands on the local network when my MTU size is less or equal to 1500 bytes there were no packet loss and time is less than when MTU size is 9000. You can also look at the round trip times which is minimum in when MTU size is set to 1500 bytes. Therefore, to get the right MTU size look for the minimum packet loss and minimum and less RTT time and overall time.

Summary

In this article we have learned about what is mtu size, what is its significance and how to choose right MTU size. In computer networking we have seen most of the router, computers have standard mtu size set to 1500 bytes but in internal organization you might notice that if organization have machines’ interfaces with higher bandwidth they have increased the MTU size to 9000 bytes (jumbo frames) and get more faster data transmission.

Leave a Comment

Your email address will not be published. Required fields are marked *