Beispiel #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="address"></param>
        /// <param name="status"></param>
        private void ProcessNode
        (
            [Annotations.CanBeNull] IPAddress address,
            IPStatus status)
        {
            long roundTripTime = 0;

            if ((status == IPStatus.TtlExpired) ||
                (status == IPStatus.Success))
            {
                var pingIntermediate = new Ping();

                try
                {
                    //Compute roundtrip time to the IpAddress by pinging it
                    if (address != null)
                    {
                        var reply = pingIntermediate.Send
                                    (
                            address,
                            this._timeout);
                        if (reply != null)
                        {
                            roundTripTime = reply.RoundtripTime;
                            status        = reply.Status;
                        }
                    }
                }
                catch (PingException e)
                {
                    //Do nothing
                    System.Diagnostics.Trace.WriteLine
                    (
                        e);
                }
                finally
                {
                    pingIntermediate.Dispose();
                }
            }

            if (address != null)
            {
                var node = new TracertNode
                           (
                    address,
                    roundTripTime,
                    status);

                var tracertNodes = this.NodesList;
                if (tracertNodes != null)
                {
                    lock (tracertNodes)
                    {
                        tracertNodes.Add
                        (
                            node);
                    }
                }

                this.RouteNodeFound?.Invoke
                (
                    this,
                    new RouteNodeFoundEventArgs(node));
            }

            if (address != null)
            {
                this.IsDone = address.Equals
                              (
                    this.Destination);
            }

            var nodesList = this.NodesList;

            if (nodesList != null)
            {
                lock (nodesList)
                {
                    if (!this.IsDone &&
                        (nodesList.Count >= (this._maxHops - 1)))
                    {
                        this.ProcessNode
                        (
                            this.Destination,
                            IPStatus.Success);
                    }
                }
            }
        }
Beispiel #2
0
 /// <summary>
 /// </summary>
 /// <param name="node"></param>
 protected internal RouteNodeFoundEventArgs(TracertNode node)
 {
     this.NodeProperty = node;
 }