Linux chooses wrong WiFi access point

My house has two access points sharing the same SSID and the same WPA2 password. The goal is that mobile devices can select the access point that they have the best connection to, no matter where they are in the house.

In the living room, my laptop always chose the wrong access point - the one with the lowest signal strength. I could re-connect wifi to get the correct one, but after one or two minutes it would switch back to the one further away.


My Laptop's Debian unstable distribution use Network Manager (version 1.28.0-2+b1) to connect to ethernet and wlan, and in its bug tracker I found the right bug report: #474: Network Manager prefers further away AP when there are multiple .

The network manager developers say it's not their fault; the wpa_supplicant tool (version 2.9.0-16) is responsible for choosing the right access point:

In general, if the profile does not restrict the AP (by setting one of wifi.bssid,,, then any AP is allowed. Then the decision which AP to choose is made by wpa_supplicant.

User verdre looked into the code and found:

In its decision logic whether to roam between APs it basically uses estimated bandwith as first priority, so if another AP can do ht40 while the current one only has ht20, it will switch to the other one while (pretty much) ignoring how bad the signal quality is.

WiFi speed

I used the network manager command line interface to check the supported speeds:

$ nmcli d wifi list ifname wlp1s0
IN-USE  BSSID              SSID             MODE   CHAN  RATE        SIGNAL  BARS  SECURITY
        5C:49:79:00:23:42  Infra  1     270 Mbit/s  100     ▂▄▆█  WPA2
        F8:D1:11:00:23:42  Infra  11    65 Mbit/s   64      ▂▄▆_  WPA2     

The second one is the TP-Link WR740N v4 in the living room, and it's speed is a quarter of the FritzBox. So I could have the same problem as described by verdre.

The TP-Link router datasheet says it supports 150 Mbit/s, which is way more than the 65 MBit/s reported by network manager.

What are "ht20" and "ht40"? 2.4 GHz Wi-Fi channels are 20 MHz wide. The Wifi standard version 802.11n supports bundling channels, so that two channels may be combined and you get 40 MHz.

After setting "Channel Width" to "Wide HT40 (40 MHz)" in the router's DD-WRT web interface, the TP-Link router is faster and supports 135 MBit/s:

$ nmcli d wifi list ifname wlp1s0
IN-USE  BSSID              SSID             MODE   CHAN  RATE        SIGNAL  BARS  SECURITY
        5C:49:79:00:23:42  Infra  1     270 Mbit/s  54      ▂▄__  WPA2
*       F8:D1:11:00:23:42  Infra  11    135 Mbit/s  85      ▂▄▆█  WPA2

With the dual-channel setting activated in the router, my laptop stays connected to it and does not switch to the bad connection.

Written by Christian Weiske.

Comments? Please send an e-mail.