Yuri Slobodyanyuk Blog on Information Security 2024年07月23日
Network MTU maximum size path discovery (PMTU) testing with ping
index_new5.html
../../../zaker_core/zaker_tpl_static/wap/tpl_guoji1.html

 

本文详细介绍了MTU(最大传输单元)在网络吞吐量中的关键作用,并通过实例演示了如何在不同的操作系统下测试和确定最佳MTU大小,以提高数据传输效率。

📦 MTU定义与重要性:MTU是网络数据包的最大尺寸,对网络传输效率有直接影响。在互联网上,MTU通常不超过1500字节,但在私有网络中可能设置得更大。

🔍 测试MTU的方法:文章提供了在Linux和Windows系统下使用ping命令测试MTU的具体步骤。通过不断增加ping包的大小,直到出现错误信息,从而确定最大MTU值。

📊 实例演示:文章通过具体示例,展示了在Windows和Linux系统中如何执行MTU测试,以及如何解读测试结果,包括错误信息的含义。

🔧 调整MTU的潜在好处:正确配置MTU可以减少数据包分片,提高网络吞吐量,特别是在使用MPLS/IPL等专线时。

📢 注意事项:在测试和调整MTU时,需要注意不要超过网络设备的实际支持大小,以避免潜在的网络问题。

MTU (MAximum Transmit Unit) plays central role in available throughput.And while with the Internet the maximum size isn’t going to surpass 1500 bytes,on MPLS/IPL/etc lines, owned by 1 provider, it is possible to get better MTU.

THe easiest way to test for the maximum size of the packets that can pass withoutfragmenting is to use ping with appropriate option.

The idea is to send pings increasing each time their size, until we get an error.

Linux:

# for ii in {1450..2500..20} ; do ping -c 2 -M do -s ${ii} 194.90.1.5; done

Here:

    I ping the destination 194.90.1.5

    The ping size starts at 1450 bytes, and increases by 20 bytes each new ping until 2500 bytes

    -M do sets dont-fragment bit on the pings.

Windows:

for /L %A in (1450,20,2500) do ping -f -l %A -n 2  194.90.1.5

Same as for Linux - send 2 pings each time, start with the size -l of 1450,increase each time by 20 bytes, and -f set dont-fragment bit.

As for the expected error message, it is "Packet needs to be fragmented but DFset." for Windows, and "error: Message too long, mtu=" for the Linux, once pingsize is larger than possible over the path.

In the examples below the maximum MTU is 1500 bytes:

Windows:

> for /L %A in (1450,20,1550) do ping -f -l %A -n 2  194.90.1.5> ping -f -l 1450 -n 2  194.90.1.5Pinging 194.90.1.5 with 1450 bytes of data:Reply from 194.90.1.5: bytes=1450 time=4ms TTL=59Reply from 194.90.1.5: bytes=1450 time=6ms TTL=59Ping statistics for 194.90.1.5:    Packets: Sent = 2, Received = 2, Lost = 0 (0% loss),Approximate round trip times in milli-seconds:    Minimum = 4ms, Maximum = 6ms, Average = 5msC:\WINDOWS\system32>ping -f -l 1470 -n 2  194.90.1.5Pinging 194.90.1.5 with 1470 bytes of data:Reply from 10.120.12.1: Packet needs to be fragmented but DF set.Packet needs to be fragmented but DF set.

Linux:

# for ii in {1450..2000..20} ; do ping -c 2 -M do -s ${ii} 194.90.1.5; donePING 194.90.1.5 (194.90.1.5) 1450(1478) bytes of data.1458 bytes from 194.90.1.5: icmp_seq=1 ttl=45 time=54.2 ms1458 bytes from 194.90.1.5: icmp_seq=2 ttl=45 time=54.2 ms--- 194.90.1.5 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1001msrtt min/avg/max/mdev = 54.267/54.276/54.285/0.009 msPING 194.90.1.5 (194.90.1.5) 1470(1498) bytes of data.1478 bytes from 194.90.1.5: icmp_seq=1 ttl=45 time=54.2 ms1478 bytes from 194.90.1.5: icmp_seq=2 ttl=45 time=54.2 ms--- 194.90.1.5 ping statistics ---2 packets transmitted, 2 received, 0% packet loss, time 1001msrtt min/avg/max/mdev = 54.201/54.208/54.216/0.232 msPING 194.90.1.5 (194.90.1.5) 1490(1518) bytes of data.From 172.31.16.1 icmp_seq=1 Frag needed and DF set (mtu = 1500)ping: local error: Message too long, mtu=1500

Resources

Fish AI Reader

Fish AI Reader

AI辅助创作,多种专业模板,深度分析,高质量内容生成。从观点提取到深度思考,FishAI为您提供全方位的创作支持。新版本引入自定义参数,让您的创作更加个性化和精准。

FishAI

FishAI

鱼阅,AI 时代的下一个智能信息助手,助你摆脱信息焦虑

联系邮箱 441953276@qq.com

相关标签

MTU 网络吞吐量 数据包分片 ping命令 系统配置
相关文章