我正在学习 ping 命令及其选项。
在 ping 中,-U 选项用于完整的用户到用户延迟。
ping 和 ping -U 选项的输出没有区别。
$ ping google.com
PING google.com (216.58.199.174) 56(84) bytes of data.
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=1 ttl=57 time=49.9 ms
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=2 ttl=57 time=44.6 ms
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=3 ttl=57 time=43.6 ms
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=4 ttl=57 time=45.6 ms
^C
--- google.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3003ms
rtt min/avg/max/mdev = 43.641/45.990/49.991/2.422 ms
$ ping -U google.com
PING google.com (216.58.199.174) 56(84) bytes of data.
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=1 ttl=57 time=54.9 ms
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=3 ttl=57 time=46.0 ms
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=4 ttl=57 time=42.8 ms
64 bytes from bom05s08-in-f14.1e100.net (216.58.199.174): icmp_req=5 ttl=57 time=42.2 ms
^C
--- google.com ping statistics ---
6 packets transmitted, 4 received, 33% packet loss, time 5013ms
rtt min/avg/max/mdev = 42.267/46.544/54.984/5.091 ms
谁能解释一下这两个命令有什么区别以及 ping 命令中 -U 选项有什么用途。
答案1
据我所知,标准 ping 显示网络往返响应时间,而 ping -U 显示用户到用户延迟。响应时间和用户延迟可能会因 DNS 故障和其他网络拥塞而有所不同。
在您给出的例子中,当时没有任何问题。
但这可能并不准确......这是我经过一些短暂的研究后得出的结论
另外,ping 的另一个好用的开关是 -c 开关,它是 ping 计数。Windows ping 4 次然后停止,而 Ubuntu 会一直 ping 直到你停止它。-c 开关将改变这一点。如果你使用ping -c 4 google.com
它,它将 ping 4 次然后停止。