[ltp] Speeding up wifi reconnect with Network Manager on wake up

Rubin Abdi linux-thinkpad@linux-thinkpad.org
Thu, 08 Nov 2012 11:41:24 -0800


This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
------enig2AUTTBPOJJKHKGLDTCDSP
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

When I was using a Mac full time a few years ago I was a bit bewildered
by how quickly the machine could deal with sleep, wake up, and wifi
reconnect. As it turns out Apple executes a lot of sneaky tricks in
order to speed up the process.

http://cafbit.com/entry/rapid_dhcp_or_how_do

Namely poking the last three wifi networks the machine has connected to
first before attempting an AP scan, and remember the last DHCP lease
used on said network and continuing to use that information before DHCP
responds back with a fresh new lease. Some will argue such tricks aren't
healthy, others will gladly accept them because they do make things faste=
r.

I'm running Debian Sid on on a ThinkPad X220 with an Intel Centrino
Advanced-N 6205 wifi card. For a while I had been using Wicd (on XFCE)
due to it's speediness at reconnecting wifi connections after coming out
of sleep, the fact that it could deal with my unicode SSIDs, and it's
ability to remember passwords but not to automatically reconnect to
those networks.

Recently I've had a taste of KDE and am happy to say that I'm now in bed
with the dark side. With that I'm back on Network Manager now, it does
the remember password but don't autoconnect thing, also a nice OpenVPN
interface and it can deal with USB tether off of my Android.

A big issue I was having still with Network Manager however was simply
that after waking up from sleep it would take up to 60 seconds for my
machine to reconnect to wifi. After some googling and staring at logs I
realized that NM is waiting a set number of seconds after wake before
doing any sort of reconnection business. I tried hurrying that up by
simply ifconfig wlan0 up which did bring up the wifi LED sooner than
later, but NM was still waiting for something.

Eventually I realized all one needs to do is to tickle NM itself on wake
and it'll take care of the rest. I imagine the general delay is possibly
compensating for other network wifi cards taking their sweet time waking
back up, but that doesn't seem to be the case for this card in my
ThinkPad. Effectively I've gone from wifi taking 30-60 seconds to
reconnect after wake up to about 5-10 seconds.

If you would like to try the same, dump this into
/etc/pm/sleep.d/wifi.hook and chmod 755 that thing...


#!/bin/sh
case "$1" in
	resume|thaw)
		nmcli nm sleep false
	;;
esac


If that doesn't work try throwing a sleep in before the nmcli command,
otherwise your millage may vary. All in all no DHCP tricks, but I
honestly don't see any reason why NM needs to take so long to start up.
Hope this helps out any of you that have also been frustrated by slow 0
to 60/mph times after wake up.

--=20
Rubin
rubin@starset.net


------enig2AUTTBPOJJKHKGLDTCDSP
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.12 (GNU/Linux)

iQEcBAEBAgAGBQJQnArkAAoJENiO8GEa75D0oPYH/14xWDEA4HftIIPrU1jZ60AW
s8ZNguj25ZxzMitFDH6GGTaOFA54OLv1yN0LepAjaxmHHzGiPDK+/4A69UW2J5Fn
vc7OigNcUHR0LiLXhnQfB2m+l1KomsLNgHHGFIP2rBgYr2r5TH0zfqABjI2Bunj8
U9qzALf6XP4owrfr4DHPt2nZB0L6yuwtRicS07XG6vaUU/CUqMOdZ2qhWBEA6VLO
07qBXnbzv3+qquvZ05pdSU/YTJoX5EwIY9h5lD9wTKiiJ7RlnOjWAjn4t2FZYFJS
FqTnpahF4NlkYVTcyE4H8vr2eqWsK3VFJAO8VEqwEOrKyBPf00DzAAmtphmtlXo=
=SRCa
-----END PGP SIGNATURE-----

------enig2AUTTBPOJJKHKGLDTCDSP--