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

The iputils ping program specifies the following for the -Woption:

-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