Steam in-home streaming is great. I can play graphics/CPU intensive games on my laptop sitting on my couch. Or I can let the (Windows) laptop run Spelunky while playing at my linux desktop. But I had a problems with it: I kept getting intermittent lagging. A little notice would pop up in the bottom left corner informing me of slow network speeds. Both machines are on wifi for network and so I thought putting the laptop on ethernet would solve the issue. Halving the strain on the air waves should do the trick but it made no difference. Which meant that the problem was likely to be on the linux desktop and it’s wireless connection.
Now, the most characteristic thing about the lags was the regularity with which they occured. I didn’t measure them but I started thinking to myself, “It’s gonna come any minute now…” About every two minutes for ten seconds or so. More than enough to get yourself good and killed in Spelunky. I tried network monitoring to see if I could catch whatever process was stealing Steam’s bandwidth but with no luck.
The reason for this is that it wasn’t a process hogging bandwith per se, it was NetworkManager scanning for networks. This happens at some specific interval and tends to cause a drop in bandwidth, something that is most noticeable in live streaming.
Bizarrely, this function is not an option but apparently hardcoded. Or it was in 2009 and nobody has seen fit to say otherwise since. Seeing as I’m at a desktop computer, I really don’t need for NetworkManager to be looking for any other networks than the one it’s on. I suspect most people on laptops don’t have any need of it either, once they’re connected. According to Dan Williams, the developer of NetworkManager, you need background scanning, that is scanning for networks even though you’ve already got a connection, because of a) roaming and b) location-based services.
I look at my 7kg desktop computer, reliant on a wifi connection because it just happens to be on the wrong floor. I’m sorry, old pal, I whisper, But you’re not roaming anywhere. You’re Dunroamin. Except of course, you never actually roamed. Or needed to know about pizza parlors nearby. Because I friggin’ live here and I know where there’s pizza.
Also you can’t have an on-off toggle just because you don’t need background scanning (or would rather do without it) because
Only have one AP at your place and don’t need roaming? That’s nice, but writing software is about making things work smoothly for everybody. Which is what background scanning is all about.
Insisting that one size fits all despite evidence to the contrary is “making things work smoothly for everybody”? Yeah. Huh. Oh well.
The good news is that we don’t really need NetworkManager once it has made a connection. Stopping NetworkManager will cause the GNOME network interface (the wifi/ethernet icon and widget in the upper right corner) to disappear
but the connection that has been made by NetworkManager will persist (altough probably not reconnect should the connection be interrupted). As of November 2015 this appears to no longer be the case: Stopping NetworkManager will kill your connection, as it seems NetworkManager takes dhclient out with it. I have yet to find a way to avoid this. The instructions below are therefore most likely useless. In May of 2017 I went ahead and replaced NetworkManager with systemd-networkd. You can read a walkthrough of that here.
So we can simply tell Startup/SystemD/insert-init-of-choice to stop the service.
sudo stop network-manager
sudo systemctl stop NetworkManager
Or yes, you can find a more minimalistic network application or even connect manually/by script. I may need to look into that once the full significance of being able to play Spelunky on linux hits home.
Finally, I just want address another of Dan Williams’ 2009 gold nuggets:
Oh, bought a Ralink card or a Broadcom? Sorry, better luck next time. This is why you buy hardware that actually works with Linux, so that the Gods of Kernel Wireless will rock your card, and you won’t be stuck with dead-end shit that never gets better.
I recently bought a new RAlink USB wifi dongle and it’s frankly ridiculously hard to pin down what chip any one product has, as the same exact product name can change chip producer from one version to the next. These version numbers are not announced on almost all web shops’ product pages. I spent half a day researching and felt bad once for sending a guy on phone support all the way down to find the physical product and read the version number to me, only to tell him that it was the wrong one. At any rate my nonscientific survey indicated that Ralink and Broadcom chips seemed to have replaced Atheros chips in a lot of products, so it’s not exactly as simple as all that. When I bought my dongle I had to settle for a Ralink product and call it a success, as at least it wasn’t the hated Broadcom of my previous device. So thanks, Dan. You’re a great help.
I am on Debian Jessie, and when I stop NetworkManager I lose my connection. Have you found another workaround for that issue so far?
I tested it on my Fedora machine and I get the same result. The reason is that when asked to shut down, NetworkManager kills dhclient, the service that gives your network device it’s IP address. Either I didn’t test properly or that has changed since I wrote the post – I haven’t used the rechnique much since my Windows machine died.
I tried to see if I could surreptitiously kill off NetworkManager without loosing dhclient but no joy. Also I found no option to ask NM to leave connections in place when stopping. I’m sorry to say this but it appears the only option is to look elsewhere for networking connections.
Hey, for any googlers out there, please check this, originating from a steam thread. This is too important to be on one place on the internet.
“Just stumbled upon this thread but was not willing to switch to a different network manage and I did not want to completely disable the “scanning in background” because that would prevent roaming to different APs to work correctly… long story short:
To work around this with Network Manager you can enter (or select) the BSSID (e.g. hardware address) of your AP in your network settings. With that set the network manager will no longer try to find a better (e.g. stroger) AP for your network and that will stop the spikes.
Find the BSSID (Address) of your ESSID in iwlist output:
$ sudo iwlist wlan0 scan
wlan0 Scan completed :
Cell 01 – Address: 00:11:22:33:44:55
Frequency:2.432 GHz (Channel 5)
Quality=70/70 Signal level=-33 dBm
Bit Rates:1 Mb/s; 2 Mb/s; 5.5 Mb/s; 11 Mb/s; 18 Mb/s
24 Mb/s; 36 Mb/s; 54 Mb/s
Bit Rates:6 Mb/s; 9 Mb/s; 12 Mb/s; 48 Mb/s
For a permanent fix, i.e. a client without this scanning behaviour, I wrote a how-to on replacing networkmanager with systemd’s networkd. See here: https://brokkr.net/2017/05/07/steam-in-home-streaming-lags-with-networkmanager-revisited-replacing-networkmanager-with-systemd-networkd/