C# - How do I access the WLAN signal strength and others?

故事扮演 提交于 2019-12-17 17:58:15

问题


Many scientists have published papers documenting how devices connected via WLAN can be tracked by measuring its Signal Strength, Time Of Arrival, Round Trip Time, etc. Any idea how I can access these values in Windows using any .NET API?

Or do you know of software SDKs already available for location tracking?


回答1:


hello for WIndows 7 this is a good code wich can detect all AP with MAC adress RSSI SSID :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using NativeWifi;

class Program
{

    static void Main(string[] args)
    {

        WlanClient client = new WlanClient();
        // Wlan = new WlanClient();
        try
        {
            foreach (WlanClient.WlanInterface wlanIface in client.Interfaces)
            {

                Wlan.WlanBssEntry[] wlanBssEntries = wlanIface.GetNetworkBssList();

                foreach (Wlan.WlanBssEntry network in wlanBssEntries)
                {
                    int rss = network.rssi;
                    //     MessageBox.Show(rss.ToString());
                    byte[] macAddr = network.dot11Bssid;

                    string tMac = "";

                    for (int i = 0; i < macAddr.Length; i++)
                    {

                        tMac += macAddr[i].ToString("x2").PadLeft(2, '0').ToUpper();

                    }



                    Console.WriteLine("Found network with SSID {0}.", System.Text.ASCIIEncoding.ASCII.GetString(network.dot11Ssid.SSID).ToString());

                    Console.WriteLine("Signal: {0}%.", network.linkQuality);

                    Console.WriteLine("BSS Type: {0}.", network.dot11BssType);

                    Console.WriteLine("MAC: {0}.", tMac);

                    Console.WriteLine("RSSID:{0}", rss.ToString());


                }
                Console.ReadLine();
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }

        }
    }  
}

i hope it will be helpful enjoy




回答2:


The Managed Wifi API will provide signal strength information. Here's a code snippet adapted from a question I previously posed and was answered here:

static void Main(string[] args)
{
    WlanClient client = new WlanClient();
    foreach ( WlanClient.WlanInterface wlanIface in client.Interfaces )
    {
        Wlan.WlanAvailableNetwork[] networks = wlanIface.GetAvailableNetworkList( 0 );
        foreach ( Wlan.WlanAvailableNetwork network in networks )
        {
            Console.WriteLine( "Found network with SSID {0} and Siqnal Quality {1}.", GetStringForSSID(network.dot11Ssid), network.wlanSignalQuality);
        }
    }
}

static string GetStringForSSID(Wlan.Dot11Ssid ssid)
{
    return Encoding.ASCII.GetString(ssid.SSID, 0, (int) ssid.SSIDLength);
}



回答3:


Windows itself provides a Location API now.



来源:https://stackoverflow.com/questions/1686715/c-sharp-how-do-i-access-the-wlan-signal-strength-and-others

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!