From 4cd0375a52700f3ec420aeeac6bc1353b2cf381d Mon Sep 17 00:00:00 2001 From: amki Date: Thu, 4 Feb 2021 07:44:47 +0100 Subject: [PATCH] Do first test pings --- ISPChk/NetworkTest.cs | 42 ++++++++++++++++++++++++++++++++++++++++++ ISPChk/ispchk.db | Bin 16384 -> 16384 bytes 2 files changed, 42 insertions(+) diff --git a/ISPChk/NetworkTest.cs b/ISPChk/NetworkTest.cs index 31cd5a7..1941c68 100644 --- a/ISPChk/NetworkTest.cs +++ b/ISPChk/NetworkTest.cs @@ -3,6 +3,9 @@ using Microsoft.EntityFrameworkCore; using System; using System.Collections.Generic; using System.Linq; +using System.Net.NetworkInformation; +using System.Text; +using System.Threading; using System.Threading.Tasks; namespace ISPChk @@ -21,6 +24,45 @@ namespace ISPChk public void AddHost(Host host) { System.Diagnostics.Debug.WriteLine("Host added!"); + var t = Task.Run(() => { + + Ping pingSender = new Ping(); + + // Create a buffer of 32 bytes of data to be transmitted. + string data = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"; + byte[] buffer = Encoding.ASCII.GetBytes(data); + + // Wait 10 seconds for a reply. + int timeout = 5000; + + // Set options for transmission: + // The data can go through 64 gateways or routers + // before it is destroyed, and the data packet + // cannot be fragmented. + PingOptions options = new PingOptions(64, true); + + System.Diagnostics.Debug.WriteLine("Pinging " + host.Name); + + while (true) + { + // Send the request. + PingReply reply = pingSender.Send(host.HostName, timeout, buffer, options); + + if (reply.Status == IPStatus.Success) + { + System.Diagnostics.Debug.WriteLine("Reply from "+reply.Address.ToString()+ + ": bytes="+reply.Buffer.Length+ + " time="+ reply.RoundtripTime+"ms"); + //System.Diagnostics.Debug.WriteLine("Time to live: {0}", reply.Options.Ttl); + //System.Diagnostics.Debug.WriteLine("Don't fragment: {0}", reply.Options.DontFragment); + } + else + { + System.Diagnostics.Debug.WriteLine(reply.Status); + } + Thread.Sleep(1000); + } + }); } } } diff --git a/ISPChk/ispchk.db b/ISPChk/ispchk.db index e0145d36c04e311077d8a7b885fdcab965a4fe67..6d22f6aa0cdfb3d0f6c1e11197f8ea3ef4b02f80 100644 GIT binary patch delta 80 zcmZo@U~Fh$+`uBh#ms+*f&UHv4gN!$`2@D`>xl5NFi0x8=jW&Aq^5&Oz2y8{Azl^+ hQN@zf;u1qsJwtOnLt{N7A)d|elCF6F|#m;%cmCPmm7cyy?me;6AM2( d3xlY1NosLPN@6hx2{CSdCod?#$iB!x005pe7Eu5I