Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

What is the -w (deadline) flag in ping for? I cannot find a description of it in the ping man page; only for -W, which takes seconds as a parameter. What is the difference between them, and how can I set a ping timeout (if host is not responding) to 200ms?

share|improve this question
    
On what operating system, and if Linux, distribution, and which package is the ping executable in? There are several different versions of ping around, with different options. –  Gilles Feb 4 '13 at 22:09

2 Answers 2

up vote 3 down vote accepted

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

That is, -w sets the timeout for the entire program session. If you set -w 30, ping (the program) will exit after 30 seconds.

-W on the other hand sets the timeout for a single ping. If you set -W 1, that particular ping attempt will time out.

As for how to set an individual ping timeout of 200ms, I don't believe this can be done with iputils' version of ping. You might want to try directly programming with an ICMP library.

share|improve this answer
    
oh, my man page (archlinux) is missing the -w flag, but has the description. I just believed it to belong to -W. So no way to define a timeout smaller that 1s? –  Rafael T Feb 4 '13 at 13:22
    
@RafaelT Not as far as I'm aware. –  Chris Down Feb 4 '13 at 13:26

My manpage (Fedora 18, iputils-20121221-1.fc18) says

   -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.
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.