4 ms·
In my pretty extensive tests, a long initial lease time is almost always the DHCP server's fault. I didn't see really any time wasted in DHCP REQUEST in my test
by lunixbochs 12y ago
In my pretty extensive tests, a long initial lease time is almost always the DHCP server's fault. I didn't see really any time wasted in DHCP REQUEST in my tests across many devices and operating systems. I think setting your DHCP server to authoritative will usually cause it to do a DHCP NACK in response to a bogus DHCP REQUEST, which prevents any delay there as observed in the article.
I measured lease time when connecting a client as "time from DHCP DISCOVER to DHCP ACK", which I found effectively represents the time between a device connecting to WiFi and being available on the network with an IP address.
With stock dnsmasq, the shortest "new connection" lease time I observed on an uncongested network was around five seconds. Almost all of the time was spent waiting for the DHCP server to respond.
With a modified dnsmasq, the shortest time to lease I observed was 20ms. That was also the longest time to lease on every platform I tested except iOS, which spends about a second trying to ICMP ping the IP address before it takes it. On iOS devices, the time to lease was almost always exactly 1s20ms the first time, and about 20ms on subsequent attempts with the same device.
You can do the same tests yourself by sitting on a wireless network with Wireshark and connecting with a device that has had the network forcibly "forgotten". Mark the first DHCP DISCOVER packet you see, and set the timestamps to relative. Filter the traffic to just show the MAC address of the router and connecting device, then look for the DHCP ACK from the router.
- xorcist 12y agoWish I could upvote more. I wanted to say something like it, plus that most home routers do their DHCP serving with ancient versions of dnsmasq.
- lunixbochs 12y agoIt's still a problem with the latest version of dnsmasq. Look for `if ((count < max) && !option_bool(OPT_NO_PING) && icmp_ping(addr))` in `src/dhcp.c`. Most of your lease acquire time is spent in `icmp_ping()` which actually just sends ARP requests for 3+ seconds then gives up. It's actually not even very reliable when someone is using the IP already, because many devices won't respond to ICMP. There's an option to disable it (OPT_NO_PING) which does improve lease performance with pretty much no downside (as ICMP is a flawed way to check if an address is in use anyway). -5, --no-ping (IPv4 only) By default, the DHCP server will attempt to ensure that an address in not in use before allocating it to a host. It does this by sending an ICMP echo request (aka "ping") to the address in question. If it gets a reply, then the address must already be in use, and another is tried. This flag disables this check. Use with caution. So, if you're configuring dnsmasq, these flags will give you some nice performance gains: dhcp-authoritative no-ping