-2

Possible Duplicate:
Get all IP-Hosts in Lan from mobile device

How can I get programmaticaly all the hosts in a wireless network?

I know the wlan I'm working in and I am connected to it. Now I want to show a list of the hosts (or at least their IP-Addresses).

How can I accomplish this, and are there special points if I work on windows mobile with compact framework and want to do that?

Community
  • 1
  • 1
abc
  • 2,285
  • 5
  • 29
  • 64
  • You asked pretty much the same question two hours ago: http://stackoverflow.com/questions/13233808/get-all-ip-hosts-in-lan-from-mobile-device – tomfanning Nov 05 '12 at 16:21
  • first idea coming to mind is enumerating all ip addresses in the subnetwork and try to ping them (or better try some portscan for known services). – BigMike Nov 05 '12 at 16:21

3 Answers3

2

There are lots of ways. For example:

  • ARP:

http://msdn.microsoft.com/en-us/library/aa366358%28VS.85%29.aspx

  • WMI:

http://weblogs.sqlteam.com/mladenp/archive/2010/11/04/find-only-physical-network-adapters-with-wmi-win32_networkadapter-class.aspx

  • ICMP:

http://social.msdn.microsoft.com/Forums/en/netfxnetcom/thread/8a528983-915b-4d94-836e-804b03e6261f

Etc

paulsm4
  • 114,292
  • 17
  • 138
  • 190
  • Nice approach but none of these solutions ensure that you'll get ALL the hosts in the wlan. Local firewalls ussually block icmp, ping and wmi requests. – Yván Ecarri Nov 05 '12 at 16:28
  • getting ALL hosts in a lan is pretty difficult, best approach is portscan for known services (wmi, netbios, ICMP and others), but still something can be missed. Network scanners are not simple to write. (and to keep up to date) – BigMike Nov 05 '12 at 16:31
0

The easy answer is: You can't. Going more in detail: you can't unless you have a protocol to discover your hosts, for example, NetBIOS. You can call NetBEUI (NetBios User Interface) through pInvoke. Look at this previous post:

Netbios support in .NET?

Another approach you can use is to ping all the IP addresses in your WLAN range and wait for responses. This is not a good approach as it is very resource consuming.

Community
  • 1
  • 1
Yván Ecarri
  • 1,661
  • 18
  • 39
0

The only way to get all the hosts in a network is to use network scanning.

You could ping all the valid IPs of the network the device is in.

Or you could check every valid IP of the network on the local DNS service for a name and list the different names you found with corresponding IP.

An IP would be valid if the Bits corresponding to the subnet mask are the same to the IP the device has.

gnomix
  • 39
  • 8