Mbed6 and DHCP lease renewals don't seem to work

We’ve used MBed5 for some years and brought up out Ethernet connection with DHCP. Basically the below code. I’ve removed the error handling to keep it short.

    EthInterface * eth = EthInterface::get_default_instance();
    eth->set_dhcp( true );
    eth->connect();

On MBed5 this worked ok and we always got the IP address data. DHCP renewals also seemed to work ok. Now we’ve finally migrated to MBed6 and while the DHCP code always gets the interface up and running it doesn’t seem to renew correctly. It took ages for us to notice as the lease time was two weeks at the office where devices were tested. After the lease has expired network operations seem to give NSAPI_ERROR_NO_CONNECTION errors.

Are we supposed to manually handle the DHCP renewals with MBed6? Or should renewals work automatically? According to the standards a DHCP client should try to renew after half the lease time has passed, so there has been ample time to renew. I don’t really see any way to check the DHCP data nor manually do the renewing, unless we want to drop down to the low level LWIP code and do an own Ethernet interface.

2 Likes

Hi chakie,

I’ve also observed that DHCP clients fail to renew their leases properly. See my recent post for more information: Odd DHCP Client Behavior Using EthernetInterface - Mbed OS / Bugs - Arm Mbed OS support forum.

Based on what I’ve seen and on your post, it does seem to be an issue with one of Mbed’s libraries. Have you had any luck correcting this behavior since your post?

Sorry I couldn’t be of any actual assistance, but I thought it would be useful to get all of this information in one place.

In Mbed6.17.0, DHCP renew is working.
After enable lwip debug & let system sleep over 1 hour, DHCP renew was invoking. (i.e: renew time or rebind time depend on DHCP server)
Snippet of log for reference:

[Tue Jun 20 09:40:08.452 2023] dhcp_coarse_tmr()
[Tue Jun 20 09:40:08.452 2023] dhcp->t1_renew_time:60

[Tue Jun 20 10:40:14.351 2023] dhcp_renew: RENEWING
[Tue Jun 20 10:40:14.351 2023] dhcp_renew(): set request timeout 2000 msecs

Snippet of sample code:

> NetworkInterface *network_interface = NetworkInterface::get_default_instance();
rc = network_interface->connect();
if(rc == 0) {
    printf("\n\rConnected to Network successfully\r\n");
} else {
    printf("\n\rConnection to Network Failed %d! Exiting application....\r\n", rc);
    return 0;
}

SocketAddress a;
network_interface->get_ip_address(&a);