ggeers
Posts: 15
Joined: Tue Feb 21, 2017 5:32 am

More on wifi scanning

Fri Feb 24, 2017 8:29 pm

Hi,
I've now discovered that wlan scanning at one minute intervals also happens on the inbuilt adapter.

If you have 'iw' installed try running 'iw event' and look at the output.

What subsystem is starting those scans? How can they be stopped?

Someone must know...

Cheers,
Glenn

wh7qq
Posts: 1581
Joined: Thu Oct 09, 2014 2:50 am

Re: More on wifi scanning

Sat Feb 25, 2017 2:33 am

Lots of info is available on "iw" by doing a google search on "iw linux" but right off, two I found were https://wireless.wiki.kernel.org/en/use ... ntation/iw and https://linuxcommando.blogspot.com/2013 ... twork.html. From a cursory look at both sources, I did not find anything to clarify that scanning is occurring continuously as you imply, unless the command

Code: Select all

iw event
is invoked. Presumably, a "CTRL-c" stoppng iw event stops the scanning. If you or another have info to the contrary, I'd like to see it. I was unable to find "iw" running by invoking

Code: Select all

htop
and searching for iw but when I invoked

Code: Select all

iw event
it showed up. Htop must be added to Raspbian with

Code: Select all

sudo apt-get install htop

ggeers
Posts: 15
Joined: Tue Feb 21, 2017 5:32 am

Re: More on wifi scanning

Sat Feb 25, 2017 4:31 am

iw wlan1 event will display all events on the interface. It's not initiating the scans. Something else is.

Similarly if you start wpa_cli you will see scan events occurring regularly.

I don't think it's wpa_supplicant that's initiating the scans.

Perhaps it's the driver?

Driving me nuts!

Cheers
Glenn

chadiem
Posts: 3
Joined: Thu Dec 03, 2020 8:47 pm

Re: More on wifi scanning

Thu Dec 03, 2020 8:55 pm

If you have a full installation of Raspbian (with the UI), it's likely that the scans are coming from lxpanel to update the Wi-Fi networks in the background.

If you don't need lxpanel, you can comment out the below line in /etc/xdg/lxsession/LXDE-pi/autostart:

Code: Select all

@lxpanel --profile LXDE-pi

bmcahill
Posts: 3
Joined: Sat Apr 03, 2021 12:34 am

Re: More on wifi scanning

Sat Apr 03, 2021 3:33 am

I had similar problems, and eventually tracked down three independent sources for the WiFi scans: lxpanels dhcpcd-ui (app level), wpa-supplicant (mid-level), and the Broadcom driver (low level).

lxpanels dhcpcd-ui applet: lxpanels dhcpcd-ui, when WiFi is associated, by default automatically performs the once-per-minute background scans. You can disable that by entering a new line in file ~/.config/lxpanel/LXDE-pi/panels/panel. Look for a Plugin entry of type=dhcpcdui. Here's what I put in (comments are my own and totally optional ... but I always forget why I do things!). The only line you really need to add is "BgScan=0" ... Note that the capitalization of "BgScan" must be exact:

Code: Select all

Plugin {
  type=dhcpcdui
  Config {
    # The following entry eliminates 1-minute-periodic wifi scans
    #   originating from dhcpcd-ui (lxpanel app that lets you select
    #   the AP you want; click on wifi symbol at top of desktop).
    #   Scans disable wifi comm intermittently causing delays!
    # NOTE: THIS DOES NOT SET ANY WPA_SUPPLICANT VALUES!
    # dhcpcd-ui calls wpa_cli utility directly, using SCAN command
    BgScan=0
  }
}
wpa-supplicant: This also, by default, performs background scans if nothing else does, which happened every ~70 seconds once I disabled the lxpanels scans. The file to modify is /etc/wpa_supplicant/wpa_supplicant.conf. Disable background scans via line bgscan="" (empty double-quotes). If written outside of a network block, it should apply globally to all networks. I'm paranoid, and entered it twice, once at a global level, and once within the block for my "AC2YD - QTH" network, which is the latency-sensitive one; I also set that at a higher priority for association than the other network via priority=2. I also entered two other global entries, so if scans did occur, they would be as limited as possible ... freq_list=2412 5180 limits a scan to just 2 WiFi channels, i.e. the channels on which my 2 networks operate. scan_cur_freq=1 looked as if it might keep scans from going off-channel when associated, but I'm not sure ... for info, search for "Example wpa_supplicant configuration file" on internet. My wpa_supplicant.conf looks like this:

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
freq_list=2412 5180
scan_cur_freq=1
bgscan=""

network={
        ssid="123weak"
        psk="xxxxxxxxxxxxxx"
        key_mgmt=WPA-PSK
        disabled=1
}

network={
        ssid="AC2YD - QTH"
        psk="xxxxxxxxxxxxxx"
        key_mgmt=WPA-PSK
        bgscan=""
        priority=2
}
Driver: The driver, or perhaps the firmware inside the Broadcom chip, will also automatically scan by default, if nothing else launches a scan. IIRC, this happened every ~130 seconds, once I disabled wpa_supplicant scans. To disable this, I had to create a new file /etc/modprobe.d/brcmfmac.conf, and add a single line to disable roaming (and therefore disable the scans required to perform roaming):

Code: Select all

options brcmfmac roamoff=1
YMMV ... Good luck!

ejolson
Posts: 11759
Joined: Tue Mar 18, 2014 11:47 am

Re: More on wifi scanning

Sat Apr 10, 2021 3:09 am

bmcahill wrote:
Sat Apr 03, 2021 3:33 am
I had similar problems, and eventually tracked down three independent sources for the WiFi scans: lxpanels dhcpcd-ui (app level), wpa-supplicant (mid-level), and the Broadcom driver (low level).

lxpanels dhcpcd-ui applet: lxpanels dhcpcd-ui, when WiFi is associated, by default automatically performs the once-per-minute background scans. You can disable that by entering a new line in file ~/.config/lxpanel/LXDE-pi/panels/panel. Look for a Plugin entry of type=dhcpcdui. Here's what I put in (comments are my own and totally optional ... but I always forget why I do things!). The only line you really need to add is "BgScan=0" ... Note that the capitalization of "BgScan" must be exact:

Code: Select all

Plugin {
  type=dhcpcdui
  Config {
    # The following entry eliminates 1-minute-periodic wifi scans
    #   originating from dhcpcd-ui (lxpanel app that lets you select
    #   the AP you want; click on wifi symbol at top of desktop).
    #   Scans disable wifi comm intermittently causing delays!
    # NOTE: THIS DOES NOT SET ANY WPA_SUPPLICANT VALUES!
    # dhcpcd-ui calls wpa_cli utility directly, using SCAN command
    BgScan=0
  }
}
wpa-supplicant: This also, by default, performs background scans if nothing else does, which happened every ~70 seconds once I disabled the lxpanels scans. The file to modify is /etc/wpa_supplicant/wpa_supplicant.conf. Disable background scans via line bgscan="" (empty double-quotes). If written outside of a network block, it should apply globally to all networks. I'm paranoid, and entered it twice, once at a global level, and once within the block for my "AC2YD - QTH" network, which is the latency-sensitive one; I also set that at a higher priority for association than the other network via priority=2. I also entered two other global entries, so if scans did occur, they would be as limited as possible ... freq_list=2412 5180 limits a scan to just 2 WiFi channels, i.e. the channels on which my 2 networks operate. scan_cur_freq=1 looked as if it might keep scans from going off-channel when associated, but I'm not sure ... for info, search for "Example wpa_supplicant configuration file" on internet. My wpa_supplicant.conf looks like this:

Code: Select all

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=US
freq_list=2412 5180
scan_cur_freq=1
bgscan=""

network={
        ssid="123weak"
        psk="xxxxxxxxxxxxxx"
        key_mgmt=WPA-PSK
        disabled=1
}

network={
        ssid="AC2YD - QTH"
        psk="xxxxxxxxxxxxxx"
        key_mgmt=WPA-PSK
        bgscan=""
        priority=2
}
Driver: The driver, or perhaps the firmware inside the Broadcom chip, will also automatically scan by default, if nothing else launches a scan. IIRC, this happened every ~130 seconds, once I disabled wpa_supplicant scans. To disable this, I had to create a new file /etc/modprobe.d/brcmfmac.conf, and add a single line to disable roaming (and therefore disable the scans required to perform roaming):

Code: Select all

options brcmfmac roamoff=1
YMMV ... Good luck!
Thanks for posting. This looks like very useful information which I'll try out now.

Return to “Troubleshooting”