- about -w and -W.
-w <deadline> reply wait <deadline> in seconds -W <timeout> time to wait for response
here is my test result: -w deadline: is the time limit for the ping cmd, not for one ping response. -W timeout: is the timeout for each response.
yuchuan@crystal ~/todo/deploy/YuChuan/daily% ping -w 3 baidu.com PING baidu.com (220.181.38.148) 56(84) bytes of data. 64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=1 ttl=50 time=33.7 ms 64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=2 ttl=50 time=32.6 ms 64 bytes from 220.181.38.148 (220.181.38.148): icmp_seq=3 ttl=50 time=32.4 ms
--- baidu.com ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2003ms rtt min/avg/max/mdev = 32.407/32.892/33.652/0.543 ms yuchuan@crystal ~/todo/deploy/YuChuan/daily% ping -W 3 baidu.com PING baidu.com (39.156.69.79) 56(84) bytes of data. 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=1 ttl=49 time=30.5 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=2 ttl=49 time=39.4 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=3 ttl=49 time=29.7 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=4 ttl=49 time=29.7 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=5 ttl=49 time=35.2 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=6 ttl=49 time=29.9 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=7 ttl=49 time=29.7 ms 64 bytes from 39.156.69.79 (39.156.69.79): icmp_seq=8 ttl=49 time=37.3 ms ^C --- baidu.com ping statistics --- 8 packets transmitted, 8 received, 0% packet loss, time 7010ms rtt min/avg/max/mdev = 29.659/32.678/39.436/3.756 ms
So in the code, we need test whether only one ping is ok, '-w' looks more appropriate?
Yes, looks so.
Thanks, Fengguang