Using DHCP w Fallback

Discussion to talk about software related topics only.
Post Reply
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Using DHCP w Fallback

Post by SeeCwriter »

I'm using v3.4.0 with a NANO. I would like to use the "DHCP w Fallback" mode. On the ConfigPage I set IPv4 Mode to "DHCP w Fallback", enter a valid IP address in "StaticAddr" , and set "StaticMask" to 255.255.255.0. I reboot and verify the configuration sticks. Then I unplug the ethernet cable and power-cycle. Using a serial port, I query for the IP address, and it returns 0.0.0.0. When I plug Ethernet back in, the module gets a DHCP address.

How is the fallback mode suppose to work?
User avatar
TomNB
Posts: 541
Joined: Tue May 10, 2016 8:22 am

Re: Using DHCP w Fallback

Post by TomNB »

How long are you waiting for DHCP to fail? DHCP has a timeout period for retries to the server that is not directly related to link. For example, a situation could be that the Ethernet connection is through a managed switch which takes some time, or some other mechanism that where a link is not immediately available due to outside functionality.
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: Using DHCP w Fallback

Post by SeeCwriter »

My module has been running for a couple of hours. Still no IP address.

I use the following statement to get the IP address:

Code: Select all

IPADDR4 ipa = ifBlock->ip4.cur_addr;
I convert ipa to an ascii string and send it.
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using DHCP w Fallback

Post by pbreed »

If there is never a link it will never timeout.
Having an IP address without having any kind of connection to do something with it is kinda pointless
Until it has link long enough for DHCP to timeout it won't ever have an address...

Try plugging it into a ethernet switch/hub not plugged into anything else...

(I'll confrim this still works in 3.x when I go home today)
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using DHCP w Fallback

Post by pbreed »

DHCP times out after 265 seconds.
This can be changed by adjusting two constants in dhcpc.cpp

DEFAULTRETRY
DEFAULTTIMEOUT


Total timeout is (2^(DEFAULTRETRY+1))*DEFAULTIMEOUT

Timeouts are
DEFAULTTIMEOUT, (4)
2* DEFAULTTIMEOUT (8)
4* DEFAULTTIMEOUT (16)
8* DEFAULTTIMEOUT (32)
16* DEFAULTTIMEOUT (64)
32* DEFAULTTIMEOUT (128)

For 252 seconds After DHCP starts cumulative.
(seemed to always be ~265 in my test case, not sure where the missing 13 seconds are)


In future releases these constants will be moved to constants.h where they belong.
If you want a version of constants.h and dhcpc.cpp that have this change, submit a support request.

Paul
User avatar
pbreed
Posts: 1081
Joined: Thu Apr 24, 2008 3:58 pm

Re: Using DHCP w Fallback

Post by pbreed »

The final 128 second timeout is not compliant with the DHCP RFC (RFC says 64 sec max timeout) , so that was fixed in the new version as well.

Paul
SeeCwriter
Posts: 608
Joined: Mon May 12, 2008 10:55 am

Re: Using DHCP w Fallback

Post by SeeCwriter »

Once connected to a network, the fallback works. It falls back in about 4.25 minutes. Close enough for me. Thanks.
Post Reply