# When does the iputils ping program -W option wait for two RTTs?

The iputils ping program specifies the following for the `-W`option:

``````-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.
``````

In which cases would the `-W` value not take effect, and the "wait for two RTTs" apply?

In the case where there has been any reply from the pinged machine during the ping sequence. In that case, `ping` times out after a time equal to the max value of all RTTs in the ping sequence, multiplied by two.

In this example, timeout is set at 55.392 × 2 = 110.784 ms:

``````PING www.google.com (173.194.44.80) 56(84) bytes of data.
64 bytes from 173.194.44.80: icmp_seq=1 ttl=47 time=55.3 ms
64 bytes from 173.194.44.80: icmp_seq=2 ttl=47 time=52.6 ms
64 bytes from 173.194.44.80: icmp_seq=3 ttl=47 time=52.7 ms
64 bytes from 173.194.44.80: icmp_seq=4 ttl=47 time=53.9 ms
64 bytes from 173.194.44.80: icmp_seq=5 ttl=47 time=52.5 ms
64 bytes from 173.194.44.80: icmp_seq=6 ttl=47 time=52.7 ms
64 bytes from 173.194.44.80: icmp_seq=7 ttl=47 time=52.8 ms
64 bytes from 173.194.44.80: icmp_seq=8 ttl=47 time=53.2 ms
^C
8 packets transmitted, 8 received, 0% packet loss, time 7010ms
rtt min/avg/max/mdev = 52.535/53.273/55.392/0.939 ms
``````

If the machine you're trying to ping does not reply at all:

• if you do not use the `-W` flag, ping timeouts after a time that depends on the implementation, usually 4 or 10 seconds
• if you use the `-W` flag, ping timeouts after the specified time