• Fixing slow wifi in Linux (Intel wifi)

    Home » Forums » AskWoody support » Linux for the Home user » Linux – all distros » Fixing slow wifi in Linux (Intel wifi)

    Author
    Topic
    #197555

    This may also work for non-Intel cards, so feel free to try it if your wifi is slow. The directions are the same for Intel or other cards.

    While Linux Mint and the other members of the Ubuntu Linux family have done a great job of configuring everything with the appropriate driver right out of the box (meaning as soon as Linux was done installing, before I started changing the default settings) every time I’ve installed Linux in recent years, there was one issue that was really annoying, and I thought I’d share how I fixed it with the good readers of AskWoody.com.

    I have several laptops with wireless networking (wifi) capability, and out of the box, they’ve always worked, but not as quickly as in Windows.  All of them use Intel wifi adapters… my Core 2 Duo laptop uses an Intel 7260 AGN (dual band without Bluetooth) MiniPCIE card, while my Dell laptop with Celeron N3060 uses an Intel 7265 AGN+AC (dual band with Bluetooth) M.2 card.  Those were not the original wifi cards in either of them, but upgrading wireless cards is easy and cheap (tons of cards on eBay for under $10), so why not?

    In Windows, the new 7265 card I put in the Dell ran at the full expected speed right from the get-go, but in Linux, it was actually slower than the supposedly “half as fast” card it had replaced.  That was… annoying!

    Meanwhile, I have a faint memory of the same slow speed being a problem when I first installed Linux on the Core 2 Duo laptop, but when I tested it now, it was fast– actually besting its performance in Windows by a little bit.  The 7260 and 7265 cards are very similar, and I am using the same version of Linux on both, so what did I change that fixed it on the older laptop?

    Searching the internet for “slow wifi” and other related things turned up a lot of stuff, and sorting through the outdated or irrelevant information can be frustrating.  I did find some answers, though.

    First of all, don’t use file copying from a Samba or Windows networking share as a measure of the wifi speed.  On most Linux systems, the automounting of a network share is handled by GVFS (Gnome Virtual File System, which was using that name for about a decade before MS came along and clumsily named something else the very same thing), and GVFS is slooooooow in copying from network shares on the client end.

    To get a better measure, I connected to my backup server’s FTP server (FileZilla) from Waterfox and downloaded some large files.  This did effectively max out the wifi connection and give a good report of the actual speed.  I got 22 MB/s in Windows and 24 MB/s in Linux on the 7260; on the 7265, I got 22 MB/s in Windows but only ~10 MB/s in Linux, with great variability (swinging back and forth between ~6 and ~14 MB/s), and sometimes not even that.  This is on the 5 GHZ “A” band, with no other detected networks impinging on the 40MHz channel I used.

    Most people probably won’t want to install a FTP server on a network computer just to test the wifi speed.  I happened to have it already set up (since the PC it is on is a backup server anyway), so that was easy.  Otherwise, you’d have to find a benchmark program you could install on a remote PC (another one on the network) as well as on the one with the slow wifi to get a good measure of the speed.  If you’re lucky enough to have internet fast enough to max out your wifi, you can try using that.

    So, back to troubleshooting the slowness.

    One of the answers suggested (that a lot of people said was helpful) was to disable the N mode in the card using a certain command.  I don’t know if it truly disables all of the N features or just the 40MHz bonded channel mode (two 20MHz channels used as one), but I didn’t replace the wifi card just to turn it back into the card it replaced (or worse).  I also knew that a very similar card performs as well or better in Linux as in Windows, so I was not going to try that “fix.”

    I tried checking the “firmware” (binary blob from Intel) to make sure it was the latest version, and it was.  I checked the Linux performance tuning TCP parameters, and they were fine.  I found out that my card was not registered to the US regulatory domain, so it was operating with “safe” international parameters that didn’t let it transmit at full power, but fixing that (I will have to make a separate post about fixing that) didn’t fix the problem (it may have helped a little, but it didn’t cure it).

    Finally, I stumbled across a web page that suggested turning off the wifi power saving mode, and it triggered a faint memory of something I’d done with the older laptop that delivered great performance over its Linux wifi.

    I issued the command on the laptop with the slow wifi (into the terminal, the Linux name for what Windows calls the command prompt):

    iwconfig

    That shows a list of the wireless devices on the PC with some of the more important bits of info for each card.  As expected, the slow wifi laptop showed Power Management: on for its wifi card.  It’s a laptop, so when it is on battery, it’s good to be able to save as much power as possible, so having that on would usually seem to be a good thing.

    I issued the same command on the fast wifi laptop, and…. Power Management: off.  Mmm, I may be on to something!

    To turn power management off, we need to know the name Linux knows the card by.  It’s not shown in the iwconfig info.  This command will give you the info you need in Mint and other Ubuntu relatives:

    sudo lshw -class network

    “ls” in Linux means list.  ‘ls’ by itself is the equivalent of ‘dir’ in Windows, listing the files in the current working directory.  ‘lshw’ means list hardware.  ‘lspci’ lists PCI devices on the computer, while ‘lsusb’ lists USB devices, and so on.  The -class network is pretty obvious; without that switch, lshw would list all the hardware, and we’d have to scroll through a ton of stuff to find what we need. ‘sudo’ means to run the command that follows as a superuser, also known as administrator or root, which ensures that the lshw command has access to all the hardware info.

    After entering the password for the sudo, scroll down through the info it provides and find the one that says “description: Wireless interface,” which on the Dell is the only one listed (it has no ethernet port), and a few lines under that it should say “logical name: wlp1s0”, where the actual name of your card replaces wlp1s0.

    It used to be that the first wifi card enumerated by the system would be called wlan0 (or ath0 for Atheros cards), but since it was never certain which order things would be enumerated in if there were multiples of something, they changed it so that things had more unique names that would stick with the device regardless of enumeration order, and that’s the one my 7265 ended up with.  That’s the situation in Mint 18.3, anyway; I don’t know about other Linuxes.

    So, now that you know the Linux name of the card, enter (substituting the name of your card for wlp1s0):

    sudo iwconfig wlp1s0 power off

    After that, iwconfig should show that power management is off.  Try the speed test again, and you should find a big improvement.

    Note that this is not a permanent fix.  The next time you reboot, it will go back to the way it was, with power management on.  If turning it off worked and you want to make it permanent in a distro that, like Mint, uses NetworkManager, there’s an easy way:

    sudo xed /etc/NetworkManager/conf.d/default-wifi-powersave-on.conf

    xed is the text editor in Mint 18.3 Cinnamon.  If you are using another version of Linux, substitute what your text editor is named for xed (pluma if you are using a Mate desktop, kate/kwrite/kedit for KDE, etc.).

    In that file, look for wifi.powersave = 3.  Change the 3 to a 2, then save the file.

    Of course, then the filename says “powersave on” even though it contains the command to turn power saving off, which didn’t seem like a good idea to me, since I might later forget what it is supposed to mean.  I’m no Linux expert, but I’ve noticed that directories (folders) that end in .d usually contain .conf files that are all obeyed in a certain order (sometimes they are preceded by numbers, like 20-whatever.conf, which would be obeyed before 3o-whatever-else.conf, and so on, up to 99).  So I tried changing the name from default-wifi-powersave-on.conf to default-wifi-powersave-off.conf (using the Mint GUI, just right click and select rename from an elevated/root Nemo (file manager) window, which you can get by first right clicking the background and selecting “Open as root”.

    I rebooted to be sure, and iwconfig still shows power management as off, so it looks like the name change didn’t affect anything.  Whether or not you rename the file, a reboot will let you know if it is going to persist as intended or not.

    That should do it.

    It appears that the iwlwifi driver (the driver for all of the newer Intel wireless adapters) has a bug in power management that kills its throughput.  It’s been an issue for a long time, as you can see in how far back the messages from people asking for help go, but with the limited resources in Linux, these kinds of things happen sometimes, unfortunately.  It may be Intel’s binary blobs that are at fault, and since those are closed-source, there would be no way to fix it until Intel decides to do it themselves.

    How this will affect battery life, I do not know yet.  For me, the full speed of the wifi connection is only needed when doing LAN stuff like transferring files over the network.  Even the slow performance with power management enabled is good enough for most public wifi internet connections, and certainly for my own home internet connection, and that’s the main purpose of the laptop when I am not at my desk (where the laptop is likely plugged in, so the slight increase in power consumption by the wifi adapter won’t make any difference), so I may end up with some kind of a script to turn power management back on when the laptop goes on battery power.

    Dell XPS 13/9310, i5-1135G7/16GB, KDE Neon 6.2
    XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 24.04
    Acer Swift Go 14, i5-1335U/16GB, Kubuntu 24.04 (and Win 11)

    5 users thanked author for this post.
    Viewing 5 reply threads
    Author
    Replies
    • #197624

      Great answer, Ascaris!

      You can turn off power management with this command in terminal as well

      sudo sed -i ‘s/3/2/’ /etc/NetworkManager/conf.d/*

      (got that from here!)

      You can create a launcher with the script above, then just hit that button, add the password, and you’re set.

      Power management can be tricky, though, depending on the Card. Atheros cards are usually very Linux frendly, other cards like Broadcom and Realtek may not be. If someone is having issues with power mangement on those, they may want to either try and google solutions, or just put in a third party wireless USB dongle that’s Linux friendly.

       

       

      2 users thanked author for this post.
      • #197635

        I have never had any luck getting my WiFi dongle with Broadcom (Netgear WNA3100) to even connect under Linux.

        But the cheap 802.11N 150Mbps dongle I got with a Ralink chip (Panda) works with every distro I tested with, as well as Windows.  http://pandawireless.com/

        Haven’t had to dig into the power settings under Linux yet, but thanks for the tips!

        Windows 10 Pro 22H2

        1 user thanked author for this post.
        • #197640

          My Compaq (HP) M2000z laptop (single core AMD Turion CPU, Win XP era) laptop came with a Broadcom MiniPCI (not MiniPCIE; this thing was much larger, about the size of a business card but a bit taller) wifi card that I ended up replacing with an Atheros all those years ago, when I was running Ubuntu Feisty Fawn alongside the preinstalled XP.

          Of course, it being a HP, as soon as I put in the new wifi card, it refused to boot, since the card was not in the whitelist.  I did my first BIOS mod on that laptop to replace the Broadcom PCI ID with the one from the Atheros.  It worked, and I still have that laptop today, with its Atheros card still working just fine.  It still dual boots XP and Linux, though the Linux is Mint Xfce 32-bit now, and as you would expect, XP doesn’t get to connect to the outside world.  I don’t really have much use for the PC with it being as slow as it is and with me having so many laptops anyway, but it still works nicely.

          I’m told HP did away with the whitelists about three years ago, finally.  I wonder if Lenovo (the other notorious whitelister for wifi cards) has or will do the same.

          Dell XPS 13/9310, i5-1135G7/16GB, KDE Neon 6.2
          XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 24.04
          Acer Swift Go 14, i5-1335U/16GB, Kubuntu 24.04 (and Win 11)

        • #197713

          +1 for Panda! I have the same dongle (for an old laptop with a weird Realtek inboard wireless), and the Panda works perfectly!

        • #197719

          I’ve got a PAU06 wireless dongle from Panda. Works flawlessly with a trivial setup (I’d call it true plug and play) on a 10 year old HP laptop running Ubuntu 16.04 LTS. Looks like they still sell it through Amazon for $15.00.

          Note: the Amazon description does not include Ubuntu 16.04 LTS, but as I recall I confirmed with Panda’s customer service that it would indeed work.

    • #197626

      Excellent info from both of you!

      I’ll have to try this, not only on my Linux Mint machine, but also on my Elementary OS machine. The Elementary OS machine needs all the help it can get, being an old, lame computer. But the fact that Elementary OS is a “light” version of Linux means that they may have already thought of that.

      I have a desktop, not a laptop, so I have no need for a power saving feature. Even if I had a laptop, as Ascaris said, the power you save is so small as to not really be worth the slower speed it causes.

      Group "L" (Linux Mint)
      with Windows 10 running in a remote session on my file server
    • #198075

      I just found this:

      Power Save Polling (PSP) Causes Connection Issues with Access Points

      “If a Wi-Fi access point (AP) or broadband Wi-Fi router does not support the power save polling (PSP) feature:

      • Intermittent loss of Wi-Fi connection
      • Inability to initiate a Wi-Fi connection
      • Poor Wi-Fi connection data performance”

      Note that third bullet item!

      The solution was to enable “continuous awareness mode,” which involves setting the profile to max performance mode (in XP), which is exactly what I am doing in Linux.  In Windows 8.1 or 7, it says to set transmit power to highest, which is what I have it set to in Linux, but I don’t have any reason to believe that continuous awareness mode is necessarily always linked to transmit power (if you read the article, you can see clearly that it is something else.  It’s linked in the Windows Intel driver, but is it in Linux?).

      Of course, this is Windows-centric advice, and I must note that in Windows, the same wifi card works flawlessly without changing any settings.  Still, it makes me wonder if my router is doing something incorrectly… I will have to research it.  The router uses DD-WRT, and I did find one mention of someone saying that they’d had reports that DD-WRT doesn’t do power saving well, but… well, the internet and grains of salt and what not.  It may or may not be this, but it’s worth some investigation.

      Dell XPS 13/9310, i5-1135G7/16GB, KDE Neon 6.2
      XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 24.04
      Acer Swift Go 14, i5-1335U/16GB, Kubuntu 24.04 (and Win 11)

      1 user thanked author for this post.
    • #199142

      Power Save Polling — likely uses enough power to maintain the connection, because it has enough power in order to poll the router. If you don’t at least ping (poll) the router every now and then, the router may think you aren’t on and may drop your connection. It then takes time to reestablish the connection.

      Setting transmit power to highest may mean nothing more than setting transmit power to always be on. If it is always on, it is using more power than if it is sometimes on (that is, unless it takes a lot of power to turn it on!). But when you turn something like that off and on regularly, you risk losing your connection, or having other connection issues. Things have to (1) handshake and (2) work together. If you stop and start these processes, it takes time to get them going again. For complex processes like wifi connectivity, it’s better to just leave them running, except in those cases when they can stay off for a long time.

      Group "L" (Linux Mint)
      with Windows 10 running in a remote session on my file server
    • #214750

      I just noticed another thing about this that’s really convenient.

      After you do the modification listed where you change the 3 to the 2, thereby turning off power saving for wifi, programs like TLP or Laptop Mode Tools that automatically enable lots of power saving features for laptops when the power is disconnected will put power saving back on while you’re on battery, and go back to your full-speed setting when put back on AC power, which for me is perfect.

      When I am on battery, I am likely out and about, using whatever wifi I can find to connect to the internet, and for that I don’t need maximum speed, since the internet connection has always been slower than the wifi link speed in every hotspot I’ve used (I always check them for throughput).

      When I do need the speed is when I am at home, plugged in to AC power, wirelessly connected to my LAN, where I often want to zap large files from or to the other PCs. Once I connect the AC power, I am back up to the speed I specified when I changed the 3 to a 2!

      If you don’t want this behavior, you can configure TLP or Laptop Mode to leave the power savings OFF on the wireless card, or use one the iwconfig command line option to do so just for a given session (after TLP or LM has already toggled, it won’t do it again until the power state is switched again).  Both of those tools default to all power savings in their default (usually OFF) state with AC power on, and all power saving settings enabled when on battery,  but it’s all configurable.  You can turn the power savings mode on while on AC power if you wish, or you can pick individual power saving settings for various things to not be enabled when you switch to battery.

      Both TLP and LM work great for me as installed, with one exception: Laptop Mode has its own function where it turns off the laptop backlight after 5 minutes of no input (makes it annoying to watch a movie), independent of the Linux system setting for that same function.  If I wanted it to turn the screen off, I would use the existing setting , which (in every Linux flavor I have tried so far) has always had a nice GUI option to turn display power saving on or off (and it has separate settings for AC and battery power, like Windows).

      I know the LM setting to do that could be turned off relatively easily, but I never bothered to find out how.  I just put it off until “later” until I happened to install a new version of Linux, which was Mint 19 Xfce.  When I was setting that up, I tried TLP instead of LM to see if it omitted this annoyance, which it did.

      Both of my laptops that I bought to use on battery (the Swift and the Inspiron) lack ethernet ports, FWIW, so the wifi being able to get up to speed while at home is important (until I finally get around to ordering a USB3 ethernet adapter for them).  I want to be sure to get one that works in Linux… while I’ve yet to have any problems getting things to work in Linux, I know others have had issues, so best to do the research first.

      Dell XPS 13/9310, i5-1135G7/16GB, KDE Neon 6.2
      XPG Xenia 15, i7-9750H/32GB & GTX1660ti, Kubuntu 24.04
      Acer Swift Go 14, i5-1335U/16GB, Kubuntu 24.04 (and Win 11)

      2 users thanked author for this post.
    • #214860

      I just checked my Linux laptop; power management is off for wifi.

      Thanks for sharing this tip with us.

      Group "L" (Linux Mint)
      with Windows 10 running in a remote session on my file server
      1 user thanked author for this post.
    Viewing 5 reply threads
    Reply To: Fixing slow wifi in Linux (Intel wifi)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: