扫描网络查找特定 MAC 地址 - Android
我正在设计一个应用程序来控制多区域音频放大器。为此,我必须创建一个套接字连接,到目前为止效果很好。我想做的是,用户不必手动输入 IP 地址,我希望我的应用程序自动扫描网络,检查所有 MAC 地址,如果它与我的放大器的公司匹配,则将其与 NIC 数据库匹配,然后保存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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我为我的应用程序“网络发现”做了这样的操作:循环遍历 ip 范围,然后只需 ping ip 即可获取 mac 地址,我通过解析 /proc/net/arp 来获取该地址。
可能有更好的方法,但它对我有用。
这是范围扫描:
https://github.com /rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/DnsDiscovery.java
start 和 end 与 ip addr 一样长。
这是 /proc/net/arp 解析:
https:// /github.com/rorist/android-network-discovery/blob/master/src/info/lamatricexiste/network/Network/HardwareAddress.java#L60
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.
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.
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