arduino-libraries / Ethernet

Ethernet Library for Arduino
http://arduino.cc/
252 stars 253 forks source link

Link local addresses and ARP messages #263

Open henkelis opened 1 month ago

henkelis commented 1 month ago

Hi,

I'm using the Ethernet library on an ESP32S3 with an attached W5500. For my use case I want to be able to connect to another host either via a router and DHCP, or via a switch or direct cable-to-cable. I don't want to use static IP addresses if there is no DHCP (as I may be connecting multiple boards to the host), so I've been looking at adding link local/AUTOIP support to Ethernet.

I've "ported" the AUTOIP code from lwIP and made appropriate changes so it works with Ethernet (I can try to acquire a DHCP address, then switch to acquiring a link local address if DHCP fails). It successfully negotiates a link local address, which I then use for a web socket connection.

To send the ARP probe/response and announcement messages, I've resorted to using port 0 on the W5500 in MACRAW mode - if I open in UDP mode, the messages have the IP header attached rather than being plain ARP. I can see that the W5500 is capable of sending plain ARP messages (it does so after I've configured link local) - does anyone know if there's a way to make it do that without having to resort to MACRAW?

Obviously if anyone wants to test out/use my link local code I can upload it.

Mark.