MTU
maximum transmission unit (MTU)
Ethernet
乙太網路 (Ethernet) 的 1500 個位元組,
TCP 會設 IP 的Don’t Fragment flag,這樣 router 覺得封包太大的時候,會回傳 ICMP “packet too big”,避開 router不處理 IP fragmentation 的問題。如前所述,我們不能完全依賴這個。TCP 在 three-way handshake 的時候還會透過 SYN 封包帶上 MSS,告訴另一邊不要送超出 MSS 的封包過來。OS 會自動用下一站的 MTU — 40 作為 MSS (TCP 和 IP 標頭檔各 20 bytes),所以無論是直接用 Ethernet 或行動網路,都不會有問題。對 Ethernet 來說,MSS 就是 1500 — 40 = <html><font color=red>1460</font></html>。
IEEE 802.3/802.2 的 1492 個位元組,
802.11
The maximum 802.11 MTU is 2304 bytes.
Here are the different possible maximum frame size of a 802.11 packet, according to the encryption scheme in use :
MTU + MAC Header + Encryption Header
WEP : 2304 + 34 + 8 = 2346 bytes
WPA (TKIP) : 2304 + 34 + 20 = 2358 bytes
WPA2 (CCMP) : 2304 + 34 + 16 = 2354 bytes
Wireless Packet Size
The MTU of wireless networks is 2,312 bytes. This size includes the packet headers. The Wireless MTU is considerably larger than the Ethernet recommendation for wired networks, which is 1,500 bytes. However, this larger size is only practical for traffic traveing within the network. Any communication intended to travel over the Internet would encounter problems, and would have to split up into smaller packets to pass through the Internet service provider's network. ISPs operate with the standard wired network MTU of 1,500 bytes. However, some add on an extra header when communicating with customers. This eight byte field reduces the maximum packet size to 1.492 bytes.
Show MTU
# /sbin/ifconfig
Output:
eth0 Link encap:Ethernet HWaddr 00:0F:EA:91:04:07 inet addr:192.168.1.2 Bcast:192.168.1.255 Mask:255.255.255.0 inet6 addr: fe80::20f:eaff:fe91:407/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:141567 errors:0 dropped:0 overruns:0 frame:0 TX packets:141306 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:101087512 (96.4 MiB) TX bytes:32695783 (31.1 MiB) Interrupt:18 Base address:0xc000
A better way is to use ip command:
$ ip link list
Output:
1: lo: mtu 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: eth0: mtu 1500 qdisc pfifo_fast qlen 1000 link/ether 00:0f:ea:91:04:07 brd ff:ff:ff:ff:ff:ff 3: sit0: mtu 1480 qdisc noop link/sit 0.0.0.0 brd 0.0.0.0
As you see, MTU set to 1500 for eth0. Let us say you want this to 1400 then you can use any one of the following command to setup MTU:
# ifconfig eth0 mtu 1400
OR
# ip link set dev eth0 mtu 1400
Changing the MTU size
Changing the MTU size with ifconfig command
In order to change the MTU size, use /sbin/ifconfig command as follows:
ifconfig ${Interface} mtu ${SIZE} up
ifconfig eth1 mtu 9000 up
Note this will only work if supported by both the network nterface card and the network components such as switch.
Changing the MTU size permanently under CentOS / RHEL / Fedora Linux
Edit /etc/sysconfig/network-scripts/ifcfg-eth0, enter
# vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add MTU, settings:
MTU="9000"
Save and close the file. Restart networking:
# service network restart
Note for IPV6 set dedicated MTU as follows:
IPV6_MTU="1280"
Changing the MTU size permanently under Debian / Ubuntu Linux
Edit /etc/network/interfaces, enter:
# vi /etc/network/interfaces
Add mtu as follows for required interface:
mtu 9000
Save and close the file. Restart the networking, enter:
# /etc/init.d/networking restart