从C#获取无线接入点的BSSID(MAC地址) [英] Get BSSID (MAC address) of wireless access point from C#

查看:317
本文介绍了从C#获取无线接入点的BSSID(MAC地址)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能获得的无线接入BSSID / MAC(媒体访问控制)地址指向我的系统连接到使用C#?

How can I get the BSSID / MAC (Media Access Control) address of the wireless access point my system is connected to using C#?

请注意,我很感兴趣的是WAP的BSSID。这是从WAP的组网一部分的MAC地址不同的

Note that I'm interested in the BSSID of the WAP. This is different from the MAC address of the networking portion of the WAP.

推荐答案

以编程方式执行以下需求:

The following needs to be executed programmatically:

netsh wlan show networks mode=Bssid | findstr "BSSID"

上面显示了WAP无线MAC地址是不同:

The above shows the WAP Wireless MAC addresses which is different from:

arp -a | findstr 192.168.1.254

这是因为在WAP有2的MAC地址。一种为无线设备,一个用于网络设备。我希望无线MAC但网络MAC使用获得的 ARP

This is because the WAP has 2 MAC addresses. One for the wireless device and one for the networking device. I want the wireless MAC but get the networking MAC using arp.

使用管理无线API

var wlanClient = new WlanClient();
foreach (WlanClient.WlanInterface wlanInterface in wlanClient.Interfaces)
{
    Wlan.WlanBssEntry[] wlanBssEntries = wlanInterface.GetNetworkBssList();
    foreach (Wlan.WlanBssEntry wlanBssEntry in wlanBssEntries)
    {
        byte[] macAddr = wlanBssEntry.dot11Bssid;
        var macAddrLen = (uint) macAddr.Length;
        var str = new string[(int) macAddrLen];
        for (int i = 0; i < macAddrLen; i++)
        {
            str[i] = macAddr[i].ToString("x2");
        }
        string mac = string.Join("", str);
        Console.WriteLine(mac);
    }
}

这篇关于从C#获取无线接入点的BSSID(MAC地址)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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