WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: how to get reliable signal strengths when doing CLI wifi scan?  (Read 3971 times)

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
how to get reliable signal strengths when doing CLI wifi scan?
« on: November 22, 2022, 08:22:14 PM »
I'm running TCL 13.1 x86_64 on my X230 ThinkPad, which has a Intel Dual Band Wireless-AC 7265 card. The two CLI tools that I'm familiar with, iw and iwlist, alternate between reporting accurate signal strengths and reporting spuriously low signal strengths.

Here are consecutive runs using iw when I am just standing still in my house. Note how the signal strengths go up and down each time I run the command:

Code: [Select]
bruno@x230:~$ sudo iw dev wlan0 scan | grep -e 'signal:' -e 'SSID:' | head -10
signal: -42.00 dBm
SSID: donkey
signal: -64.00 dBm
SSID: bibliotheca_alexandrina
signal: -80.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -84.00 dBm
SSID: wattslolahome-guest
bruno@x230:~$ sudo iw dev wlan0 scan | grep -e 'signal:' -e 'SSID:' | head -10
signal: -69.00 dBm
SSID: donkey
signal: -78.00 dBm
SSID: bibliotheca_alexandrina
signal: -80.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -84.00 dBm
SSID: wattslolahome-guest
bruno@x230:~$ sudo iw dev wlan0 scan | grep -e 'signal:' -e 'SSID:' | head -10
signal: -43.00 dBm
SSID: donkey
signal: -61.00 dBm
SSID: bibliotheca_alexandrina
signal: -79.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -82.00 dBm
SSID: wattslolahome-guest
bruno@x230:~$ sudo iw dev wlan0 scan | grep -e 'signal:' -e 'SSID:' | head -10
signal: -69.00 dBm
SSID: donkey
signal: -81.00 dBm
SSID: bibliotheca_alexandrina
signal: -79.00 dBm
SSID: Spencer
signal: -80.00 dBm
SSID: wattslolahome
signal: -82.00 dBm
SSID: wattslolahome-guest

If I append the flush option to the iw command (like this: sudo iw dev wlan0 scan flush) it makes no difference.

Using iwlist results in the same shenanigans. Watch:
Code: [Select]
bruno@x230:~$ sudo iwlist wlan0 scan | grep -e "Signal" -e "SSID" | head -10
                    Quality=68/70  Signal level=-42 dBm 
                    ESSID:"donkey"
                    Quality=47/70  Signal level=-63 dBm 
                    ESSID:"bibliotheca_alexandrina"
                    Quality=27/70  Signal level=-83 dBm 
                    ESSID:"wattslolahome-guest"
                    Quality=28/70  Signal level=-82 dBm 
                    ESSID:"Ring Setup 9b"
                    Quality=30/70  Signal level=-80 dBm 
                    ESSID:"Spencer"
bruno@x230:~$ sudo iwlist wlan0 scan | grep -e "Signal" -e "SSID" | head -10
                    Quality=42/70  Signal level=-68 dBm 
                    ESSID:"donkey"
                    Quality=30/70  Signal level=-80 dBm 
                    ESSID:"bibliotheca_alexandrina"
                    Quality=27/70  Signal level=-83 dBm 
                    ESSID:"wattslolahome-guest"
                    Quality=28/70  Signal level=-82 dBm 
                    ESSID:"Ring Setup 9b"
                    Quality=30/70  Signal level=-80 dBm 
                    ESSID:"Spencer"
bruno@x230:~$ sudo iwlist wlan0 scan | grep -e "Signal" -e "SSID" | head -10
                    Quality=68/70  Signal level=-42 dBm 
                    ESSID:"donkey"
                    Quality=45/70  Signal level=-65 dBm 
                    ESSID:"bibliotheca_alexandrina"
                    Quality=33/70  Signal level=-77 dBm 
                    ESSID:"wattslolahome-guest"
                    Quality=25/70  Signal level=-85 dBm 
                    ESSID:"Ring Setup 9b"
                    Quality=31/70  Signal level=-79 dBm 
                    ESSID:"Spencer"
bruno@x230:~$ sudo iwlist wlan0 scan | grep -e "Signal" -e "SSID" | head -10
                    Quality=42/70  Signal level=-68 dBm 
                    ESSID:"donkey"
                    Quality=30/70  Signal level=-80 dBm 
                    ESSID:"bibliotheca_alexandrina"
                    Quality=33/70  Signal level=-77 dBm 
                    ESSID:"wattslolahome-guest"
                    Quality=25/70  Signal level=-85 dBm 
                    ESSID:"Ring Setup 9b"
                    Quality=31/70  Signal level=-79 dBm 
                    ESSID:"Spencer"
Does anyone know how to make one of these utilities give consistent results? If not, is there a different CLI tool that gives consistent results?

« Last Edit: November 22, 2022, 08:45:44 PM by GNUser »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #1 on: November 22, 2022, 08:56:46 PM »
I noticed that the first scan after boot gives the bogus low strengths, second scan gives accurate strengths, third scan gives bogus low strengths, etc.

Since I only have one shell script that scans for wireless networks, this is my (truly hideous) solution for the time being:

Code: [Select]
sudo iw dev wlan0 scan flush >/dev/null
sudo iw dev wlan0 scan flush >/tmp/wifi-scan-results.txt

In other words, every time I need to do a wifi scan, I first discard the scan with bogus signal strengths, then scan again and save the result with the accurate signal strengths. A true kludge if I ever saw one!

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #2 on: November 22, 2022, 09:37:32 PM »
The problem must be hardware-related. A different TCL13 x86_64 machine (ThinkPad T520 with Intel Centrino Advanced-N 6205 card) does not have this problem at all (i.e., consecutive wifi scans show consistent signal strengths).

I don't know if the bug is in the kernel, the Wireless-AC 7265 card, or card's driver. I imagine that troubleshooting this would not be fun. I'm happy to use my kludge on the machine that needs it.

Sorry for the noise.

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 724
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #3 on: November 23, 2022, 12:26:53 AM »
Don't be sorry for some noise.
The problems needs to be solved. :)

I know little of computers but some times I get the correct answer for the problems.
When you describe your problem two thing come in mind, some wifi chips comes with some
power savings features, and maybe your problem has something to do with that.

So the first command wakes up the wifi, and the second command do it's real thing.

Some bios settings can disable the power saving features.
Maybe this feature depending on if your computer is connected to the power outlet, or just using the battery.

And i think some drivers can also change this behavior, just need correct mod flags.

Don't let your computer steer you, you have the control of your own computer. :)

And you say that you using dualband, maybe you use the same ssid for 5GHz and 2.4Ghz
The driver switches between this two, so my suggestion you have to change your router to have two ssid to distinguish between this two frequencies.

The signal strengths, is much better with 2.4 because of the "low" frequency.

Happy hacking
« Last Edit: November 23, 2022, 12:40:44 AM by patrikg »

Offline gadget42

  • Hero Member
  • *****
  • Posts: 826
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #4 on: November 23, 2022, 01:36:54 AM »
haven't used this but it looks interesting and the readme was informative and thought-provoking

https://github.com/ghostop14/sparrow-wifi
The fluctuation theorem has long been known for a sudden switch of the Hamiltonian of a classical system Z54 . For a quantum system with a Hamiltonian changing from... https://forum.tinycorelinux.net/index.php/topic,25972.msg166580.html#msg166580

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #5 on: November 23, 2022, 09:24:39 AM »
When you describe your problem two thing come in mind, some wifi chips comes with some
power savings features, and maybe your problem has something to do with that.

Thanks for your help, patrikg. After seeing your post I decided to scan for wifi networks on the affected laptop while plugged in to AC power. It makes no difference whether on battery power or on AC power, unfortunately.

Then I tried going into BIOS settings, but this laptop uses Coreboot which, as far as I'm aware, does not have a settings menu.

Next I explored the driver options:
Code: [Select]
$ modinfo iwlwifi
filename:       /lib/modules/5.15.10-tinycore64/kernel.tclocal/drivers/net/wireless/intel/iwlwifi/iwlwifi.ko.gz
author:         Intel Corporation <linuxwifi@intel.com>
description:    Intel(R) Wireless WiFi driver for Linux
license:        GPL
parm:           remove_when_gone:Remove dev from PCIe bus if it is deemed inaccessible (default: false)
parm:           disable_11ac:Disable VHT capabilities (default: false)
parm:           power_level:default power save level (range from 1 - 5, default: 1)
parm:           power_save:enable WiFi power management (default: disable)
parm:           led_mode:0=system default, 1=On(RF On)/Off(RF Off), 2=blinking, 3=Off (default: 0)
parm:           bt_coex_active:enable wifi/bt co-exist (default: enable)
parm:           enable_ini:Enable debug INI TLV FW debug infrastructure (default: true
parm:           uapsd_disable:disable U-APSD functionality bitmap 1: BSS 2: P2P Client (default: 3)
parm:           nvm_file:NVM file name
parm:           fw_restart:restart firmware in case of error (default true)
parm:           amsdu_size:amsdu size 0: 12K for multi Rx queue devices, 2K for AX210 devices, 4K for other devices 1:4K 2:8K 3:12K (16K buffers) 4: 2K (default 0)
It seems power_save is disabled by default, which is good but leaves me without ideas of what to try next :-\
« Last Edit: November 23, 2022, 09:42:06 AM by GNUser »

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 724
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #6 on: November 23, 2022, 11:23:20 AM »
You only get the default value when using modinfo, lets see what value is set ??
Lets us execute this oneliner :)

Code: (bash) [Select]
for parm in $(ls /sys/module/iwlwifi/parameters/); do echo $parm $(cat /sys/module/iwlwifi/parameters/$parm); done

And what about this i wrote in the previous thread:

And you say that you using dualband, maybe you use the same ssid for 5GHz and 2.4Ghz
The driver switches between this two, so my suggestion you have to change your router to have two ssid to distinguish between this two frequencies.

The signal strengths, is much better with 2.4 because of the "low" frequency.

Happy hacking
« Last Edit: November 23, 2022, 11:27:56 AM by patrikg »

Offline GNUser

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 1530
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #7 on: November 23, 2022, 11:52:28 AM »
Hi, patrikg. Here you go:

Code: [Select]
$ for parm in $(ls /sys/module/iwlwifi/parameters/); do echo $parm $(cat /sys/module/iwlwifi/parameters/$parm); done
11n_disable 0
amsdu_size 0
bt_coex_active Y
disable_11ac N
disable_11ax N
enable_ini Y
fw_restart Y
led_mode 0
nvm_file (null)
power_level 0
power_save N
remove_when_gone N
swcrypto 0
uapsd_disable 3

My router is dual-band. The 5 GHz SSID is called "bibliotheca_alexandrina" and the 2.4 GHz SSID is called "donkey". If you look at my first post with the scan results, you see that the scans look at both frequency bands.
« Last Edit: November 23, 2022, 11:55:16 AM by GNUser »

Offline patrikg

  • Wiki Author
  • Hero Member
  • *****
  • Posts: 724
Re: how to get reliable signal strengths when doing CLI wifi scan?
« Reply #8 on: November 23, 2022, 12:14:31 PM »
OK
power_save N
power save set to NO.

Okey my bad, not seen that in your threads. 2.4 and 5, have different ssid.

Sorry to say that's my thinking of your problem.

Nothing else have popped up in my brain.