實驗結(jié)果
- MTU參數(shù)只作用于發(fā)包,不作用于收包。
- 收包規(guī)格取決于網(wǎng)卡
- 發(fā)包規(guī)格取決于MTU參數(shù)
實驗拓撲
WINDOWS 10:"VMware Network Adapter VMnet8"[mtu 1500]---[mtu 1500]"ens33":Linux
Windows10網(wǎng)卡配置
netsh interface ipv4 show subinterfaces "VMware Network Adapter VMnet8"
MTU MediaSenseState 傳入字節(jié) 傳出字節(jié) 接口
------ --------------- --------- --------- -------------
1500 1 4461 67219 VMware Network Adapter VMnet8
linux網(wǎng)卡配置
# ip a
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
link/ether 00:0c:29:e7:54:74 brd ff:ff:ff:ff:ff:ff
inet 192.168.232.110/24 brd 192.168.232.255
修改linux的ens33 mtu為1600
# nmcli con modify ens33 802-3-ethernet.mtu 1600
# nmcli con up ens33
在linux上測試,發(fā)現(xiàn)1572字節(jié)icmp報文可以ping通
# ping -c 1 -s 1572 192.168.232.2
PING 192.168.232.2 (192.168.232.2) 1572(1600) bytes of data.
1580 bytes from 192.168.232.2: icmp_seq=1 ttl=128 time=0.326 ms
--- 192.168.232.2 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.326/0.326/0.326/0.000 ms
經(jīng)過抓包發(fā)現(xiàn),發(fā)送的報文確實是1580字節(jié)的包,收到的reply是兩個包,說明windows在replay的時候,因為mtu是1500,所以發(fā)生了IP分片,發(fā)送了兩個報文。
# tcpdump -i ens33 icmp
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on ens33, link-type EN10MB (Ethernet), capture size 262144 bytes
02:21:11.240517 IP backend > _gateway: ICMP echo request, id 14608, seq 1, length 1580
02:21:11.240812 IP _gateway > backend: icmp
02:21:11.240819 IP _gateway > backend: ICMP echo reply, id 14608, seq 1, length 1480
windows發(fā)送報文MTU參數(shù)不受限制,雖然IP頭的長度規(guī)格是65535,但是以太網(wǎng)并不一定是承載ip,以太幀頭中也沒有長度的定義,所以可以修改mtu到10萬
netsh interface ipv4 set subinterface "VMware Network Adapter VMnet8" mtu=1000000
確定。
netsh interface ipv4 show subinterface "VMware Network Adapter VMnet8"
MTU MediaSenseState 傳入字節(jié) 傳出字節(jié) 接口
------ --------------- --------- --------- -------------
1000000 1 239347 365732 VMware Network Adapter VMnet8
由于ip的限制,最大ping報文長度為65500,測試windows可以發(fā)送65500大的ping包,但是由于受網(wǎng)卡規(guī)格的限制,無法ping通
ping -f -l 65500 192.168.232.110
正在 Ping 192.168.232.110 具有 65500 字節(jié)的數(shù)據(jù):
請求超時。
linux 只可以修改mtu到16110,更大的值不會報錯,但是不會生效(會變回1500)
# nmcli con modify ens33 802-3-ethernet.mtu 16110
# nmcli con up ens33
Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/41)
# ip link
2: ens33: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 16110 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 00:0c:29:e7:54:74 brd ff:ff:ff:ff:ff:ff
使用ping可以測得兩個網(wǎng)卡可以支持的最大接收mtu規(guī)格為9170
ping -n 1 -f -l 9170 192.168.232.110
正在 Ping 192.168.232.110 具有 9170 字節(jié)的數(shù)據(jù):
來自 192.168.232.110 的回復: 字節(jié)=9170 時間<1ms TTL=64
192.168.232.110 的 Ping 統(tǒng)計信息:
數(shù)據(jù)包: 已發(fā)送 = 1,已接收 = 1,丟失 = 0 (0% 丟失),
往返行程的估計時間(以毫秒為單位):
最短 = 0ms,最長 = 0ms,平均 = 0ms
ping -n 1 -f -l 9171 192.168.232.110
正在 Ping 192.168.232.110 具有 9171 字節(jié)的數(shù)據(jù):
請求超時。
192.168.232.110 的 Ping 統(tǒng)計信息:
數(shù)據(jù)包: 已發(fā)送 = 1,已接收 = 0,丟失 = 1 (100% 丟失),