0

I have been looking for a library that can execute an ARP (Address Resolution Protocol) command to return a list of connected devices on the network. The idea is that it would send the request to the gateway and get a list of MAC addresses of currently connected devices as a sort of "who's home" request.

I have searched around Arduino's libraries and have not found any that specifically perform this type of functionality so I was hoping that maybe it was available in a function within a broader networking library.

The particular networking interface (wifi via ESP8266/ESP32 or Ethernet) does not matter as I have not chosen a specific board for the job yet. I'm interested in any library solution that would allow me to poll the gateway to see which devices are currently online without having to buy a special device like FingBox.

Any recommendations for a library that includes this functionality or an approach that would allow me to send ARP commands over the network?

  • 1
    the way i do this is by looping from 0 to 255 and scanning each local IP. – dandavis Jan 20 at 5:28
  • @dandavis, I feel like that's what the DOS arp command and apps like Fing do as well. I'm thinking something like WiFi.ping() – tshimkus Jan 20 at 17:15
3

ARP isn't generally used the way you described. Per the spec, to resolve an IP address into a MAC address, you broadcast an ARP request for the IP address, and receive a unicast response from the host whose address it is - not a router. It also only resolves a single IP address in one request; it doesn't return the contents of the entire ARP cache.

While you could potentially unicast ARP requests to a router, it's anybody's guess as to whether the router would respond - it's not required to. By spec only the computer who's IP address is being queried should respond - so a router should not unless you've sent it an ARP request for its IP address. You'd also have to send one request for each IP address in the range specified by the LAN's network mask.

You're better off using SNMP, if the router supports it. SNMP can read the router's entire ARP cache with very little overhead (and very few packet exchanges).

The are SNMP implementations for the ESP32 and ESP8266, but they're likely to be difficult to use. Googling will find them for you.

  • Thanks, I'll take a look for SNMP libraries. I thought ARP was the name of the protocol that returns the routing tables as that is the DOS command that returns the list of connected devices. MAC addressing would be most useful as device IPs are generally subject to change. – tshimkus Jan 16 at 4:53
  • It is the name of that command, but what it returns isn't a routing table, it's the MAC address translation table of the computer you run it on, not the router. The protocol is different from the command. – romkey Jan 16 at 4:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.