// project.Variables["proxy"].Value - положить сюда IP или Хост
try {
Ping pingSender = new Ping ();
PingOptions options = new PingOptions ();
// Use the default Ttl value which is 128,
// but change the fragmentation behavior.
options.DontFragment = true;
// Create a buffer of 32 bytes of data to be transmitted.
string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa";
byte[] buffer = Encoding.ASCII.GetBytes(data);
int timeout = 30000;
PingReply reply = pingSender.Send(project.Variables["proxy"].Value, timeout, buffer, options);
if (reply.Status == IPStatus.Success) {
project.SendInfoToLog(string.Format(@"Address: {0}", reply.Address.ToString()));
project.SendInfoToLog(string.Format(@"RoundTrip time: {0}", reply.RoundtripTime));
project.SendInfoToLog(string.Format(@"Time to live: {0}", reply.Options.Ttl));
project.SendInfoToLog(string.Format(@"Don't fragment: {0}", reply.Options.DontFragment));
project.SendInfoToLog(string.Format(@"Buffer size: {0}", reply.Buffer.Length));
return "Всё прекрасно и замечательно!";
} else {
return null;
}
} catch (PingException e) {
throw new Exception(e.InnerException.Message);
}