全部博文(1015)
分类:
2010-07-29 17:32:41
ping排错功能的强大不在话下,下面着重对PC机上win系统的ping过程和cisco路由器上的ping的过程的差异进行研究。
首先在PC上,带上-f参数,并指定源数据包大小,ping网关: C:>ping 172.16.5.254 -l 1472 -f Pinging 172.16.5.254 with 1472 bytes of data: Reply from 172.16.5.254: bytes=1472 time=1ms TTL=255 Reply from 172.16.5.254: bytes=1472 time=1ms TTL=255 Reply from 172.16.5.254: bytes=1472 time=1ms TTL=255 Reply from 172.16.5.254: bytes=1472 time=1ms TTL=255 Ping statistics for 172.16.5.254: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 1ms, Average = 1ms C:>ping 172.16.5.254 -l 1473 -f Pinging 172.16.5.254 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 172.16.5.254: Packets: Sent = 4, Received = 0, Lost = 4 (100% loss) 网卡的默认MTU是1500,通过设置DF位,我们测试的结果是-l的值1472,而1500-20-8=1472正好是1472(记得否,ICMP包是直接封装在IP包里的,8个byte的ICMP包头和20个byte的IP包头),由此可以看出,在win xp/2k3环境下,ping进程对-l参数识别为数据净负荷,即,不包括IP包头部分和ICMP包头部分; 下面是在cisco路由器上的测试: R6#sh int s1/1 Serial1/1 is up, line protocol is up Hardware is M4T Internet address is 172.16.36.2/30 MTU 1500 bytes, BW 1544 Kbit, DLY 20000 usec, -----------out put omit--------------------- R6#ping 192.168.100.3 size 1500 df-bit Type escape sequence to abort. Sending 5, 1500-byte ICMP Echos to 192.168.100.3, timeout is 2 seconds: Packet sent with the DF bit set !!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 40/47/68 ms R6#ping 192.168.100.3 size 1501 df-bit Type escape sequence to abort. Sending 5, 1501-byte ICMP Echos to 192.168.100.3, timeout is 2 seconds: Packet sent with the DF bit set ..... 显然,cisco设备上的ping进程的-size参数表示的是MTU,包括了IP报头和ICMP包头。你发现了没? ping x.x.x.x size x df 命令是解决由于网络MTU引起的网络故障的超必杀,经过GRE隧道、PPPOE拨号、 MPLS VPN等多种网络环境,都会产生大包不通,表现为,某些网页打不开、无法下载大容量文件,都可以用这个命令来探测网络经过各种环境下的单包最大数据净负荷(最大三层信息),并通过修改MTU以实现网络的畅通无阻。 下面是家庭中的tp link路由器 192.168.1.1是网关 -f是不分片
C:\Documents and Settings\renyu>ping 192.168.1.1 -l 1432 -f
Pinging 192.168.1.1 with 1433 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 192.168.1.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), C:\Documents and Settings\renyu>ping 192.168.1.1 -l 1431-f
Pinging 192.168.1.1 with 1431 bytes of data:
Request timed out.
Request timed out. Request timed out. Request timed out. Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), C:\Documents and Settings\renyu>ping 192.168.1.1 -l 1431-f
Pinging 192.168.1.1 with 1431 bytes of data:
Request timed out.
Request timed out. Request timed out. Request timed out. Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss), C:\Documents and Settings\renyu>ping 192.168.1.1 -l 1430 -f
Pinging 192.168.1.1 with 1430 bytes of data:
Reply from 192.168.1.1: bytes=1430 time=1ms TTL=64
Reply from 192.168.1.1: bytes=1430 time=1ms TTL=64 Reply from 192.168.1.1: bytes=1430 time=1ms TTL=64 Reply from 192.168.1.1: bytes=1430 time=1ms TTL=64 Ping statistics for 192.168.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 1ms, Maximum = 1ms, Average = 1ms |