DHCP Gives Up

Discussion to talk about software related topics only.
Post Reply
kackle123
Posts: 73
Joined: Tue Nov 23, 2010 1:35 pm

DHCP Gives Up

Post 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())?
Last edited by kackle123 on Mon Nov 03, 2014 6:49 am, edited 1 time in total.
rnixon
Posts: 833
Joined: Thu Apr 24, 2008 3:59 pm

Re: DHCP Gives Up

Post 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.
kackle123
Posts: 73
Joined: Tue Nov 23, 2010 1:35 pm

Re: DHCP Gives Up

Post 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!
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: DHCP Gives Up

Post 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
Dan Ciliske
Project Engineer
Netburner, Inc
kackle123
Posts: 73
Joined: Tue Nov 23, 2010 1:35 pm

Re: DHCP Gives Up

Post 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.
Post Reply