简体   繁体   中英

Get MAC address of all devices connected to WLAN router in C#

I'm trying to get the mac addresses of all devices connected to my wireless access point (which is running on the computer itself). So far I've looked at the TCPConnectionInterface class and NetworkInterface class but couldn't find any methods for retrieving this information. I also tried the ManagedWiFi API but this only seems to show the information about the wireless networks which are within reach.

I would like to do something like this:

foreach (ConnectedDevice device : MyWirelessAccessPoint.getDevices()) {
   Console.writeline(device.getMacAddress());
}

Any suggestions on how this can be accomplished ?

If you have the IP Address of the devide, you can use http://www.pinvoke.net/default.aspx/iphlpapi.sendarp to get the MAC address.

/Tibi

I realize this isn't terribly helpful in telling you how to do it, but I'd recommend that you look at how to retrieve your machine's "arp cache".

Each machine on the network maintains its own arp cache, which maps MAC addresses to IP addresses. Since your machine is actually acting as the wireless access point, I'm guessing that you can be sure that your machine's arp cache is up-to-date.

EDIT: The GetIpNetTable Windows API function looks promising: http://msdn.microsoft.com/en-us/library/aa365956(v=VS.85).aspx

EDIT2: Also, you may want to refer to this question: How do I access ARP-protocol information through .NET?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM