我正在研究 IP 分片和 MTU。我所知道的是 MTU 是物理介质的属性,因为它可以处理数据量而无需对数据进行碎片化。机器上的默认 MTU 设置为 1500。从网上阅读我了解到为 ICMP 保留了 28 个字节,所以我的实际 MTU 是 1472。
如果我将 DF 位设置为 1 并将数据包大小设置为 1472,我会收到 ping 响应,并且我会在 Wireshark 中看到相同的流量
ping 8.8.8.8 -f -l 1472
Pinging 8.8.8.8 with 1472 bytes of data:
Reply from 8.8.8.8: bytes=68 (sent 1472) time=60ms TTL=113
Reply from 8.8.8.8: bytes=68 (sent 1472) time=67ms TTL=113
Reply from 8.8.8.8: bytes=68 (sent 1472) time=77ms TTL=113
Reply from 8.8.8.8: bytes=68 (sent 1472) time=44ms TTL=113
但是如果我用数据包大小 1473 ping,我会得到以下信息:
C:\Users\admin>ping 8.8.8.8 -f -l 1473
Pinging 8.8.8.8 with 1473 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 时,我有一个 Wireshark 正在运行,但我从来没有在 Wireshark 中看到过这个。为什么这在 Wireshark 上看不到?我的意思是我不应该看到一些 ICMP 响应吗?我相信如果我机器上的 TCP/IP 堆栈看到 DF 位被设置并且 MTU 超过那么它自己会丢弃数据包吗?有人可以确认吗?
此外,如果我删除 DF 标志,那么我会在 Wireshark 中看到 ICMP ping,但 ping 失败:
C:\Users\admin>ping 8.8.8.8 -l 1473
Pinging 8.8.8.8 with 1473 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
为什么这会失败?我尝试将机器上的 MTU 从 1500 手动更改为 1501
MTU MediaSenseState Bytes In Bytes Out Interface
------ --------------- --------- --------- -------------
4294967295 1 54991843 0 Loopback Pseudo-Interface 1
1500 5 0 0 Wi-Fi
1500 5 0 0 Ethernet
1500 5 0 0 Local Area Connection* 14
1500 5 0 0 Local Area Connection* 15
**1501 1 114787330 26005606 Ethernet 2**
1500 1 0 755762 VirtualBox Host-Only Network
即使在增加 MTU 之后,我也会收到请求超时。有人可以解释一下吗?是不是因为我的机器容量还是1500字节,改成1500就没有效果了?