WiFi notes

From Noah.org
Jump to: navigation, search

overlapping channels and collisions

I'm not saying I don't believe in the following practice, but I am saying that I don't believe most people who believe this actually know what they are talking about.

The following may be a lie: You should select channel 1, 6, or 11 for your network because these are the only non-overlapping channels. To start, these are not non-overlapping channels. They don't overlap with each other as a set, true, but you could just as easily tell people to only use channels 3 and 9. [1, 6, and 11] is the biggest set of non-overlapping channels within the 2.4 GHz WiFi spectrum, but [3, 9] would also serve the same purpose.

Since about the year 2010 a new custom has come about -- one must select only the non-overlapping WiFi channels 1, 6, and 11 for a WiFi network. It seems to me there are holes in the logic of this practice. WiFi channels are rarely evenly utilized over the given bandwidth (not even consider 802.11b, which even worse). At the highest data rates the spectral efficiency is actually quite good due to the type of spread spectrum modulation used. As a connection shifts down to lower data rates the type of spread spectrum modulation used also changes. At lower data rates the spectral efficiency is lower. If you look at a spectral plot you see that a WiFi channel looks like a bell (under ideal circumstances it looks like a nice, flat, rectangle). Most of the energy and data gets concentrated toward the center of the WiFi channels (at least on 2.4 GHz). Overlapping channels should therefore have lower rates of retransmission/retry due to cross-channel interference than is commonly assumed. In very crowded areas no network is able to maintain the highest data rates, which have the good spectral efficiency.

The logic of choosing only channel 1, 6, or 11 only seems valid if there are only two other visible networks using the remaining two channels. As soon as more networks move into range where their traffic can begin to cause interference you have to accept some interference. Now, I have read that if you are in this situation then it's actually better to pick the exact same channel of another nearby network. The logic is that WiFi handles network interference from competing networks better than it handles off-channel interference. Supposedly competing on-channel networks actually negotiate and manage congestion, whereas interference from off-channel networks is treated as just radio noise. I say supposedly, but it's in the WiFi specs. I'm pretty sure that I don't believe this actually works to any useful effect. Can two negotiating networks, by managing bandwidth together, really get better throughput than two nearby networks working around each other using just spread spectrum and error correction to maintain a viable connection? Perhaps, but I could just as easily see that the overhead to meter traffic could end up causing even greater throughput loss.

I just scanned the WiFi networks in the vicinity of my home. I see over 20 networks (moderate density for San Francisco). None of them are on any channel other than 1, 6, or 11! Has the voodoo has come full circle? It is my believe that if I go set my access point to channel 3 or 9 then I will get the best speed, most range, and most robust connection of anyone in the vicinity.

What I really believe is that I've never found channels 1, 6, and 9 to magically solve a WiFi problem. Looking at the network with a spectrum analyzer and picking the spot in the middle of the areas with least utilization has helped more than sticking to channel 1, 6, or 9.

The real solution is to switch to the 5 GHz band.


See also wpa_supplicant.

Linux kernel drivers

The mac80211 is the only one to be concerned about. It is a generic WiFi driver. There are other, older ones, but everything is moving toward mac80211.

Linux WiFi control

The iw tool is the only one to be concerned about.

Don't use iwconfig anymore. It is old, deprecated, and no longer maintained. Use iw instead.

WiFi interface modes

Station mode, also known as Managed Mode. This is the typical mode for WiFi clients. At station is associated with an access point.

AP mode, Access Point infrastructure mode, master mode. This mode is set when a WiFi interface is acting as an access point. If an interface supports this mode, then you can use hostapd to create an Access Point.

Monitor mode. This mode is similar to "promiscuous mode" for wired interfaces, but is actually at a lower level. In this mode the interface is simply listening to all wireless frames being broadcast by nearby WiFi radios. There is no Access Point network association necessary. This mode may also be used for arbitrary frame injection. See Radiotap for a tool to monitor and inject frames.

Ad-Hoc mode, aka IBBS (Independent Basic Service Set) mode. This mode is used for peer-to-peer connections without an Access Point. This is like connecting two laptops together with a cross-over cable.

WDS mode. Wireless Distribution System mode. This mode is similar to AP mode, but the interface in this mode does not act as an access point master itself. Instead it passes off responsibility to another Access Point. This mode is used to extend an existing WiFi network.

Mesh mode. This mode is used to build self-organizing, Self routing network.

connecting to an AP from the command-line

This should be the bare minimum you need to get WifI up and working with WPA security from the command-line. This does not establish a connection that will be restored on reboot; this is just a temporary connection.

Run `wpa_passphrase` to generate a conf file that will be used later by `wpa_supplicant`:

wpa_passphrase SOME-AP PASSWORD > wpa.conf

You will get a file that looks like this:


Modify the file so that it looks like this (add the ctrl_interface and scan_ssid lines):

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev

Now run the following commands (where wlan0 is your WiFi device name):

ifconfig wlan0 up
wpa_supplicant -B -D wext -c "wpa.conf" -i wlan0 -f /var/log/wpa_supplicant.log
dhclient wlan0

If your dhcp server is stupid then you might also have to change your /etc/resolv.conf file to something like the following ( is Google's free, public nameserver):


scan for access points sorted by power

sudo iwlist wlan0 scanning | grep -e "Address:" -e "level=" | while read l1 && read l2; do echo $l1 $l2; done | awk '{print $8" "$5;}' | sed -e 's/level=//' | sort

The results will look something like this:

-46 AC:4B:C8:0F:AA:00
-53 AC:4B:C8:0E:A6:40
-53 AC:4B:C8:0F:7F:80
-53 AC:4B:C8:0F:C3:40
-54 AC:4B:C8:0F:AA:01
-56 7C:D1:C3:96:25:BA
-58 AC:4B:C8:0F:C3:41
-65 60:33:4B:03:87:89
-66 AC:4B:C8:0F:95:80
-67 AC:4B:C8:0E:A6:41
-67 AC:4B:C8:0F:91:00
-70 AC:4B:C8:0D:F4:00

This will add the WiFi channel used by the access point:

iwlist wlan2 scanning | grep -e "Address:" -e "level=" -e "Channel:" | while read l1 && read l2 && read l3; do echo $l1 $l2 $l3; done | awk '{print $9" "$5" "$6;}' | sed -e 's/level=//' -e 's/Channel://' | sort

The results will look something like this:

-46 AC:4B:C8:0F:AA:00 6
-52 AC:4B:C8:0F:C3:40 11
-54 AC:4B:C8:0E:A6:40 11
-55 AC:4B:C8:0F:AA:01 165
-58 7C:D1:C3:96:25:BA 11
-58 AC:4B:C8:0F:7F:80 1
-58 AC:4B:C8:0F:C3:41 44
-59 AC:4B:C8:0E:29:C0 1
-66 AC:4B:C8:0E:A6:41 161
-67 AC:4B:C8:0D:F4:00 11
-67 AC:4B:C8:0F:95:80 11
-70 AC:4B:C8:0F:91:00 1
-71 20:E5:64:A1:6D:20 6

Sometimes you get the following error message:

Interface doesn't support scanning : Device or resource busy

This is usually harmless. Try the scan again.

Received Signal Strength Indicator

Received Signal Strength Indicator (RSSI) is dimensionless. It is a measure of relative signal strength; thus, it is only useful in comparing measurements made with the same hardware and drivers. Measurements are probably not comparable even between two different receivers made with identical equipment. The values returned from different hardware and drivers can have vastly different ranges and interpretations of minimum and maximum.

Contrast this to Signal Strength.


The Signal to Noise Ratio (SNR) in WiFi can be characterized by the following values:

>40 dB
excellent signal; almost always full speed.
25 - 40 dB
good signal; usually full speed, but may sometimes drop to lower speed.
15 - 25 dB
moderate signal; fast, but not always full speed.
10 - 15 dB
lowest useful signal; slow data speeds; may sometime loose association.
<10 dB
AP may be detectable, but rarely useful signal; rarely maintains association.

Signal Strength

Signal Strength is usually expressed in dBm. This is an absolute value (not dimensionless) for measuring milliwatts. That is, dBm is another way to measure milliwatts. Also note that dBm is a log scale. The reference power is 0 dBm = 1 mW. Negative values are fractions of a milliwatt.

The range of received signal power for WiFi stations is typically in the range or -80 to -50 dBm. Contrast this to Received Signal Strength Indicator.

Rule of 10: Add 10 to dBm is equivalent to multiplying power by 10.

  • -80 dBm equals 10 pW of received radio power.
  • -70 dBm equals 100 pW. This is 10 times stronger than -80 dBm.
  • -60 dBm equals 1000 pW, or 1 nW. This is 10 times stronger than -70 dBm.
  • -50 dBm equals 10000 pW, or 10 nW, or 10^-5 mW, or 0.00000001 W or 10^-8 W
  • -40 dBm equals 100 nW, or 0.0001 mW, or 10^-7 W
  • -30 dBm equals 1000 nW, or 0.001 mW, or 10^6 W, 0.000001 W
  • -20 dBm equals 0.01 mW, or 10^5 W, or 0.00001 W
  • -10 dBm equals 0.1 mW, 10^4 W, or 0.0001 W
  • The values below are for comparison, since most WiFi chipsets don't allow more than 100 mW of transmit power, and the amount you receive will be significantly less than 100 mW.
  • 0 dBm equals 1 mW, or 10^3 W, or 0.001 W
  • 10 dBm equals 10 mW, or 0.01 W
  • 20 dBm equals 100 mW, or 0.1 W
  • 30 dBm equals 1 W
  • 40 dBm equals 10 W
  • 50 dBm equals 100 W
  • 60 dBm equals 1 kW

The inside of a microwave oven can have a signal strength of 60 dBm, which is 1 kilowatt. There is a 120 dB difference between -60 dBm and 60 dBm. That's a factor of 10^12, so there is one trillion times more radio energy inside a microwave oven than what is received by a WiFi station. But, you have to be careful when trying to impress people with big numbers. The range of human hearing is also 120 dB. That ranges from the most quiet sound the ear can hear to the loudest sound the ear can hear before it is damaged.

1 milliwatt = 1.0 × 10-6 kilowatts

Location by RSSI


Bilinear Interpolation