Network Scanning for a Specific MAC Address - Android

I am developing a multi-zone sound amplifier control application. To do this, I need to create a socket connection, so far this is working fine. I would like for the user, instead of manually entering the IP address, would like my application to automatically scan the network, check all the MAC addresses. Match this with the NIC database if it matches the chassis of my amplifier, then save the IP address. Is it possible, if so, how? Or is there an easier way to do this?

+3
source share
1 answer

I did this for my "Network Discovery" application as follows: Loop through the ip range and then just ping ip to get the mac address, which I grab by parsing / proc / net / arp. This is probably the best way, but it works for me.

Here is a range scan: https://github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/DnsDiscovery.java beginning and end: ip addr for how long.

And here is the parsing / proc / net / arp: https://github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/Network/HardwareAddress.java#L60

+7
source

Source: https://habr.com/ru/post/1774819/


All Articles