Difference between revisions of "WiFi notes"

From Noah.org
Jump to navigationJump to search
m
m
Line 3: Line 3:
 
== Linux kernel drivers ==
 
== Linux kernel drivers ==
  
The '''mac80211''' is the only one to worry about these days. It is a generic WiFi driver. There are other, older ones, but everything is moving toward '''mac80211'''.
+
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 ==
 
== WiFi interface modes ==

Revision as of 07:13, 5 March 2014


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:

network={
        ssid="SOME-AP"
        #psk="PASSWORD"
        psk=f0431c0df3d54975b2fcf11f2041539e70d3ba74db889a0d78ed8cd0423f2c7a
}

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
network={
        ssid="SOME-AP"
        scan_ssid=1
        psk=f0431c0df3d54975b2fcf11f2041539e70d3ba74db889a0d78ed8cd0423f2c7a
}

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 (8.8.8.8 is Google's free, public nameserver):

nameserver 8.8.8.8

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.

SNR

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

Trilateration

Bilinear Interpolation

Shapely