Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
Rapid DHCP: Or, how do Macs get on the network so fast? (2011) (cafbit.com)
198 points by allenleee on July 26, 2017 | hide | past | favorite | 108 comments


This is an article from 2011, 6 years ago. Has there been any progress on implementing RFC 4436 on Linux in general or Android specifically in the interim?

http://www.ietf.org/rfc/rfc4436.txt


No, but it is still quite fast.

On chromeOS network bring up is extremely fast. We are talking 1-3 seconds from cold boot to your emails have been synchronized.

My Ubuntu is almost as fast, if we subtract the 4 seconds the ugly bios screen adds.

No idea about Android, but did you read the end of the article?


Are you saying that 1-3 seconds includes boot time? Like, time form pressing the power button to email syncing?


Edit: yes, but it depends very much on hardware. My old arm chromebook was very fast to boot but the Intel ones seem to boot slower:

https://youtu.be/rsTyiMTYq9M


It's better but definitely not "extremely fast".

The mac from 6 years ago does it in 300ms which is still 3-10x faster than what you suggest is the norm for your setup.

The difference between 300ms and 3 seconds is the tipping point for being annoyed when you cannot connect to the first page you visit.


You misunderstood my numbers :)

Search "chromebook boot time" on YouTube. Checkout the comparisons between a $200 chromebook from 2013 and a $2000 MBP...


ChromeOS is not a real OS. It's an embedded appliance/cloud OS as a gateway to the web and Google services. Anyone can make a machine boot fast if it has nothing to load.


Just because it's not bloated doesn't make it any less of an OS then any other minimal Linux installation, it is itself built on the Linux kernel - it is just highly optimised for a very select set of software and hardware requirements.


It's gentoo based. Just because its DE is basically just chrome doesn't make it any less of an OS. Hell, you can even run another OS in a chroot on it.

You'll get similar performance if you put your OS on an SSD, and select services that minimize your boot time.


Can I join it to my AD infrastructure? Can I access network shares (NFS/SMB) ? I could list off a million "Can I...?" questions but the fact remains that it's a Google Chrome appliance. The detail that hidden underneath is a Linux/Gentoo base is irrelevant. This is no different than your PS4 which runs Orbis, a stripped down OS based on FreeBSD. It's not a real OS targeted for users who want a complete OS computing experience. It's an appliance with a single purpose built upon parts of an existing OS.


My NetworkManager still takes multiple seconds to connect to wifi, and that's definitely the same pathetic DHCP behavior. wpa_supplicant is super fast. Modern Ubuntu (17.04) is still stuck in this ancient, lethargic world.


TL;DR: ChromeOS uses this rfc, Android, dhcpcd, isc-dhcp-client doesn't (Note: I have no clue about systemd-networkd)

Ok, so the article covers ARP discover, but actually it's not the only issue.

The author mentions a 10s timeout because his DHCP is not authoritative. But in my opinion, that's not the real problem (though I admit it is better if his setup has it). The author's device should not ask for an unrelated IP in the first place. If it doesn't do so, and asks for the correct IP address, you save 1.5 RTT. This is because at the time of that article, dhcpcd had one lease file per interface.

In my opinion, between RFC4436, and per-ssid interface, having a per-ssid lease makes a MUCH bigger user-facing change than RFC4436. RFC4436 worst 1-percent gain is 1s, per-ssid lease worst 1-percent is gain 10s.

I suggested a fix to dhcpcd's author: have one lease file per { interface + ssid }. This has been merged in dhcpcd in February 2015 (sorry, it looks like mailing-list archives is down). So the bad feeling of > 10s connection time should be gone when using dhcpcd.

I've also suggested him to implement rfc4436, but got no answer at the time. Considering the friendly answer I had for my previous patch, I guess it just got lost. As far as I can tell, as of today, mainline dhcpcd still doesn't implement it.

ChromeOS uses a patched dhcpcd, which includes RFC4436: https://chromium-review.googlesource.com/c/22643/ https://chromium-review.googlesource.com/c/23906/

isc-dhcp-client, aka dhclient, doesn't seem to include either the ssid-based lease, or the RFC4436.

Android used to use dhcpcd until Android 6, but a very old version. I published an updated version of dhcpcd for rooted Android: https://forum.xda-developers.com/android/software/wifi-dhcp-...

I pushed to Android's gerrit the changes that were merged to dhcpcd (it had to be rewritten, because Android's dhcpcd is really old).

The result of this, is that for Android 6, Google decided to rewrite their own DHCP implementation (mostly because the integration with dhcpcd made a state machine more complex than rewriting a DHCP client). This led to a java dhcp client which doesn't save leases, had flaws which could make an android device reboot, and which doesn't support RFC4436. At least, there is no longer any authoritative problem, since the device will always send a DISCOVER. As far as I know, this still is the current status of Android.

Android Things, which is basically Android... Well, they are using yet another google-written dhcp client. ( https://android.googlesource.com/platform/system/connectivit... ) This supports leases (I couldn't tell based on the sources whether it was interface or ssid-based), but no RFC4436.


Fantastic, thanks for such a detailed response! My meager web searching skills did not turn up any of this.

And of course, thanks for all this work, it's quite impressive.


Awesome work!

Also, You not working for Google just proves their headhunting and recruitment process is not worth shit


Interesting nugget of information here: > Thanks to Steinar H. Gunderson for pointing out in the comments that the DHCP server on my test network was incorrectly configured. Since I was using a mostly "out of the box" dhcpd configuration from Ubunbtu Linux, it wasn't set up to be authoritative by default, so it wasn't promptly sending NAKs in response to the Galaxy Tab's requests for an old IP address. After fixing the problem on the DHCP server, the Galaxy Tab's DHCP handshake happens quite a bit faster (although still 85 times slower than the Mac).

Set authoritative on your dhcpd.conf! I checked, fortunately mine is set :)


> Set authoritative on your dhcpd.conf!

Done: https://github.com/majewsky/system-configuration/commit/f917... :)

Will see if it helps once I get home.


An instruction like that is why I don't use Linux as a desktop!


> An instruction like that is why I don't use Linux as a desktop!

This has nothing to do with the linux desktop - this is a misconfiguration of the dhcp server, which would affect all clients. The mac circumvented the issue because it sends out information of all previous networks (which is a security issue, btw - I'd rather not want my laptop to push out all of my recent networks' information to anybody).

Also, this guy is running his own ISC dhcpd server to have more control over the network and to learn more about networking in general. This is not a professional network admin/dev - of course he doesn't do all of it right, but if he'd read the manual, he would've enabled it. Seriously, even in default configurations the option is marked as 'if this is the only DHCP server in the network you'll want to enable this' or something along the lines of that.

So we're not speaking about an out-of-the-box ready-to-roll router - we're talking about a guy who's running a server with Ubuntu on it to provide leases to his network.

Besides - the same would've happened if a windows user were to use Microsoft's DHCP server, which is non-authoritative by default as well. It's a good practice that a DHCP server on default configuration doesn't assume to have the authority - since, well, since the configuration has not been touched.


> The mac circumvented the issue because it sends out information of all previous networks ... I'd rather not want my laptop to push out all of my recent networks' information to anybody

It's some information about the last few _wired_ networks you've connected to, to any of those networks, that the owners of those networks already have. If you have a wifi you already know which network you're on, and there's no sense in asking about addresses you haven't seen with that SSID+key.

There certainly appears to be a privacy issue if you're connecting to a lot of public ethernets and those sites (can) collude, however if those sites can and do work together, they can unmask you anyway.

If they don't yet collude (but are willing) and you don't use random MAC addresses, then there may be another privacy issue where they can use the MAC address you leak to discover each-other, but I'm unconvinced even Google has the resources to do this.


> An instruction like that is why I don't use Linux as a desktop!

How often do you find yourself needing to run a DHCP daemon on your desktop, Linux or otherwise?

Some might say that Windows' DHCP setup being authoritative by default is one of the reasons they prefer Linux on the server. It is not the safest default: sending NAKs when you shouldn't could cause significant disruption, not sending NAKs when you could correctly do so does nothing worse than delaying new connections by a few seconds.


I'm a bit disappointed that you're downvoted to grey right now because editing obscure config files and entering esoteric terminal commands is exactly why Linux is so difficult for the average user, and it's never going to improve if those who're already comfortable with it ignore the problem.


That's all fine and dandy for the desktop case.

But its a dhcp server, network admins would be expected to touch config files, and the interface for a DHCP server really can't be much worse than the GUI version that microsoft supplies!

but digressions, to say "this is why I won't use a linux desktop" in response to a server-specific use-case, is at best antagonistic!


Pfsense does a great job offering a GUI for how configuring DHCP should work.


The used netgear router a friend gave me, does a fine job of getting my devices ip addresses on time without me touching the config.


In fairness, it is a sensible default for a dedicated hardware router, and not so much for a software DHCP server.


It's still a fair point, even if a little "off topic' wrt parent and still perfectly on topic wrt this submission.


Well if you're an average user, I might suggest not running your own DHCP server?

Seriously, I understand where you're coming from, but you're blathering needlessly about an issue that is a) not really a contentious one, and b) completely irrelevant to the discussion.


The windows equivalent to make such a change would be some kind of hidden module for that scm. Exe or whatever that obscure config tool is called.


In this specific case, the DHCP server configuration under Windows makes it abundantly clear though that you need to make your DHCP server authoritative by adding a warning icon and presenting a warning dialog when it's not running in authoritative mode.

Making it authoritative is then to just press a button in that dialog.

Yes. You have to know that you have to open the GUI for DHCP server configuration in order to configure the DHCP server, but that's really all you need to know to prevent the issue described here.

isc-dhcpd that's often used under linux doesn't even warn to syslog when it's not authoritative. All indication for doing so is given in the sample config file using

    # network, the authoritative directive should be uncommented.
    #authoritative;
It doesn't however explain to you why you should or shouldn't do that and, again, it starts up just fine without this uncommented.

Case in point: Back when I was learning about all of this my Windows-based DHCP servers were all authoritative, whereas none of my Linux or FreeBSD based DHCP servers were.


> the DHCP server configuration under Windows

Though for the opening to the current discussion that is a moot point - this is not relevant to either OS on the desktop.


Neither Windows nor Linux desktops buck the trends (with respect to documentation and user expectations) that their server counterparts follow.


And dump truck gearing patterns are kind of similar to manual transmission car patterns. Complaints about the difficulty of driving a dump truck remains irrelevant to cars.


"Kind of similar" is very different from "arranged by the same people following the same processes with many packages being identical". We're talking about comparing transmissions from the same manufacturers with a lot of shared parts.


From when and which distro is that default config file? I remember having a text next to it saying 'Enable this, if this is the only DHCP server on this network' or something along the lines of that with a pointer to the documentation for an explanation.


The current isc-dhcp-server package in Debian testing has that comment, although there’s a line missing…

  # If this DHCP server is the official DHCP server for the local
  # network, the authoritative directive should be uncommented.
From that, it’s a little more clear that you should be uncommenting that option.


It would still be an easier to navigate GUI tool, possibly with tooltips and online help along the way, than manually editing /etc or /usr/share files.


People say things like this, but if you're not familiar with it the Windows networking GUI configuration is still quite a mess. Especially since Win8 there are now two different GUIs for it, with different feature sets.

There are still some configuration items that have to be set in the registry or through Powershell (wmi and so on). The registry is much worse than editing files in /etc/ because you can't back it up, revision control it, or put comments in.

Random googling reveals people having surprisingly similar problems with the Windows DHCP server: https://community.spiceworks.com/topic/332253-cannot-backup-...


I am familiar with Windows since version 3.0 and was introduced to UNIX via Xenix.

As for GNU/Linux, I know it since Slackware 2.0.


I thought you'd be familiar with it; I was talking about third parties who might not be familiar with either.


If they aren't familiar with either, the amount of documentation in Technet and wizards help, is much better than searching man pages.

Leaving aside the fact that the variation among Windows versions is quite small versus the GNU/Linux distribution fragmentation.


In practice, it is still easier to grep and edit config files in /etc (often commented), than to look for the needle in a haystack like gpedit, where, if localized, you don't even know exact term you are looking for.


If you want a needle in a haystack, try finding out how to adjust network provider, binding and connection orders in the Windows GUI.


Not really a fair comparison. For editing config files I often have to go to man pages to find out what the syntax is for the things I want (and sometimes, where to find the file). Especially if editing bash/zsh.rc, there is no hope of getting anything done without Google unless you already know how to do it.

Conversely, most group policies I have ever needed were pointed out, including where to find them, after one web search, and their use is extensively documented in the config editor.


> here is no hope of getting anything done without Google

> were pointed out, including where to find them, after one web search,

Well, if you are doing that one web search, it doesn't matter whether the named key is for gui or text config. Except for that localization issue, if you find English string, it won't help you with localized one.

Then there is the issue of the GP items themselves: many times you don't know whether to choose enable or disable, because double negatives FTW.


Incorrect. Windows has a dedicated configuration tool for DHCP.


I say the same thing about the space shuttle, it should have one button "go to space".


It's not even a out the desktop. The comment is completely off base. Downvoted.


OP is downvoted because a misconfigured DHCP server has nothing to do with running Linux. What if the DHCP server was running Windows?


You should try disabling mouse acceleration using your mouse, that's even better. Setting server stuff is one thing, but it's ridiculous that using a mouse is not considered important enough for simple users to be able to customize.


This is nice, but kind of useless when waking up from deeper sleep states, which prevent the password dialog from receiving keystrokes for a good five seconds anyway (despite teasing a blinking cursor).


That blinking cursor is especially sneaky. When they just loaded up what is effectively a screenshot while everything loaded, that could've been forgiven (better than a blank screen I suppose). But animating it so that it LOOKS like it's working ...


Thank you both. I've been mystified by this behavior for years. How do I tell when it becomes responsive ? Without trying to type of course.


Man, I thought that was just something buggy on mine. That's standard behavior?!?!


I remember this feature used to cause a lot of problems with random IP conflicts, but I haven't had an IP conflict like that in years, so it seems they've made it a lot more robust. Or are routers/DHCP servers just less broken these days (I guess since Apple's market share has forced them to)?



It does. I had to deal with it many times working at helpdesk.


I think Apple "updated" the network stack with 10.10 (maybe 10.10.1) and then had so many issues with IP conflicts with the new implementation that they actually backtracked and reverted to the original. The memory is hazy but if you're interested I can do a little digging and see if I can find some other info.


It still happens. I run Ubuntu on a MBP (dual boot) and some networks are fucking great. No problems whatsoever. Others I get booted off more frequently the more people enter the cafe. I dug into the problem a while back and figured out it was this shitty behaviour by Apple that Ubuntu hadn't fixed.


It’s not a Mac hardware behavior, it’s in macOS - the fact that you’re seeing bad things in Ubuntu has nothing to do with Apple here.


The joke is, Macbooks are dead slow on WPA2-Enterprise networks once you go with certificate-based logins. At home, I'm in the network often enough faster than 1s - at work, up to two minutes sometimes.

I guess that modern macbooks keep the connection alive on the PHY level while asleep... they do have that "backup/sync while you sleep" feature, so quite possible that the chip handling this feature only speaks "normal" WPA2, keeps the connection alive and then after resuming the OS only has to re-check the IP address and does not have to do the full PHY handshake first...


If you’re seeing 2 minute connection times that’s on your network - probably the RADIUS server, not macOS. There are tons of places using macs with WPA2 and certs that don’t have any connection lag - including my employer and many of my customers.


Rapid driving: how ignoring red lights makes the iCar so fast.


Except that this isn't ignoring red lights, it's taking a government approved shortcut that no-one else has done the research to know about (to extend your metaphor). This approach is standards approved:

http://www.ietf.org/rfc/rfc4436.txt


Still PROPOSED STANDARD, eleven years on. Though that says as much about the IETF as that particular RFC.


That's just IETF terminology. Number assignment is one of the last things to happen - so if it has a number, it's done.


As I was reading, I was mentally composing a convoluted reply. Yours said the same thing, much better, and bonus coffee over my screen! well done :)


> bonus coffee over my screen

Why did you pour coffee on your screen? That's really quite strange behaviour.


HN isn't in the mood for levity today....


maybe he was laughing too hard and spit out the coffee that was in the person's mouth


That is indeed what happened. Unfortunately, HN has become so fucking dour, and mindless downvoting is quickly replacing interesting discourse. This is no longer a place for some occasional lighthearted discourse.


Previous comments are interesting: https://news.ycombinator.com/item?id=2755461


They also end up with other host names in the terminal from time to time.


The hostname has to do with multicast DNS / "Bonjour", not DHCP or IP address assignment.


That's why I configure my hostname permanently. Using scutil if memory serves.


I'm more worried about the network problems i have with my mac, it disconnects sometimes out of the blue, if i reconnect or enable/disable vpn it works again, very weird behaviour.


Honestly, my Lenovo using Ubuntu gets on the network just as fast as my Mac used to, it's impressive coming back to Linux after 5 years.


> I assume the Mac would know to begin the DHCP discovery phase, instead of sending blind requests for a former IP address...

I wonder if that is my problem. Often, my Mac won't connect to my mobile hotspot. I open the lid, it starts attempting to connect to the hotspot and just sits. Connecting. Forever. I can turn off WiFi, turn off the hotspot, and sometimes even reboot both my phone and my laptop and still be unable to connect.

I recently figured out that if this not-connecting happens, I can disable wifi, disable hotspot, turn on WiFi and select my not-on hotspot to connect to. A couple of seconds later, it fails and asks to run network diagnostics. I cancel, disable wifi, turn back on the hotspot, turn back on wifi and, presto, it connects.

I figured there was some caching going on and that I am effectively invalidating the cache. Maybe this is what the op is talking about here.


It sounds more like your hotspot is janky - if a Mac doesn’t get a DHCP response it will still connect to the wifi network using and autoconf address. There is no dhcp related scenario that causes it to not connect to the network at all.


Pretty neat!

Previously discussed here: https://news.ycombinator.com/item?id=2755461


Interestingly, we use Cisco's Meraki APs at work. The WiFi is pretty solid most of the time, but macs are the only machines that suffer occasional dropouts and then DHCP stops working till you cycle the n/w adapter. (though iphones never seem to have this issue).


It depends on the router too. My arch Linux connects almost instantly to my Ubiquiti WiFi AP on wake from sleep, but takes seconds to connect to my phone AP.


Can someone please port this to the linux kernel, or at least archlinux / ubuntu????


Does anybody know if there is a setting to disable this ?


My 5-year-old MBP doesn't seem to connect faster than anything else.


Needs a (2011) in the title.


Could have been titled: How do Apple devices wreak havoc on home networks.

When my kid comes home with his iPhone there is a better than even chance that my home network will go out to lunch. Router reboot time.

Never happens with Windows or Android devices coming and going.


Let’s be clear: this is an issue with your home network. If it’s not able to cope with a known and documented by RFC scheme for detecting network reattachment, then it’s broken.

Unfortunately, most domestic networking equipment is in my experience awful.


If it's "router reboot time" something is seriously messed up with your network.

If that's an exaggeration and the iPhone is just booting other random stuff off the network, have you tried just increasing the DHCP lease time? On a home network that just sees the same devices day in and out you could safely set it to several days long.


Really, if your router's uptime isn't measured in months, you're doing it wrong. Probably by running the software it came with, instead of replacing it with an actually-maintained Linux distribution like OpenWRT or LEDE.

There are really very few routers out there anymore that have so little memory they can't be robust and run modern software. Flaky hardware is quite a bit more rare than some users seem to think. The problem is mostly that the hardware vendors have very little incentive to continue polishing the software after the device is shipping, because by the time you get fed up with the consequences of their crap software there will be a new model to sell you. They love that "buy a new router" is such a common troubleshooting step.


Standard Netgear wifi router with standard config. As I said, it's fine except when Apple devices come onto the network.


I'd suggest that it warrants more investigation than just writing it off as Apple trashes networks. Hybrid Apple/Windows households have been common for the larger part of 2 decades now and certainly others do not experience the same issues guaranteed.

So rather, the title would be Apple devices cause issues on your home network. Or more accurately, something on your home network works in an unintended fashion when your son's iPhone connects.


Odds are high that GP's router is configured to give out addresses sequentially, with a fairly short lease and the wireless ap is configured to disallow communication between wireless hosts. I'm thinking the odds they'll change the configuration vs yell about apple devices aren't so high.


It's not just his iPhone. It's iPads, any Apple device that has been "away" for a while and then comes back.

TFA describes how Apple is taking shortcuts in the DHCP negotiation. I blame them for assuming that the previous IP address assigned to the device will still be available.


Well, while this may be the case, I'm not quite sure how Apple device assuming same IP as before somehow triggers the disconnect from the rest. It may be part of the steps required to reproduce, but hundreds of other consumer routers with standard configuration handle such a scenario without booting the rest of the attached clients, which is why I woudl rephrase it as unexpected behavior from the router.

And Apple isn't taking a shortcut or a hack here, it's a known scheme: http://www.ietf.org/rfc/rfc4436.txt It's not so much doing anything special as crafting a special call to the network it tries to connect to. It's more of a shortcut to know if the Mac should go to the DHCP phase rather than cheating its way on to the network.


Still weird. My Netgear R7000 doesn't have a problem with Apple devices.

It used to have an open root exploit (patched), but it never had an Apple problem. :-)


This is a known issue on iOS 8.0-8.1. Lookup 'WiFried'.


This is very interesting! I just replied to another commentator mentioning issues apple had with 10.10.1 - 10.10.4 when they updated some aspect of the network stack. both the macOS and iOS issues were apparently caused by the same change. More info here: https://www.macrumors.com/2015/05/26/apple-discoveryd-replac...


If you have a linux device on the network you could have that be the dhcp server and control lease times there, dhcp and dns on a linux machine(even an old laptop) are way better than all but the top tier netgear routers. If your windows machine is always on you could even run it in a vm.

https://askubuntu.com/questions/248355/can-i-run-a-dhcp-serv...

Hope that helps. You'll still be behind the NAT of the netgear router but you'll have better control over QoS.

Here's how you can do it on a debian box

https://wiki.debian.org/DHCP_Server


Buy a new router?


My SO unfortunately has 2 ipones, an ipad and a MBP. There is a confluence of DHCP activity from all these devices that is guaranteed to take my network down.


Unless your DHCP server is an old Commodore 64, that's not the right diagnosis. The ISC DHCP server was rock solid with negligible CPU load with many thousands of clients even 10-15 years ago.

If your network is really having problems, either dig deeper if you want to learn more about networking or buy something like a Google WiFi device if you just want something known to handle much greater loads without issue.


It will kill my fiber to the home network box that my telco installed, and provides DHCP. It isn't a load issue, it is a "the DHCP server died" issue.


That's a bug in that software stack which is unique to however they've designed it. The right thing to do is fix it or replace it rather than blaming the vendor you notice problems with, just as you wouldn't blame a pothole on the first car to hit it.


Our home network has 6+ Apple devices and a pile of other stuff (Smart TVs, DVRs, game consoles, media converters, etc) and it has zero problems whatsoever. Our router is some generic thing by NEC that I bought off the shelf at a big-box retailer because it had the biggest numbers on the box.


DHCP activity from 4 devices will not slow your network, much less take it down.

A DHCP negotiation to get an IP address takes 4 UDP packets, all of them usually below 500 bytes in size.

Not even when you have set the lease time to the theoretical minimum of 1s, this traffic will be at all significant in your network.


It will kill my fiber to the home network box that my telco installed, and provides DHCP. It isn't a load issue, it is a "the DHCP server died" issue


I would be talking to my telco in this instance.


"It" won't. Bugs in DHCP / your router/modem/telco's software will.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: