How to scan IP and Mac address of all Device Connected to wifi in android accurately?

后端 未结 2 986
借酒劲吻你
借酒劲吻你 2021-01-02 04:35

Hi i am trying to find all devices connected to My WIFI Router from android and ,i need to device Mac address and local ip address of each device (Including iOT Devices) ,

2条回答
  •  南方客
    南方客 (楼主)
    2021-01-02 04:55

    Actually, you only need to ping the broadcast address of the device's network to make the ICMP ECHO request go to every and each machine on the network. No need to ping separately. On the other hand, some devices don't respond to pings like these as a "security precaution". It's up to you.

    Then, do what the code in the other answer does - parse /proc/net/arp which contains the ARP cache. From that special file in procfs you will find out the MAC addresses of network devices in your network. (Posting this as an answer because I do not have enough reputation yet to add this as a comment to the other answer)

提交回复
热议问题