2

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 ?

Matt
  • 22,721
  • 17
  • 71
  • 112
user1022425
  • 63
  • 1
  • 5
  • Obviously all routers are different so you'll either need a proprietary API from the manufacturer, or maybe you can use SNMP. Barring that maybe you can scrape the web management interface. – Jimmy D Nov 17 '11 at 13:21
  • If it's running on your computer, perhaps you're lucky enough and the software that implements the A.P. (I'm assuming it's third-party) keeps a file (or registry key?) with the MACs. Long shot, but you might look into it. – Vlad Nov 17 '11 at 13:26
  • This would be true if the Access Point would be a dedicated device, like a linksys AP or something. However, we are running a software Access Point on a computer, so to me, that would make it a lot easier to get the list of connected devices. Or not? – user1022425 Nov 17 '11 at 13:27

2 Answers2

0

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

Tibi
  • 1,507
  • 1
  • 9
  • 10
0

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?

Community
  • 1
  • 1
Dr. Wily's Apprentice
  • 10,212
  • 1
  • 25
  • 27