Page 1 of 1
DHCP Gives Up
Posted: Fri Oct 31, 2014 2:49 pm
by kackle123
Is there anyone who knows whether there's anything I can do after the DHCP client "gives up" on an SB70LC? I am using GetDHCPAddress() (v2.5.3) and if the device is powered up without a LAN connection for, say, 5 hours, it will still sit at 0.0.0.0 after it is plugged back into the LAN. I fear a temporary Internet outage will render my device useless in the field.
Is handling my own DHCP instance the answer (using StopDHCP()/StartDHCP())?
Re: DHCP Gives Up
Posted: Fri Oct 31, 2014 4:14 pm
by rnixon
Per the RFC, DHCP has a backoff timer, but it should cycle back and start over. How long are you waiting to get a DHCP address after you plug back in? To avoid unnecessary (that spelling just doesn't look right) network traffic the backoff timer keeps doubling in seconds: 2, 4, 8, 16, 32, etc. Not sure how high it goes, but probably a minute or more.
One thing you could do in your app is to check for Ethernet link before calling GetDhcpAddress(). But for full control you would have to go down the path like in the ChangeIP example that can start, stop, renew, etc.
Re: DHCP Gives Up
Posted: Mon Nov 03, 2014 6:48 am
by kackle123
Thank you for your response. I have only waited a minute or two after plugging it back into the LAN; I'll do more experimenting and report here if there's something still amiss.
To avoid unnecessary (that spelling just doesn't look right)
Hahaha, I do that all the time!
Re: DHCP Gives Up
Posted: Mon Nov 03, 2014 9:28 am
by dciliske
Ok, here's the breakdown on how the DHCP client is going to work: when you call GetDHCPAddress(IfNecessary), it starts sending discovery messages. These have a backoff timer as previously mentioned. The max backoff is something like 64 or 128 seconds, after which it resets the DHCPObject's state and restarts the discovery process.
If you need it to start up immediately after link is regained, you can put a hook in a linkstatus callback that grabs the DHCPObject and restarts. The code to do that looks something like this:
Code: Select all
InterfaceBlock *pifb = GetInterfaceBlock(GetFirstInterface());
if (pifb && pifb->dhcpClient) {
pifb->dhcpClient->RestartDHCP();
}
Obviously, if you're working with a MOD54417 (or any other device with multiple physical interfaces), you'll need to replace the GetFirstInterface() call as appropriate.
-Dan
Re: DHCP Gives Up
Posted: Wed Nov 12, 2014 9:34 am
by kackle123
Thank you! As long as it retries eventually, I'm happy. I just didn't want it to ever be dead in the water.