Search code examples
c#windowswifipingtriangulation

Send Multiple Pings without waiting for reply Windows C#


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).

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.

Many Thanks

Dylan


Solution

  • 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