ping 响应时间并不反映真实的网络响应时间

ping 响应时间并不反映真实的网络响应时间

我遇到了一个奇怪的问题,返回的响应时间ping几乎固定在98ms

我要么ping访问网关,要么 ping 本地主机或互联网主机。响应时间总是在附近,98ms尽管实际延误是显而易见的。

但是,反向 ping(从本地机器到该主机)工作正常。

以下是我的路线表和结果:

route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.1.1     0.0.0.0         UG    100    0        0 eth1
60.194.136.0    0.0.0.0         255.255.255.0   U     0      0        0 eth0
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth1
192.168.1.0     0.0.0.0         255.255.255.0   U     0      0        0 eth1

# ping the gateway
ping 192.168.1.1
PING 192.168.1.1 (192.168.1.1) 56(84) bytes of data.
64 bytes from 192.168.1.1: icmp_req=1 ttl=64 time=98.7 ms
64 bytes from 192.168.1.1: icmp_req=2 ttl=64 time=97.0 ms
64 bytes from 192.168.1.1: icmp_req=3 ttl=64 time=96.0 ms
64 bytes from 192.168.1.1: icmp_req=4 ttl=64 time=94.9 ms
64 bytes from 192.168.1.1: icmp_req=5 ttl=64 time=94.0 ms
^C
--- 192.168.1.1 ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 4004ms
rtt min/avg/max/mdev = 94.030/96.149/98.744/1.673 ms 

#ping a local machine
ping 192.168.1.88
PING 192.168.1.88 (192.168.1.88) 56(84) bytes of data.
64 bytes from 192.168.1.88: icmp_req=1 ttl=64 time=98.7 ms
64 bytes from 192.168.1.88: icmp_req=2 ttl=64 time=96.9 ms
64 bytes from 192.168.1.88: icmp_req=3 ttl=64 time=96.0 ms
64 bytes from 192.168.1.88: icmp_req=4 ttl=64 time=95.0 ms
^C
--- 192.168.1.88 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 95.003/96.696/98.786/1.428 ms

#ping a internet host
 ping google.com
PING google.com (74.125.128.139) 56(84) bytes of data.
64 bytes from hg-in-f139.1e100.net (74.125.128.139): icmp_req=1 ttl=42 time=99.8 ms
64 bytes from hg-in-f139.1e100.net (74.125.128.139): icmp_req=2 ttl=42 time=99.9 ms
64 bytes from hg-in-f139.1e100.net (74.125.128.139): icmp_req=3 ttl=42 time=99.9 ms
64 bytes from hg-in-f139.1e100.net (74.125.128.139): icmp_req=4 ttl=42 time=99.9 ms
^C64 bytes from hg-in-f139.1e100.net (74.125.128.139): icmp_req=5 ttl=42 time=99.9 ms

--- google.com ping statistics ---
5 packets transmitted, 5 received, 0% packet loss, time 32799ms
rtt min/avg/max/mdev = 99.862/99.925/99.944/0.284 ms

我正在运行iperf测试带宽,对于 LAN 连接来说,速率相当低。

iperf -c 192.168.1.87 -t 50 -i 10 -f M
------------------------------------------------------------
Client connecting to 192.168.1.87, TCP port 5001
TCP window size: 0.06 MByte (default)
------------------------------------------------------------
[  4] local 192.168.1.139 port 54697 connected with 192.168.1.87 port 5001
[ ID] Interval       Transfer     Bandwidth
[  4]  0.0-10.0 sec  6.12 MBytes  0.61 MBytes/sec
[  4] 10.0-20.0 sec  6.38 MBytes  0.64 MBytes/sec
[  4] 20.0-30.0 sec  6.38 MBytes  0.64 MBytes/sec
[  4] 30.0-40.0 sec  6.25 MBytes  0.62 MBytes/sec
[  4] 40.0-50.0 sec  6.38 MBytes  0.64 MBytes/sec
[  4]  0.0-50.1 sec  31.6 MBytes  0.63 MBytes/sec

答案1

ping将尝试对 IP 地址执行 DNS PTR 查询,这可能是您看到的延迟。运行ping -n以禁用。

您可能还会看到非 ICMP 流量的不同行为。尝试使用在各个端口上发送 UDP 和 TCP 数据包来检查这一点。

答案2

iperf udp模式更能代表实际的帧转换延迟和失败率。

一些面向会话的 TCP 测试掩盖了丢失。

您还可以使用 iperf 做一些很酷的事情,例如抖动测量。

http://openmaniak.com/iperf.php

相关内容