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
mtr. Here's how to use them most 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.
Assuming the ESSID is known and the quality is good (say about 30%-100% of the maximum) you may move to the second 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 miliseconds) columns:
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
If you dont have
mtr installed, try:
sudo apt-get install mtr.
I find these two tools particularly valuable because I can quickly change configuration, for example:
/etc/network/interfaces and then
ifdown wlan0 && ifup wlan0
- Reload drivers:
- Restart the network:
service networking restart
- Reorient the WiFi card antenna
- Change the wireless iterface MTU:
ifconfig wlan0 mtu 1472
- Disable the card power-saving ability
- Adjust my access point transmission power, preferred channel number, bandwidth, ...
- Turn my repeater off, wait, turn it on again
etc. etc. and immediately see the effect of my change in the continuously updating screens. Since there are so may knobs you can experiment with, the most critical thing is to be able to see the immediate effect of the change. If it makes no difference (most cases in my experience), just note it down, and revert to the previous value. But if you suddenly see the
Loss% rates jump up, or the signal strength sharply drop, you know you've found a smoking gun.
Rapid experimentation is the key to be able to quickly diagnose issues