/// <summary> /// Update form control with new data. /// </summary> private void UpdateForm() { TraceRouteHopData data = this.hopList[this.hopList.Count - 1]; this.dataGridView1.Rows.Add(new object[] { data.Count, data.Address, data.RoundTripTime, data.Status, data.HostName, data.Time }); if (this.dataGridView1.Rows.Count > 1) { this.dataGridView1.FirstDisplayedScrollingRowIndex = this.dataGridView1.Rows.Count - 1; } this.UpdateGraph(); }
public RouteHopFoundEventArgs(TraceRouteHopData hop, Boolean isLast) { this.Hop = hop; this.IsLastNode = isLast; }
private void ProcessHop(IPAddress address, IPStatus status, string time) { Int64 roundTripTime = 0; if (status == IPStatus.Success || status == IPStatus.TtlExpired) { System.Net.NetworkInformation.Ping ping2 = new System.Net.NetworkInformation.Ping(); try { // Do another ping to get the roundtrip time per address. PingReply reply = ping2.Send(address, this.HopTimeOut); roundTripTime = reply.RoundtripTime; status = reply.Status; } catch (Exception ex) { Log.Info(String.Empty, ex); } finally { ping2.Dispose(); ping2 = null; } } if (this.cancel) { return; } TraceRouteHopData hop = new TraceRouteHopData(this.counter++, address, roundTripTime, status, time); try { if (status == IPStatus.Success && this.ResolveNames) { IPHostEntry entry = Dns.GetHostEntry(address); hop.HostName = entry.HostName; } } catch (SocketException) { // No such host is known error. hop.HostName = String.Empty; } lock (this.hopList) this.hopList.Add(hop); if (this.RouteHopFound != null) { this.RouteHopFound(this, new RouteHopFoundEventArgs(hop, this.Idle)); } this.Idle = address.Equals(this.destinationIP); lock (this.hopList) { if (!this.Idle && this.hopList.Count >= this.HopLimit - 1) { this.ProcessHop(this.destinationIP, IPStatus.Success, DateTime.Now.ToLongTimeString()); } } if (this.Idle) { this.OnCompleted(); this.Dispose(); } }
private void ProcessHop(IPAddress address, IPStatus status, string time) { Int64 roundTripTime = 0; if (status == IPStatus.Success || status == IPStatus.TtlExpired) { System.Net.NetworkInformation.Ping ping2 = new System.Net.NetworkInformation.Ping(); try { // Do another ping to get the roundtrip time per address. PingReply reply = ping2.Send(address, this.HopTimeOut); roundTripTime = reply.RoundtripTime; status = reply.Status; } catch (Exception ex) { Log.Info(String.Empty, ex); } finally { ping2.Dispose(); ping2 = null; } } if (this.cancel) return; TraceRouteHopData hop = new TraceRouteHopData(this.counter++, address, roundTripTime, status, time); try { if (status == IPStatus.Success && this.ResolveNames) { IPHostEntry entry = Dns.GetHostEntry(address); hop.HostName = entry.HostName; } } catch (SocketException) { // No such host is known error. hop.HostName = String.Empty; } lock (this.hopList) this.hopList.Add(hop); if (this.RouteHopFound != null) this.RouteHopFound(this, new RouteHopFoundEventArgs(hop, this.Idle)); this.Idle = address.Equals(this.destinationIP); lock (this.hopList) { if (!this.Idle && this.hopList.Count >= this.HopLimit - 1) this.ProcessHop(this.destinationIP, IPStatus.Success, DateTime.Now.ToLongTimeString()); } if (this.Idle) { this.OnCompleted(); this.Dispose(); } }