Network discovery in android
Asked Answered
C

0

13

I want to discover all devices (host name, MAC address and vendor name) connected to my Wifi network through an android phone. There are no common services running on the devices.

Tried the following methods:

  1. Pinging all IPs in the subnet takes too long (inetAddress.isReachable()).
  2. Sending an nbstat request to query the NETBIOs names works in some devices. Some of them give PortNotOpenException (port 137 not opened). Some other devices do not have NETBIOs name service enabled.
  3. Tried using jcifs for android. Was able to fetch host names using

    nbtAddress.getByName(ip)
    

looped over all IP addresses in the subnet. This method gives all hostnames, irrespective of whether they are active or not.

What is the best method to find all ACTIVE devices on a network? Some apps like FING seem to do it.

Edit: I tried to analyze how the android FING app does it.

  1. Connected a small hotspot with 2 devices. Started discovery in FING and captured packets on wireshark. A series of the following requests are sent(All broadcast):

Packets on wireshark

  1. Started discovery in FING on a large wifi network (65 k devices) Netbios name service query and response packets are captured. (Unicast and sometimes to broadcast address)

Meanwhile, I try to print the arp entries of my android phone on the IDE.

The number of entries keeps increasing as discovery progresses in FING app.

5 entries before discovery starts

Increases to 1025 entries as the discovery progresses.

Decreases to 150 entries after the discovery is over.

What exactly is happening? There were no ICMP requests. Can ARPRequests be sent in an android application? Please help.

Chopfallen answered 15/2, 2016 at 9:13 Comment(6)
See if this helps you #12387448Intensifier
I did check the Android Network Discovery from this GitHub repo: github.com/rorist/android-network-discovery. The app also uses isReachable() to find if the device is active. WifiP2PManager can be used only within android devices. I want to be able to detect all devices (routers, iphones, MAC, etc..)Chopfallen
I want to implement the exact same thing. I tried Android Network Discovery and for my home network the speed is pretty fine considering I have 2-3 connected devices (including my pc). This app won't reveal the device you are using it though so you may need that too but I'm not sure how to work this around yet.Hebe
I want to scan a large network (upto 65k IPs). Network discovery scans just 255 IPs. My subnet mask is 16, but the Network Discovery app shows it as 23.Chopfallen
@Chopfallen , did you find an answer?Forked
Did you find any anwser?Mezzorelievo

© 2022 - 2024 — McMap. All rights reserved.