njh / EtherCard

EtherCard is an IPv4 driver for the ENC28J60 chip, compatible with Arduino IDE
https://www.aelius.com/njh/ethercard/
GNU General Public License v2.0
1.03k stars 454 forks source link

Wrong Ethernet II destination MAC address. #426

Open ColinDexter opened 2 years ago

ColinDexter commented 2 years ago

If I switch to another network (without turning off the Arduino and ENC28J60) I do get the new IP data from the DHCP. But when I request a website, the destination MAC address of the old DNS server remains in the Ethernet II package instead of the MAC of new DNS server. (verified with Wireshark.)

I can't find where this is set. Apparently this does not reset / set properly when reconnecting to the other network .

globalcitizen commented 2 years ago

This issue is requesting a new feature - automatic ARP cache invalidation when link status changes. It should not be hard to implement however it will take more code and since few people have requested it disabling by default may be a good idea.

ColinDexter commented 2 years ago

Okay, thanks. Only I have no idea how I can do an "automatic ARP cache invalidation". Hopefully this feature can be added in the future.

globalcitizen commented 2 years ago

For the moment, you could for example reinitialize the library if a ping fails, which should have the intended effect.

ColinDexter commented 2 years ago

I already do an ENC28J60::initialize on a disconnect but that doesn't solve the problem.

globalcitizen commented 2 years ago

You could try:

Ultimately if you are unable to reset the ARP cache or resolve via reset I don't think you will get far with this solution as it is not really polished in so far as usability for those sorts of edge use cases and is not receiving a lot of development effort anymore. If you really need rapid plug-and-play between networks without skipping a beat you may be best served by looking toward alternate stacks or hardware.

ColinDexter commented 2 years ago

Sorry, I can program a bit, but this is going to be a little above my level.