Troubleshooting slow WiFi on Linux

It's always in the last place you look.
198 readers like this.
Tools for the sysadmin

opensource.com

I'm no stranger to diagnosing hardware problems on Linux systems. Even though most of my professional work over the past few years has involved virtualization, I still enjoy crouching under desks and fumbling around with devices and memory modules. Well, except for the "crouching under desks" part. But none of that means that persistent and mysterious bugs aren't frustrating. I recently faced off against one of those bugs on my Ubuntu 18.04 workstation, which remained unsolved for months.

Here, I'll share my problem and my many attempts to resolve it. Even though you'll probably never encounter my specific issue, the troubleshooting process might be helpful. And besides, you'll get to enjoy feeling smug at how much time and effort I wasted following useless leads.

It all began when I noticed network latency and download speeds on my workstation were awful. Well, let me back up. It really began a few years ago when I moved and couldn't be bothered to run cable through my new home to all the rooms that would need connectivity. Instead, I bought a bunch of USB WiFi adapters. The performance wasn't as good as Ethernet, but it was good enough—usually between 2Mbps and 4Mbps between machines.

But then one gloomy winter day, my workstation connection deteriorated. As far as I could tell, it seemed to have hit around the time I briefly put my interface into monitor mode to experiment with network sniffing. Latency was now high, I was often lucky to get 300kbps download speeds, and ifconfig was reporting high numbers of transfer errors. It was so bad, I would regularly download larger internet-based packages to a laptop and transfer them to my workstation using a USB. What century is this?

Eliminating the impossible

Could my USB WiFi interface have degraded over time? No problem: there are probably 10 of them—all different models—scattered through the house. So I tried two or three others, but with similarly depressing results.

While a long shot, it couldn't hurt to check my ISP service connection. Multiple DSL speed test websites all confirmed that my provider was giving me everything they said they would. Perhaps the WiFi router provided by my ISP was to blame. Nope. The laptop was getting good connectivity to the same router even while sitting right next to the workstation.

Was I sure it was a WiFi problem? Perhaps it was a general networking issue. To find out, I combined two old CAT5 cables and ran them from the router, under the dining room table, through the living room, across a hall, and into my office. Instant connection happiness: 25Mbps downloads. But I sensed that, over the long term, the wife might not respond well to the cable in the dining room. Not a solution, but it did confirm that the issue was WiFi-specific.

Did my brief switch to monitor mode somehow mess with some obscure WPA_supplicant setting? (WPA_supplicant is a package for managing client connections using the WPA, WiFi Protected Access, protocol.) The quickest way to find out for sure was to boot my workstation to a live USB Ubuntu session to get a pristine, out-of-the-box operating system experience. The result? Even using the live session, I was still getting poor connectivity. Which pretty much ruled out software configurations, didn't it?

So what's left? In desperation, I emailed an old friend who gave me some logical suggestions, including checking dmesg for errors, lsmod for conflicting drivers, and the firmware versions of my wireless chipsets. Given how much progress has been made over the past few years incorporating such a wide range of WiFi chipsets into the Linux kernel—and how complicated it could be to dive down the firmware version rabbit hole—I skipped that last item and hoped for the best.

Finally, my friend advised me to purge wpa_supplicant and reinstall it. That "reinstall" bit could get tricky, considering that I'd have no WiFi connection at that stage. But it's doable. So I did it and, indeed, my connection improved… for a week or so. Then it was back to the dark ages of 250kbps.

Desperate, I tried uninstalling NetworkManager and replacing it with the Wicd package. Two interesting observations about that:

  • Did you know that uninstalling NetworkManager in GNOME 3 automatically causes gnome-control-center to uninstall as well? That's considered a feature, by the way, not a bug.
  • And did you know why Wicd isn't the default WiFi tool used with any Linux distros with which I'm familiar? I'm now pretty sure that—while it can be a life-saver in some edge scenarios—it's because the module is more likely to introduce lots of annoying buggy behavior.

New hardware, same old problem

So there things stood for a few uncomfortable weeks until, for mostly unrelated reasons, I decided to build a replacement workstation.

Happily, my connection to the new machine was robust. Until it wasn't.

Within a few days, I was back to watching the internet through a thick fog. Speed tests showed me I was getting latency in the range of 100ms, and transfer speeds were dead slow. What was going on? The only piece of hardware that both machines shared was the power supply, and there's no way that was a factor here.

In fact, the workstation upgrade made things simpler for me, because it ruled out just about everything. And, as Sherlock Holmes famously said, when you've ruled out the impossible, what's left is the probable.

So what was left? There was really only one thing, but it took all those dead ends and failures to get me to it. Because my workstation lives under my desk, and because WiFi reception can suffer behind too many physical barriers, I wanted to lift my USB WiFi adapter as high as I could. To do that, I connected it to my workstation through a three-foot USB extender and sat it on the surface of my desk. On a hunch, I pulled the extender and plugged the adapter directly into one of the integrated USB ports.

Instant success. Perhaps using the extender was a bad idea from the start or, more likely, it degraded over time, but everything was humming along happily now. I'll bet you didn't guess that ending. I certainly didn't.

Tags
David Clinton
DAVID CLINTON is a system administrator, teacher, and writer. He has administered, written about, and created training material for many important technology subjects including Linux systems, cloud computing (AWS in particular), and container technologies like Docker.

7 Comments

I had a problem with flaky usb wifi unit. My wife's WIndows7 (sigh..) desktop computer would sometimes FAIL to shutdown and would just "hang". The usb wifi was plugged into an extender cable to get it "up" (Sound familiar??) After trying this and that, I plugged the usb wifi unit directly into the back of the PC and everything worked perfectly. No more "hangs" on shutdown and other weird stuff.

Yup. That does sound familiar. I think part of the problem is that there are a lot of cheap USB components out there and there's no easy way to tell them apart. Not to mention that we leave them around the house unlabelled for way too long. :)

In reply to by Ralph Peters (not verified)

What a great article, David! We "software types" are so conditioned to blame the code (and, dare I say, for some valid reasons) that when we encounter someone who suspects the hardware, we're ready to accuse them of Not Understanding Things.

Personally, I've dealt with flakey cables a number of times (though not yet a USB problem). I even had an 8-port switch that had a flakey port. I never determined whether that was just some intermittent physical problem (like a bent connector) or something electrical, because I spent so long diagnosing it that when I finally determined the problem, I hurled the entire unit into the nearest dumpster. Probably not the right thing to do, but it sure did feel good.

My own introduction to Linux (way back in Ubuntu 7.10 times) was nearly derailed by an unreliable port on a cheap, unmanaged switch. I just couldn't get all of my thin clients booting from an LTSP server and I was just about ready to throw the whole Linux thing into a dumpster. That WOULD have been the wrong thing to do! :)

In reply to by clhermansen

I was troubled with my wifi which sometimes was great, sometimes miserable in the same spot on my desk. Until I noticed: the connection was bad only when I hooked up my laptop to an external monitor – and naturally closed the lid. Opening the laptop-lid instantly solved all my wifi issues, probably because of the antenna…

Good article!
I have a similar issue with a wireless mouse I use at a client's office. After about half an hour the mouse loses connectivity and I have to switch it on and off and move it newer the base unit for a few mins before it starts working again. Very annoying.
Ironically, my client never has this problem as he is left handed unlike me and the mouse is thus s foot or two closer to the base unit so always in range.
Certainly the rf unit was not designed very well unless it was by a left hander too ?

"uninstalling NetworkManager in GNOME 3 automatically causes gnome-control-center to uninstall as well"

That was a valuable information for me.

Creative Commons LicenseThis work is licensed under a Creative Commons Attribution-Share Alike 4.0 International License.