The ability to experiment rapidly is the best approach for a quick diagnosis.
Two diagnostic tools I find invaluable to pinpoint the root cause in cases where the WiFi works, but is unreliable, e.g. intermittently losing the connection, sessions hanging, web-pages freezing are iwlist
and mtr
.
Here's how to use iwlist
and mtr
effectively:
1) Is the low-level wireless reception/transmission healthy?
watch sudo iwlist wlan0 scan
This gives a treasure trove of information about the strongest wireless signals detected by your card. I find the Channel
, Frequency
, ESSID
, Quality
, and Signal level
, the most useful.
If you have no signal, or your ESSID isn't recognized, you need to focus on the low-level (hardware/drivers): Is the router on? Are antennas oriented optimally? Is device too far away from the router? Do you have the right driver for your wifi card? (for that you may want to check the system logs)
Assuming the ESSID is known and the quality is good (say about 30%-100% of the maximum) you may move to the second, higher level, stage:
2) Once a WiFi connection is established, is the connection stable?
Since TCP/IP supports error-detection with retransmits, and congestion control, WiFi disconnects/reconnects are usually a result of a large number of errors to the point where TCP gives-up. Rather than waiting for a full disconnect, which may happen only once in several minutes, I run mtr
in a separate window and continuously watch the Loss%
(packet percent loss) and Avg
(average round-trip time in milliseconds) columns:
mtr <hostname>
While looking at this screen, I can immediately see not just whether there's some ongoing transmission/reception problem, but also which link along the way is the most problematic/slow one, in case there's more than one hop between me and the target <hostname>
.
(If you don't have mtr
installed, you may install it using: sudo apt-get install mtr
)
I find these two tools particularly valuable because they provide a continuous state of the WiFi connection. I can quickly change configuration and immediately see the effect of my change on the network. Some examples of experiments you may do while looking at the above described screens are:
- Edit
/etc/network/interfaces
and then ifdown wlan0 && ifup wlan0
- Reload drivers:
modprobe <name_of_device_driver>...
- Restart the network:
service networking restart
- Reorient the WiFi card antenna
- Change the wireless iterface MTU: e.g.
ifconfig wlan0 mtu 1472
- Disable the card power-saving ability
- Adjust your access point transmission power, preferred channel number, bandwidth, ... in the router UI.
- If you use a repeater (aka range-extender), turn it off, wait, turn it on again
As there are so many knobs you can turn and experiment with, the most critical thing, is to be able to see the immediate effect of any change on the continuously updating screens. If it makes no difference (most cases, in my experience), just note it down, and revert to the previous state. But if you suddenly see the Loss%
rates jump up in mtr
, or the signal strength sharply drop (or conversely, jump way up) in iwlist
, you know you've found a smoking gun (or the fix).
Again, the #1 take-away from all of this is: Rapid experimentation is the key to be able to quickly diagnose WiFi issues