ilikecats567 / arduino

Automatically exported from code.google.com/p/arduino
Other
0 stars 0 forks source link

Ethernet library should doesn't notice if the physical layer is disconnected #855

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
In the comments from issue 716 it was noted that the Ethernet library doesn't 
automatically renew the lease if the DHCP server is rebooted.  Here are the 
relevant comments from that:

Comment 20 by j3rry5y, Yesterday (28 hours ago)

I applied the patch and added the call to maintain(), but if I power cycle my 
router, all my other devices show up immediately on my router page except for 
Wiznet. Is this expected even with this fix? I can still access the webserver 
running in the arduino.

Comment 21 by jbrazio, Today (10 hours ago)

As I don't have the wiznet ethernet shield I can't test it.. but can I
speculate that if you connect the wiznet into router A serving subnet
192.168.1.0/24 and unplug the network cable (without power cycling the
arduino) and connect it to another router B serving 10.0.0.0/24 that the
ethernet lib's IP address will not be updated into the new range ?

Arduino's ethernet lib should detect the physical link going down and up;
it should try to obtain a new lease from the DHCP server at such physical
events.

--- End of copied comments ---

We'd need to check to see if there's a way to find out from the WizNet chip if 
the physical layer is disconnected, and if there is, it would be useful if 
Ethernet.maintain could check for that and renew the lease if that's happened.

Original issue reported on code.google.com by adrian.m...@gmail.com on 11 Mar 2012 at 2:18

GoogleCodeExporter commented 9 years ago
If there is a way of getting some knowledge about the state of the physical 
layer, implementing a release/renew sequence won't be that hard. 
It can be done with a Ethernet.begin(mac) or a fairly small change of the DHCP 
library.
But we need to find out whether we can detect the link state change at all.

If there isn't a way of detecting the change we have to thing about a 
workaround and I can immediately think of two possible ways.
A) Do a renew once every other loop or something, just in case.
B) Ignore the issue since it wont happen that often. 
For the moment I'm leaning towards plan B but lets check out if the change can 
be detected first.

Original comment by pe...@birchroad.net on 11 Mar 2012 at 4:17

GoogleCodeExporter commented 9 years ago
When your router/dhcpd reboots every client should call back the dhcpd with a 
renew request, if the clients have a previous assigned IP address then it will 
also inform the dhcpd server it's preferred IP address (being the previous 
assigned one). Then the dhcpd will ACK the requested IP address or give a new 
one, either way marking the IP address as used on it's internal tables.

When the router reboots and all the clients do not call back then the dhcpd 
will not be aware of the used IP address by arduino, if we're talking about a 
crappy dhcpd implementation then it could assign that IP address to another 
client causing both clients to loose connectivity.

Original comment by jbrazio on 11 Mar 2012 at 6:29

GoogleCodeExporter commented 9 years ago
I've been reading the W5100 datasheet v1.2.2 and I couldn't find any reference 
to a link status change interrupt.

Original comment by jbrazio on 11 Mar 2012 at 7:56

GoogleCodeExporter commented 9 years ago
I've been looking for a way to work to work out the link status too, and 
according to the link below, there is no register corresponding to the link 
status. Seems like a bit of an oversight to me, especially as there is a link 
LED... 

A reasonable hack would be to connect the link LED to a GPIO pin. Perhaps newer 
shields should link the LED pin on the chip to an Arduino GPIO pin via a solder 
bridge? As the default DHCP timeout is 60 seconds, it means there has to be a 
blocking 60 second delay each time the Arduino tries to get a DHCP address when 
the link is down, which is pretty poor.

http://www.wiznettech.com/Sub_Modules/en/technical/Q_A_View.asp?boardcd=101&SF_A
O=And&PK_NUM=20510&page=1&SF_Part=writer,%20subject,%20contents&SF_KeyWord=link%
20state%20physical&SF_AO=And

Original comment by elija...@mac.com on 3 Jun 2013 at 4:59