ARP request using etharp_request() - exception

Posts: 1
Joined: Tue Feb 20, 2018 1:36 am

ARP request using etharp_request() - exception

Postby branchespark » Tue Feb 20, 2018 4:56 pm

Hi - my first post to this fab forum.

This is a question about ARP with the esp8266. I realise this might be a fairly low-level SDK question, so I will explain a little about what I am trying to achieve.

If we assume that I have a known MAC address or IP address, I would like to know if the device in question is connected to the network. The ESP8266 is in STATION mode, so the device might be on WiFi or might be on Ethernet, but that should not matter. I am using an ESP07 and Arduino SDK / platform.

My understanding is that the ARP table in the ESP needs to have sent/received a packet from a device for the MAC and IP pair to be stored. If I do an ARP lookup for a known IP address using etharp_find_addr(STATION_IF, &_ip, &_arp_mac, &_arp_ip), then assuming the device is know, I get the index of the result and the associated MAC address.

Code: Select all

// search ARP records for IP
int8_t result = etharp_find_addr(STATION_IF, &_ip, &_arp_mac, &_arp_ip)

One way I get traffic to be 'seen' is to do a ping to the device (using the in-built ping.h) - it seems to help considerably in the accuracy of the result. In fact, if I do not do a ping, then I get no results most of the time. I think this follows the theory that the ARP table is only populated when traffic to the IP/MAC is seen. All good so far.

However, not all devices respond to a ping (if they are dormant, etc.), so this is not always reliable. Pretty reliable, but not bullet-proof.

Other tools for desktop systems can use ARP to force a request to the network / device to get a reply. Using such tools gives a much more reliable answer to the question "is device with IP address active?". There appears to be some functionality within etharp.h, but if I even think about using them, such as etharp_request(STATION_IF, &_ip), then I get an exception and the ESP reboots.

Code: Select all

// test IP address
ip_addr_t test_ip;
IP4_ADDR(&test_ip, 192,168,0,111);

// do a search
int8_t result = etharp_request(STATION_IF, &test_ip);

I have searched long and hard on this forum and also on Google for answers to this, but have failed dismally. Does anyone have a clue (or even better, some working sample code) that can help me do what I am after?

Many thanks.

Who is online

Users browsing this forum: No registered users and 2 guests