📌  相关文章
📜  如何为网络找到合适的 MTU 大小?

📅  最后修改于: 2022-05-13 01:57:01.705000             🧑  作者: Mango

如何为网络找到合适的 MTU 大小?

最大传输单元 (MTU) 是可以通过网络进行通信而不将其分成更小的片段的最大可能的数据包/帧大小。它们以八位字节声明,可以在基于帧/数据包的网络中传输。如果任何数据包大于指定的 MTU 设置,则它将原始数据包分解或分段为更小的子数据包。现在,如果这些数据包的数量很少,则可以,当碎片数据包的数量很大时,就会出现问题,在这种情况下,它会显着降低数据在网络上的传输速度。

使用不正确的 MTU 大小可能会导致一些问题,例如尝试打开某些浏览器时可能会出现问题,通过网络传输或接收文件时可能会出现问题,并且 VoIP 也可能会遇到一些故障。要解决这些问题,应检查 MTU 值并将其设置为最佳 MTU 大小。如果 MTU 大小是最优的,那么当流中的数据包长度等于 MTU 的值时,它可以显着提升网络的整体性能,并且可以达到更高的速度。

在各种网络设备中,可以为所选接口手动设置MTU值,但应适当设置最佳大小。 TCP 使用 MTU 来限制每个数据包的最大大小。它通常与以太网协议链接,其中允许的最大数据包大小高达 1500 字节。

MTU 大小:

要找到最佳 MTU 大小,请转到搜索栏并输入“ cmd ”打开 cmd。

使用任何 URL 和数据包大小输入以下命令。

ping www.xyz.com -f -l 1460

ping cmd 后会给出一些输出,可能如下图所示。

C:\Users\mkbt>ping www.xyz.com -f -l 1460
Pinging www.xyz.com [143.238.92.7] with 1460 bytes of data:
Reply from 143.238.92.7: bytes=68 (sent 1460) time=55ms TTL=60
Reply from 143.238.92.7: bytes=68 (sent 1460) time=42ms TTL=60
Reply from 143.238.92.7: bytes=68 (sent 1460) time=40ms TTL=60
Reply from 143.238.92.7: bytes=68 (sent 1460) time=41ms TTL=60
Ping statistics for 143.238.92.7:
  Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
  Minimum = 40ms, Maximum = 55ms, Average = 45ms

从上面可以看出,数据包没有分段,因此我们将通过增加数据包大小再次进行。

C:\Users\mkbt>ping www.xyz.com -f -l 1472
Pinging www.xyz.com [143.238.92.7] with 1472 bytes of data:
Reply from 143.238.92.7: bytes=68 (sent 1472) time=55ms TTL=60
Reply from 143.238.92.7: bytes=68 (sent 1472) time=42ms TTL=60
Reply from 143.238.92.7: bytes=68 (sent 1472) time=40ms TTL=60
Reply from 143.238.92.7: bytes=68 (sent 1462) time=41ms TTL=60
Ping statistics for 143.238.92.7:
  Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
  Minimum = 40ms, Maximum = 55ms, Average = 45ms

同样,我们没有看到碎片,所以我们将再次增加数据包的大小。

C:\Users\mkbt>ping www.xyz.com -f -l 1473
Pinging www.xyz.com [143.238.92.7] 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 statistics for 143.238.92.7:
  Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
 

结论:

在这里,我们发现数据包在其大小为 1473 字节时正在分片,这意味着此处的最大可能大小为 1472 字节。但这不是 MTU 值,要找到它,我们必须添加 IP 标头和 ICMP 标头的值,即 28 字节。因此,MTU 的值 = 1472 + 28 即 1500 字节,这是最佳 MTU 值。