Example #1
0
 private void RaiseOnHopPing(IPRouteHop hop)
 {
     if (OnHopPing != null)
     {
         OnHopPing(this, hop);
     }
 }
Example #2
0
 private void PingHop(IPRouteHop hop)
 {
     if (!CheckStop())
     {
         _ping.SendAsync(hop.Address, _timeout, hop);
     }
 }
Example #3
0
 private void RaiseOnHopSuccess(IPRouteHop hop)
 {
     if (OnHopSuccess != null)
     {
         OnHopSuccess(this, hop);
     }
 }
Example #4
0
        void _ping_PingCompleted(object sender, PingCompletedEventArgs e)
        {
            if (e.UserState == null)
            {
                if (e.Reply.Status == IPStatus.TtlExpired || e.Reply.Status == IPStatus.Success)
                {
                    IPRouteHop hop = new IPRouteHop(e.Reply.Address, _currentHop, _pingsPerHop);
                    _route.Add(hop);

                    _nameResolver.ResolveHostName(e.Reply.Address, new AsyncHostNameResolver.StoreHostNameDelegate(hop.StoreHostName));

                    RaiseOnHopSuccess(hop);

                    _currentHop++;
                    PingHop(hop);
                }
                else
                {
                    RaiseOnHopFail(_currentHop, _currentRetry, e.Reply.Address, e.Reply.Status);

                    if (_currentRetry < _hopRetries)
                    {
                        _currentRetry++;
                        NextHop();
                    }
                    else
                    {
                        lock (_runControlLock)
                        {
                            _active = false;
                            _stopEvent.Set();
                        }

                        RaiseOnTraceCompleted(TraceStatus.Failed);
                    }
                }
            }
            else
            {
                IPRouteHop hop = (IPRouteHop)e.UserState;

                hop.StorePingResult(e.Reply.Status == IPStatus.Success ? e.Reply.RoundtripTime : -1);

                RaiseOnHopPing(hop);

                if (!hop.Complete)
                {
                    PingHop(hop);
                }
                else if (!hop.Address.Equals(_target))
                {
                    NextHop();
                }
                else
                {
                    lock (_runControlLock)
                    {
                        _active = false;
                        _stopEvent.Set();
                    }

                    RaiseOnTraceCompleted(TraceStatus.Successed);
                }
            }
        }