Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Default ping timeout

Tags:

c#

ping

What is the default time of ping? I use the code below to send ping to tcp devices. When does IPStatus fall to timeout?

private static void ApplyPing(Topology.Runtime rt)
{
    try
    {
        if (rt.TcpClient != null)
        {
            string ip = rt.Ip;
            if (new Ping().Send(ip).Status != IPStatus.Success)
            {
                Service.WriteEventLog(string.Format("{0} ping error.", ip), EventLogEntryType.Warning);
                rt.Disconnect();
            }
        }
    }
    catch (ArgumentNullException ex)
    { 

    }
    catch (Exception ex)
    {
        Service.WriteEventLog(ex, EventLogEntryType.Error);
    }
}

Thank you.

like image 860
sanchop22 Avatar asked Jun 18 '13 07:06

sanchop22


People also ask

How do I set a ping timeout?

-w timeout Specifying a timeout value when executing the ping command adjusts the amount of time, in milliseconds, that ping waits for each reply. If you don't use the -w option, the default timeout value of 4000 is used, which is 4 seconds.

What is ping interval?

Ping Interval—Length of time the system waits between ping packets. Ping is repeated the number of times configured in the Number of Pings field, whether the ping succeeds or not.

How do I ping 1000 packets in CMD?

Type ping -f -l 1000 <default gateway address> and press Enter. Note the addition of the -f option to prevent fragmentation of the packet.


1 Answers

From MSDN here and here

The method waits five seconds for an ICMP echo reply message. If it does not receive a reply in that time, the method returns and the Status property is set to TimedOut.

And if we check in reflector, indeed we see:

public PingReply Send(string hostNameOrAddress)
{
    return this.Send(hostNameOrAddress, 5000, this.DefaultSendBuffer, null);
}
like image 103
Marc Gravell Avatar answered Sep 24 '22 01:09

Marc Gravell