0

I would ask if it is possible to get information about connected devices in the local wireless network. Is there any api for xamarin to do that?

StarterPack
  • 498
  • 1
  • 7
  • 28
screamingworld
  • 93
  • 1
  • 11

3 Answers3

1

It doesn't seem like Xamarin has an API for this, but Microsoft introduced a Ping (documentation here) and a NetworkInterface class (documentation here) in .NET 2.0 that you could use.

Essentially, what you need to do, is to ping the IP adresses on your local network, which you can do asynchronously using SendAsync(). You then register the callbacks by registering an EventHandler to PingCompleted. The callback will contain a PingCompletedEventArgs which you can use to retrieve basic information (e.g. IP, MAC and Hostname) about the device.

You can find a complete guide of the implementation here.

I hope this helps.

Note: Of course, it all depends on what type of information you expect to retrieve. Although, I think you can only expect to retrieve the basic information about devices on your network, as everything else could potentially be a security risk.

Secondary note: Depending on which devices you wish to discover on your network, you could also use the SNMP component which will allow you to discover devices such as routers, switches, printers, and so on.

Demitrian
  • 3,200
  • 1
  • 24
  • 41
  • Thanks for your advice. So the problem is that I do not know the ip of the device. I need a list of all network (devices). When I do it with ping, then I need to ping the complete range and look if I get any success? Is this not to slow? I need the the ip from a special device in the local network. All I know from it is the mac address. Is there a way to get the device by an mac address? – screamingworld Feb 15 '16 at 22:36
0

I am thinking you are looking for which devices at layer-2 have registered with your wireless controller/accept-point/router and by being connected you are referring to how many have successfully establish 802.x handshake (implying security exchange and channel establishment has occurred).

There exists a tool to do this work (never tested this on my mac) and you can check Flying Squirrel for the above purpose. This will ofcourse be an independent sniffer over the wireless network and you'll require the password used for wifi etc. for making this work.

If you have access to a device that exposes instrumentation (MIB) then you can get that information from the device by SNMP walking the device. At this level you'll of course get the MAC address table and if DHCP is running on your router then perhaps access to DHCP table can give you information about the MAC to IP mapping. On some medium to high end networking gear MIBs like CISCO-DOT11-ASSOCIATION-MIB can be used. Also I am assuming you are refering to 802.11 here there are other wireless protocols like BlueTooth etc. in play as well which use different scanning techniques so the answer depends on what kind of network you are referring to here.

Aniruddh Dikhit
  • 662
  • 4
  • 10
0

Ok, I figured out a way without snifing the local network. It makes more sense the following way in my case...

Case: I want to connect to an device which provide an own wlan network. Then I connect to it and pass the home wlan network to it. The device restarts and is now configured as a client in the local home network. And now I need the local ip for service communications.

My Solution: I do a register call to the device. The device gives me the mac address. Now I register (with phone device) the mac address from the access point device in a online service. After the device has been restarted and get the new local ip address it sends to the online service. And the I can retrieve the local ip address through polling or through getting push notification from the server...

screamingworld
  • 93
  • 1
  • 11
  • Glad to know you found a solution to your problem. Just in case you need further inspiration, you can read what others have done in [this post on SO](http://stackoverflow.com/questions/2567107/ping-or-otherwise-tell-if-a-device-is-on-the-network-by-mac-in-c-sharp). On a sidenote, it would have helped a lot if you, in your original question, had mentioned that you already knew the MAC Address of the device. – Demitrian Feb 16 '16 at 17:16