我使用以下命令以 1 毫秒的间隔从 server1 (ip:1.1.1.1) ping server2 (ip:2.2.2.1):
ping 2.2.2.1 -i 0.001 -f
我期望看到 ping 请求每 1ms 离开 server1,只要有相应请求的答复,就会发生这种情况,但如果某些回显请求序列没有答复,则 ping echo 请求数据包的间隔更改为 10ms,然后当回复恢复时,间隔再次更改为 1ms。有没有办法即使没有回复也能将 ping 间隔保持在 1ms?我检查了一些 ping 选项,但没有找到可以阻止间隔更改发生的选项。两台服务器都在 centos 7 上。提前致谢。
答案1
从man ping
:
-f Flood ping. For every ECHO_REQUEST sent a period ``.'' is printed, while for ever ECHO_REPLY received a
backspace is printed. This provides a rapid display of how many packets are being dropped. If inter-
val is not given, it sets interval to zero and outputs packets as fast as they come back or one hundred
times per second, whichever is more. Only the super-user may use this option with zero interval.
因此,当数据包返回速度不够快时,“每秒一百个”就会小于响应时间,并且下一个数据包将在 10 毫秒后发送。这么看来,洪水的速度ping
不可能比这更快了。我的第一个简单想法是运行许多命令,这可能会更加泛滥:
for i in {1..10}; do ping -f 2.2.2.1 & done