Answers:
来自man ping
:
-w deadline
Specify a timeout, in seconds, before ping exits regardless of how many packets have been sent or received. In this case ping does not stop after count packet are sent, it waits either for deadline expire or until count probes are answered or for some error
notification from network.
-W timeout
Time to wait for a response, in seconds. The option affects only timeout in absense of any responses, otherwise ping waits for two RTTs.
也就是说,-w
设置整个程序会话的超时时间。如果您设置-w 30
,ping
(程序)将在30秒后退出。
-W
另一方面,设置单个ping的超时时间。如果设置-W 1
,则该特定的ping尝试将超时。
至于如何将单个ping超时设置为200毫秒,我不认为这可以通过iputils
'的版本完成ping
。您可能想尝试直接使用ICMP库进行编程。
-w
标志,但是有描述。我只是认为它属于-W。因此,没有办法定义小于1s的超时吗?
-w
,-c
将被忽略。如果您只需要一次ping,则可以使用-c 1 -W 4
或适当的超时方法。
我的联机帮助页(Fedora 18,iputils-20121221-1.fc18)说
-w deadline
Specify a timeout, in seconds, before ping exits regardless of
how many packets have been sent or received. In this case ping
does not stop after count packet are sent, it waits either for
deadline expire or until count probes are answered or for some
error notification from network.
-W timeout
Time to wait for a response, in seconds. The option affects only
timeout in absence of any responses, otherwise ping waits for
two RTTs.
ping
中)?ping有几种不同的版本,具有不同的选项。