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.
-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.
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.
Type ping -f -l 1000 <default gateway address> and press Enter. Note the addition of the -f option to prevent fragmentation of the packet.
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);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With