Esempio n. 1
0
        public PingGraphInfo(string addr, long max)
        {
            if (p == null)
            {
                p = new Ping();
            }
            scope     = 0;
            points    = new List <DrawPoint>();
            route     = new List <PingGraphInfo>();
            address   = addr;
            maxpoints = max;

            this.DoPing();

            if (this.error != IPStatus.Success)
            {
                return;
            }

            byte[] test = Encoding.Default.GetBytes("tracert " + DateTime.UtcNow.Ticks.ToString());

            PingOptions po = new PingOptions();

            po.Ttl = 1;
            PingReply pr = p.Send(addr, 1000, test, po);

            while (pr.Status != IPStatus.Success)
            {
                PingGraphInfo subpgi = new PingGraphInfo();
                subpgi.address   = pr.Address == null ? null : pr.Address.ToString();
                subpgi.maxpoints = this.maxpoints;
                subpgi.DoPing();
                route.Add(subpgi);

                if (po.Ttl++ >= 255)
                {
                    break;
                }
                pr = p.Send(addr, 1000, test, po);
            }
        }
Esempio n. 2
0
        private void WindowTick(object sender, EventArgs e)
        {
            try
            {
                Task.Factory.StartNew(() =>
                {
                    this.Dispatcher.Invoke((Action)(() =>
                    {
                        PingGraphInfo pgi = ((Window)((DispatcherTimer)sender).Tag).Tag as PingGraphInfo;

                        pgi.DoPing();
                        ReDrawGraph(pgi);
                        UpdateStatusbar(pgi);
                        UpdateRoute(pgi);
                    }));
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show("ERROR: " + ex.Message + "\n" + ex.StackTrace);
            }
        }