扫描网络对于特定MAC地址 - 机器人机器人、地址、网络、MAC

2023-09-05 00:06:39 作者:心比姨妈来的痛

我设计一个应用程序来控制多区域音频放大器。要做到这一点我必须创建一个socket连接,到目前为止,工作正常。我想要做的是,而不必手动键入IP地址,我想我的应用程序自动扫描网络,检查所有的MAC地址匹配到网卡数据库,如果我放的CORP相匹配的用户,然后保存的IP地址。这是可能的,如果是如何?还是有更简单的方法来做到这一点?

I'm designing an Application to control multi zone audio amplifiers. To do so I have to create a socket connection, So far that works fine. What I would like to do is instead of the user having to manually type in the ip address I would like my app to automatically scan the network, check all MAC address Match it to the NIC database, if it matches the corp of my amp, then save the ip address. Is that possible if yes how? Or is there an easier way to do it?

推荐答案

我为我的应用网络发现是这样的:循环通过IP范围,则只是ping的IP来获取MAC地址,我抢用解析的/ proc /净/ ARP。 有可能是一个更好的办法,但它为我工作。

I made it for my app "Network Discovery" like this: Loop through the ip range then just ping the ip to get the mac address, which I grab by parsing /proc/net/arp. There probably is a better way, but it works for me.

下面是范围扫描: https://github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/DnsDiscovery.java 开始和结束的IP地址为长。

Here is the range scanning: https://github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/DnsDiscovery.java start and end are ip addr as long.

这里是在/ proc /净/ ARP解析: https://github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/Network/HardwareAddress.java#L60

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