Setting the MTU Size

Like most computer protocols, TCP/IP was designed with flexibility in mind. One negative consequence of flexibility is that when different systems implement a protocol using different defaults, the two systems may not interact as efficiently as when the two systems use the same defaults. One point of flexibility in TCP/IP is the maximum transfer unit (MTU) size, which is the maximum size of data packets it sends. You can learn the MTU for your system by using ifconfig:

$ ifconfig ethO | grep MTU

UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1

This command displays the MTU, among other information. Ideally, all the computers on your LAN should use the same MTU. Linux's default value for Ethernet networks is 1,500 bytes, and this value is common on many other OSs, as well. If a device on your network uses an MTU smaller than others, transfers involving that device may be slowed down slightly, particularly if the devices communicate through another device (such as a router). Such communication may require packets to be broken up. For instance, some ADSL connections use an MTU of 1,492 bytes, meaning that 1,500-byte packets must be split into two: one 1,492-byte packet and another 8-byte packet. If the originating computer had used a 1,492-byte or smaller MTU, the split wouldn't be necessary. Of course, an 8-byte packet takes less time to send than does a 1,492-byte packet, so this conversion doesn't double transmission time, but the extra overhead does degrade performance somewhat.

For the most part, MTU size isn't a big deal in Linux, because Linux uses a technique known as path MTU discovery to determine the MTU on a site-by-site basis. If the initial MTU used for a connection is too high, Linux throttles it back until it works, thereby optimizing the connection. You can verify that path MTU discovery is enabled on your system by typing this command:

$ cat /proc/sys/net/ipv4/ip_no_pmtu_disc

A return value of 0 means that path MTU discovery is working; 1 means that this feature is disabled. You can use echo to copy a value into this pseudo-file if you want to change this option.

If you know that your system should use an MTU that's smaller than it does by default, you can alter the MTU by using the mtu option to ifconfig:

# ifconfig ethO mtu 1492

This example sets the MTU to 1,492 bytes, as might be appropriate if your system is on a LAN that uses an ADSL account with an MTU of 1,492. Setting this option in a startup script may slightly improve performance, even when your computer performs path MTU discovery; it won't try a 1,500-byte MTU that's destined to fail.

0 0

Post a comment