I use smartphone Wi-Fi tethering every day to connect my notebook to the Internet. This mostly works out of the box. There are, however a tiny number of smartphones with which I have problems While the notebook connects just fine, ping times are very long and erratic as shown in the screenshot on the left and there's almost no data throughput. I took me a long time to figure out what the issue was but at some point I realized that I only had the problems with a few particular devices when my notebook was not connected to the charger. Ah, may of you might say now, then it has something to do with power saving modes!
And indeed it has. Per default, Ubuntu activates power save mode in the Wi-Fi chip when running on battery and deactivates it as soon as the notebook is connected to the mains again. While power save mode slightly increases ping times it otherwise has no negative effects with 99% of the smartphones I try, except for the few it wreaks total havoc on.
Fortunately, there's a simple way to disable power save mode. A simple "sudo iwconfig wlan0 power off" from a shell instantly fixes the problem. The "iwconfig" command without any parameters then shows that power save mode was switched off desite running on battery:
wlan2 IEEE 802.11bgn ESSID:"martins-i-spot"
Mode:Managed Frequency:2.462 GHz Access Point: xx:xx
Bit Rate=57.8 Mb/s Tx-Power=16 dBm
Retry long limit:7 RTS thr:off Fragment thr:off
Link Quality=70/70 Signal level=-38 dBm
Rx invalid nwid:0 Rx invalid crypt:0 Rx invalid frag:0
Tx excessive retries:0 Invalid misc:90 Missed beacon:0
While this is a good short term fix, Wi-Fi power management is activated again after rebooting or after sleep mode. To permanently disable Wi-Fi power save mode, a script that contains the command can be added in the power management configuration directory:
sudo touch wireless
sudo chmod 755 wireless
sudo nano wireless
And then paste the following two lines inside:
/sbin/iwconfig wlan0 power off
That's it. Just one more thing perhaps: Use "ifconfig" to check if your Wi-Fi adapter is "wlan0" or if the OS has at some point assigned another name to it and adapt the command accordingly.