public static void Start(string address, CancellationToken cancellationToken) { PingAttributes attrs = new PingAttributes(); m_Address = address; // Verify address attrs.ResolvedAddress = Lookup.QueryDNS(address, AddressFamily.InterNetwork); // Setup ping attributes attrs.Interval = 0; attrs.Timeout = 100; attrs.Message = "R U Dead Yet?"; // TODO: Option for 'heavy' flood with bloated packet sizes attrs.Continous = true; Ping p = new Ping(attrs, cancellationToken, ResultsUpdateCallback); // Disable output for faster speeds Display.ShowOutput = false; // Start flooding PingResults results = p.Send(); // Display results Display.ShowOutput = true; Display.PingResults(attrs, results); }
/// <summary> /// Sends a set of ping packets, results are stores within /// Ping.Results of the called object /// /// Acts as a basic wrapper to SendICMP and feeds it a specific /// set of PingAttributes /// </summary> public PingResults Send(PingAttributes attrs, Action <PingResults> onResultsUpdate = null) { // Lookup host if specified if (attrs.InputtedAddress != "") { attrs.Address = Lookup.QueryDNS(attrs.InputtedAddress, attrs.ForceV4 ? AddressFamily.InterNetwork : AddressFamily.InterNetworkV6); } Display.PingIntroMsg(attrs); if (Display.UseResolvedAddress) { try { attrs.InputtedAddress = Helper.RunWithCancellationToken(() => Lookup.QueryHost(attrs.Address), m_CancellationToken); } catch (OperationCanceledException) { return(new PingResults()); } if (attrs.InputtedAddress == "") { // If reverse lookup fails just display whatever is in the address field attrs.InputtedAddress = attrs.Address; } } // Perform ping operation and store results PingResults results = SendICMP(attrs, onResultsUpdate); if (Display.ShowOutput) { Display.PingResults(attrs, results); } return(results); }
public void Start(string address, CancellationToken cancellationToken) { PingAttributes attrs = new PingAttributes(); _address = address; // Verify address attrs.ResolvedAddress = Lookup.QueryDNS(address, AddressFamily.InterNetwork); // Setup ping attributes attrs.Interval = 0; attrs.Timeout = 100; attrs.Message = "R U Dead Yet?"; // TODO: Option for 'heavy' flood with bloated packet sizes attrs.Continous = true; // Setup ping object Ping p = new Ping(attrs, cancellationToken); p.OnResultsUpdate += OnResultsUpdate; // Start flooding PingResults results = p.Send(); ConsoleDisplay.PingResults(attrs, results); }
private void ResolveAddress() { // If we have not been given a resolved address, perform dns query for inputted address if (m_PingAttributes.ResolvedAddress == "") { AddressFamily family = m_PingAttributes.UseICMPv4 ? AddressFamily.InterNetwork : AddressFamily.InterNetworkV6; m_PingAttributes.ResolvedAddress = Lookup.QueryDNS(m_PingAttributes.InputtedAddress, family); } }
public Graph(string address, CancellationToken cancellationTkn) { m_CancellationToken = cancellationTkn; m_Ping = new Ping(cancellationTkn); // Setup ping attributes m_PingAttributes.InputtedAddress = Lookup.QueryDNS(address, System.Net.Sockets.AddressFamily.InterNetwork); m_PingAttributes.Continous = true; }
public static void Start(string address, CancellationToken cancellationToken) { PingAttributes attrs = new PingAttributes(); RateLimiter displayUpdateLimiter = new RateLimiter(TimeSpan.FromMilliseconds(500)); ulong previousPingsSent = 0; Ping p = new Ping(cancellationToken); // Verify address attrs.Address = Lookup.QueryDNS(address, AddressFamily.InterNetwork);; // Setup ping attributes attrs.Interval = 0; attrs.Timeout = 100; attrs.Message = "R U Dead Yet?"; // TODO: Option for 'heavy' flood with bloated packet sizes attrs.Continous = true; // Disable output for faster speeds Display.ShowOutput = false; // This callback will run after each ping iteration void ResultsUpdateCallback(PingResults r) { // Make sure we're not updating the display too frequently if (!displayUpdateLimiter.RequestRun()) { return; } // Calculate pings per second double pingsPerSecond = 0; if (displayUpdateLimiter.ElapsedSinceLastRun != TimeSpan.Zero) { pingsPerSecond = (r.Sent - previousPingsSent) / displayUpdateLimiter.ElapsedSinceLastRun.TotalSeconds; } previousPingsSent = r.Sent; // Update results text Display.FloodProgress(r.Sent, (ulong)Math.Round(pingsPerSecond), address); } // Start flooding PingResults results = p.Send(attrs, ResultsUpdateCallback); // Display results Display.ShowOutput = true; Display.PingResults(attrs, results); }