Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting WIFI signal strength- seeking the best way (IOCTL, iwlist (iw) etc.)

I want to scan the signal strength received from 3 AP. I would be happy if that could happen every 300ms (max.500ms). I flashed OpenWRT on the routers.

I was seeking for a good tool to do that. First I found iwconfig which worked, but only with networks that I was connected to. So I used iwlist (iw didn't work- maybe I need to update it?). Do you know how accurate is the output of it? Can I trust it?

After that, I came across the IOCTL. It looks really powerful* and professional. But is the output from getting the signal stregnth from a WIFI more reliable than the simple method like iwlist/iw?

*even too much powerful as I failed to compile any program I wrote using it

like image 942
user3673464 Avatar asked Aug 17 '14 15:08

user3673464


People also ask

How to determine Wi-Fi signal strength?

You'll want to look for the universal WiFi symbol in the upper right-hand corner of your device to gauge your current signal strength. Generally, this indicator appears as four to five curved bars stacked on top of each other- the more bars that are filled in, the stronger your connection.

What is a good signal strength for Wi-Fi?

-50 dBm: This is considered an excellent signal strength. -60 dBm: This is a good signal strength. -67 dBm: This is a reliable signal strength. This is the minimum for any online services that require a reliable connection and Wi-Fi signal strength.

What is Wireless signal strength?

The signal strength is the wireless signal power level received by the wireless client. Strong signal strength results in more reliable connections and higher speeds. Signal strength is represented in -dBm format (0 to -100). This is the power ratio in decibels (dB) of the measured power referenced to one milliwatt.


1 Answers

If you want to determine the signal strength of WLAN access points to which you are not connected, scanning is the right way.

The scanning is performed by the wireless network card with much or little "help" from the driver, depending on the design of the wireless card. There are cards (chipsets, to be more specific) that have their own processor and run their own firmware code independently from the host computer. On the other end, there are "stupid" cards where the driver on the host computer does most of the work.

Between the driver and the rest of the operating system, there is an interface (API) for sending commands to the driver and reading back information in a standardized way. With Linux, there are at least two different APIs. The older one is named Wireless Extensions, and the newer one is named cfg80211. Normally, a driver supports only one of the APIs. Most current drivers use cfg80211, but there may be older drivers that still use Wireless Extensions.

For each of the two APIs, there's a user-space tool (or family of tools) to use it. For Wireless Extensions, there is iwconfig (and iwlist, iwpriv etc.) For cfg80211, there is just iw.

So, the questions about the right tool depends on what API the wireless driver uses. To add confusion ;-), cfg80211 does some emulation which allows you to perform some Wireless Extension calls to drivers that use the newer cfg80211 API.

Regarding your questions about ioctl(): This is a generic method for communication between user-space and kernel-space in Unix operating systems. The old Wireless Extensions API uses ioctl(). The newer cfg80211 API does not use an ioctl()-based interface, but uses nl80211 instead.

To sum it up: whether to use iw/cfg80211/nl80211 or iwconfig/Wireless Extensions/ioctl depends on the driver or your wireless card.

Regarding your desired scanning interval, I would say that 300ms is rather short. This is because for a useful scan, the client needs to leave its current channel for a short time, switch to another channel and listen to signals from other access points on this channel. Since leaving its channel interrupts communication, these off-channel times are usually kept short and are carried out infrequently.

Calling iw <dev> scan or iwlist <dev> scan, respectively, will not necessarily cause a new scan, but may return an old (cached) list of access points. Depending on your wireless card/driver it may be (im)possible to enforce a new scan.

like image 104
dasup Avatar answered Sep 23 '22 16:09

dasup