Appearance
Appearance
MTU 是特定传输介质的最大 payload length。例如,Ethernet 的 MTU 通常是 1500 字节。Ethernet 的最大 packet length 通常是 1518 字节,但其中包括 14 字节的 Ethernet header 和 4 字节的 CRC,因此剩余 1500 字节 payload。当涉及 VLAN tag 时,packet length 会增加到 1522 字节。如果主机希望发送大于某个网络 MTU 的 packet,则必须将该 packet 分割成不大于 MTU 的块。
两台主机之间最小的 MTU 称为 path MTU。它可能等于或小于主机发送 packet 的接口 MTU。原因是,在两台主机之间路径上的各路由器链路中,任何链路的最小 MTU 决定了整条路径的 MTU。
为了找出 path MTU,主机会发送设置了 Don't Fragment flag 的 IP packets。当 packet size 超过 path MTU size 时,具有限制性 MTU 的路由器会发回 ICMP packet,通知发送主机该 IP packet 需要分片。发送主机此时就知道 path MTU 低于已发送 packet 的大小。关于这一过程有若干 RFC(IPv4:RFC 1191、RFC 4821、RFC 8899;IPv6:RFC 8201)。
通常,接口的最大传输大小是对称的,即 maximum transmission unit 等于 maximum receive unit。但这不是定义要求,而是接口的一项设计特性。
| 值 | 链路类型 | 65535 | PPP max, Hyperchannel | 17914 | 16 Mbps Token Ring | 4464 | 4 Mbps Token Ring | 1500 | Ethernet, PPP default | 1492 | IEEE 802.3/802.2 | 1480 | PPPoE | 1460 | L2TP | 1454 | 最优 PPPoE-over-DSL MTU(详情见 http://www.mynetwatchman.com/kb/adsl/pppoemtu.htm) | 1372 | PPTP (PPP/GRE/IP) default, Windows XP | 576 | X.25, default for many SLIP implementations
要设置 MTU 值,可在许多 OS 上使用 ifconfig 命令。
ifconfig <interface> mtu <value>ifconfig 命令也可能在报告接口其他信息的同时报告 MTU。
ifconfig <interface>在使用 ip 命令(来自 iproute2)的 Linux 上,设置 MTU:
ip link set { DEVICE | group GROUP } mtu MTUip 命令可以显示接口的所有详细信息,其中包括 MTU。
ip link show [DEVICE]可以通过使用 ping 命令反复试错来获取 MTU 值。
C:\>ping 10.1.1.1 -f -l 1373Pinging 10.1.1.1 with 1373 bytes of data:Packet needs to be fragmented but DF set.Packet needs to be fragmented but DF set.Packet needs to be fragmented but DF set.Packet needs to be fragmented but DF set.Ping statistics for 10.1.1.1: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),C:\>ping 10.1.1.1 -f -l 1372Pinging 10.1.1.1 with 1372 bytes of data:Reply from 10.1.1.1: bytes=1372 time=53ms TTL=254Reply from 10.1.1.1: bytes=1372 time=56ms TTL=254Reply from 10.1.1.1: bytes=1372 time=56ms TTL=254Reply from 10.1.1.1: bytes=1372 time=54ms TTL=254Ping statistics for 10.1.1.1: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),Approximate round trip times in milli-seconds: Minimum = 53ms, Maximum = 56ms, Average = 54ms可以通过注册表设置 MTU 值。更多详情参见 KB article 158474。
另请参见 RFC 1191,其中有一张常见 MTU 表。
Imported from https://wiki.wireshark.org/MTU on 2020-08-11 23:17:01 UTC