feat(dhcp): add menuconfig for DHCP discover retransmission interval

This commit is contained in:
Chen Wen
2019-07-24 13:26:38 +08:00
parent f1b9e15bce
commit d64f04bc95
3 changed files with 25 additions and 0 deletions

View File

@ -229,6 +229,13 @@ config LWIP_DHCPS_MAX_STATION_NUM
After this number is exceeded, DHCP server removes of the oldest device After this number is exceeded, DHCP server removes of the oldest device
from it's address pool, without notification. from it's address pool, without notification.
config LWIP_DHCP_DISCOVER_RETRANSMISSION_INTERVAL
int "DHCP discover retransmission interval (milliseconds)"
default 250 # 4 * default retransmission interval
range 250 1000
help
Set time interval of retransmissions of DHCP discover.
endmenu #DHCP endmenu #DHCP
menuconfig LWIP_AUTOIP menuconfig LWIP_AUTOIP

View File

@ -1007,7 +1007,16 @@ dhcp_discover(struct netif *netif)
autoip_start(netif); autoip_start(netif);
} }
#endif /* LWIP_DHCP_AUTOIP_COOP */ #endif /* LWIP_DHCP_AUTOIP_COOP */
#if ESP_DHCP
/**
* Since for embedded devices it's not that hard to miss a discover packet, so lower
* the discover retry backoff time from (2,4,8,16,32,60,60)s to (500m,1,2,4,8,15,15)s.
*/
msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * LWIP_DHCP_DISCOVER_RETRANSMISSION_INTERVAL;
#else
msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * 1000; msecs = (dhcp->tries < 6 ? 1 << dhcp->tries : 60) * 1000;
#endif
dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS; dhcp->request_timeout = (msecs + DHCP_FINE_TIMER_MSECS - 1) / DHCP_FINE_TIMER_MSECS;
LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs)); LWIP_DEBUGF(DHCP_DEBUG | LWIP_DBG_TRACE | LWIP_DBG_STATE, ("dhcp_discover(): set request timeout %"U16_F" msecs\n", msecs));
return result; return result;

View File

@ -54,6 +54,7 @@
#define ESP_LWIP 1 #define ESP_LWIP 1
#define ESP_IP4_ATON 1 #define ESP_IP4_ATON 1
#define ESP_DHCP 1
#ifdef CONFIG_ESP_DNS #ifdef CONFIG_ESP_DNS
#define ESP_DNS 1 #define ESP_DNS 1
@ -720,6 +721,14 @@ size_t memp_malloc_get_size(size_t type);
* (up to the maximum limit defined here). * (up to the maximum limit defined here).
*/ */
#define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS #define LWIP_DHCP_MAX_DNS_SERVERS DNS_MAX_SERVERS
/**
* LWIP_DHCP_DISCOVER_RETRANSMISSION_INTERVAL: DHCP discover retry backoff time.
* (default is 250, a conservative default, the maximum is 1000.)
* Since for embedded devices it's not that hard to miss a discover packet, so
* it is necessary to reduce the discovery retry backoff time.
*/
#define LWIP_DHCP_DISCOVER_RETRANSMISSION_INTERVAL CONFIG_LWIP_DHCP_DISCOVER_RETRANSMISSION_INTERVAL
/** /**
* @} * @}
*/ */