Summary: change the DNS server query strategy from sequential
to Round Robin
Project: lwIP - A Lightweight TCP/IP stack
Submitted by: kevingao
Submitted on: Tue 02 Apr 2019 09:18:07 AM UTC
Severity: 3 - Normal
Item Group: Change Request
Assigned to: None
Discussion Lock: Any
Planned Release: None
lwIP version: git head
currently the DNS server query strategy was sequential, it means that lwip
would query the 1st server DNS_MAX_RETRIES times before switching to the
backup one. In the scenario that the main DNS server was unavailable, but the
backup was available, this query stratedy would cusume much time to complete
one successful domain name resolution.
I suggest the DNS query stradegy changed to Round Robin. so the query
procedure was changed from "A->A->A->A->B->B->B->B" to
"A->B->A->B->A->B->A->B", A and B was the main and backup DNS server. In
current settings, this change could make the domain name resolution time from
6s to 1s in above scenario.
The attached file was my modification, pls have a review. There was four
1, change the DNS query strategy from sequential to Round Robin;
2, for one successful DNS query, record the current server index to make the
next DNS query start from this index, this would save more time if many domain
name resolution happened in above case.
3, reset the current server index to the 1st valid one if servers changed.
4, change the initail DNS timeout from 1s to 2s. This could make the 1st
timeout value was [1s, 2s]. If the initial timeout was set to 1s, the actually
timeout value was [0, 1s], this could incur some unnecessary DNS query