发送多个Ping而无需等待答复Windows C# [英] Send Multiple Pings without waiting for reply Windows C#

查看:194
本文介绍了发送多个Ping而无需等待答复Windows C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在为我的最后一年BSc项目做研究.最终产品将包括室内位置跟踪功能.传统或使用最多的方法似乎是RSSI三角测量法,但我热衷于尝试提高PING方法的准确性,因为我认为这将更适合可能遭受信号衰减的位置(我打算使用该设备可能会有中等程度的无线电干扰.

Im currently doing research towards my final year BSc project. The final product will include indoor location tracking functionality. The traditional, or most utilised method seems to be RSSI triangulation, but I am keen to attempt to improve the accuracy of the PING method as I think this would be better suited to locations that may suffer from signal attenuation (the locations I am intending to use the device may have a moderate ammount of radio interference).

我想知道是否可以用c#编写软件来模仿linux ping实用程序的ping泛洪功能(该功能可以发送多个ping而无需等待答复).我假设使用多个ping并从第一个到最后定时对其进行计时将使该方法可以在较短的距离内使用.

I was wondering if it was possible to write software in c# that would mimick the ping flood ability of linux ping utility(which enable the sending of multiple pings without waiting for a reply). I hypothesize that using multiple pings and timing them from the first to the last will enable the usage of the method over shorter distances.

非常感谢

迪伦

推荐答案

尝试这一希望它能正常工作

try this hope it works fine

private ArrayList IPList()
        {
            string myipsplit = string.Empty;
            string myip =
                Dns.GetHostAddresses(
                    Dns.GetHostName())[0].ToString();
            string[] myiparray = myip.Split(new[] {'.'});
            for (int j = 1; j < myiparray.Length; j++)
                myipsplit += myiparray[j - 1] + ".";
            var sb = new ArrayList();
            MyPing ping = delegate(int id)
                              {
                                  string ls = myipsplit + id;
                                  var pingSender = new System.Net.NetworkInformation.Ping();
                                  PingReply reply = pingSender.Send(ls, 0);
                                  if (reply != null)
                                      if (reply.Status == IPStatus.Success)
                                          sb.Add(ls);
                              };
            var asyncResults = new IAsyncResult[0x100];
            for (int i = 1; i < 0x100; i++)
                asyncResults[i] = ping.BeginInvoke(i, null, null);
            for (int i = 1; i < 0x100; i++)
                ping.EndInvoke(asyncResults[i]);
            return sb;
        }

        #region Nested type: MyPing

        private delegate void MyPing(int id);

        #endregion

这篇关于发送多个Ping而无需等待答复Windows C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆