anilgkts / arduino

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

DHCP infinite lease + ethernet.maintain() #985

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
Ethernet shield + DHCP. If the DHCP server gives you lease with "infinite"  
lease time (0xFFFFFFFF) the method calculating rebind time (_dhcpT2 = _dhcpT1 
<< 1;) gives you wrong time forcing Ethernet.maintain() to rebind every time 
it's called.

What is the expected output? What do you see instead?
PROBLEM ROW #104:_dhcpT2 = _dhcpT1 << 1;
I'm expecting positive integer but I'm seeing -2. Calculation method gives 
2147483647 for renew timer(_dhcpT1) and -2 for rebind timer(_dhcpT2). 
Ethernet.maintain() sees this like it would be always 2 seconds "late" and 
forces it to rebind. This creates huge amount of traffic inside LAN as DHCP 
uses broadcast messages for request etc.

If I'm correct the calculation method should be something else for example the 
one I used in my scenario (see below).

What version of the Arduino software are you using? On what operating
system?  Which Arduino board are you using?
IDE 1.0.1, Windows 7 SP1, Arduino Mega2560+ Ethernet shield with SD

Please provide any additional information below.
In my own scenario I fixed the problem by changing the row used to calculate 
rebind time to not use bitwise left shift. Instead the row is now like this: 
"_dhcpT2 = _dhcpLeaseTime*7/8;".

Original issue reported on code.google.com by mik...@gmail.com on 16 Jul 2012 at 1:09

GoogleCodeExporter commented 9 years ago
Adrian, can you look into this?  

Original comment by dmel...@gmail.com on 19 Jul 2012 at 3:00

GoogleCodeExporter commented 9 years ago
https://github.com/arduino/Arduino/pull/2601

Original comment by nchave...@gmail.com on 4 Feb 2015 at 1:27

GoogleCodeExporter commented 9 years ago
A more complete fix based on 
https://github.com/arduino/Arduino/pull/2601

is here:
https://github.com/arduino/Arduino/pull/3287

please follow up there.

Original comment by c.mag...@arduino.cc on 4 Jun 2015 at 3:29