コード例 #1
0
        /// <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();
        }
コード例 #2
0
 public RouteHopFoundEventArgs(TraceRouteHopData hop, Boolean isLast)
 {
     this.Hop = hop;
     this.IsLastNode = isLast;
 }
コード例 #3
0
 public RouteHopFoundEventArgs(TraceRouteHopData hop, Boolean isLast)
 {
     this.Hop        = hop;
     this.IsLastNode = isLast;
 }
コード例 #4
0
        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();
            }
        }
コード例 #5
0
ファイル: TraceRoute.cs プロジェクト: RSchwoerer/Terminals
        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();
            }
        }