Fr-eee-dom: roaming on the bus with wpa_supplicant

As I wrote earlier, I bought an Eee PC to use on the bus. Initially, I only used it offline to do some Debian packaging and blogging, but I soon discovered that I could do a few things online on the many open networks on my daily commute. While the connections are normally brief in good traffic conditions, even a few seconds here and there is enough to participate in irc discussions.

Manually connecting to each got old very quickly. So, to automate those connections I settled on wpa_supplicant, (wpasupplicant is the Debian package name,) which is quite easy to set up in roaming mode, as outlined in /usr/share/doc/wpasupplicant/README.modes.gz. All you need is the following in /etc/network/interfaces:

allow-hotplug ath0
iface ath0 inet manual
        wpa-driver wext
        wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf
iface default inet dhcp

Then create your /etc/wpa_supplicant/wpa_supplicant.conf as follows:

ctrl_interface=/var/run/wpa_supplicant
network={
     key_mgmt=NONE
}

That’s it. You can now roam from one open network to the next and the supplicant will connect you to each one in turn. I have used this to reconnect to my screen session each time the bus slows down for a stop or gets stuck in traffic to carry on conversations on irc for the whole length of the commute.

If you also connect to networks requiring authentication, you’ll need to add a “network” clause for each network. See /usr/share/doc/wpasupplicant/examples/ for help with that, particularly the annotated conf file, README.wpa_supplicant.conf.gz.

For finer control over the process, I use sudo wpa_cli so i can:

  • keep an eye on what networks are around: scan, then scan_results,
  • disconnect from a network once I know it’s out of range
  • and reassociate as needed.

The only things that I haven’t figured out how to do yet are to make the process of switching from one network to the next a bit faster (it normally takes about a minute; precious seconds of online time are lost when the bus is in motion,) and to blacklist certain essids, e.g. commercial hotspots that make you pay before they’ll route your packets to the Internet. For the first problem, I have already tweaked my dhcp settings, which helps a bit. For the second, I tried adding network blocks for specific networks and setting them to a lower priority, but that doesn’t work because then the ‘catch all’ open network block kicks in and picks them up anyway.

3 Replies to “Fr-eee-dom: roaming on the bus with wpa_supplicant”

  1. More than one person pointed out I should use wext, not madwifi, so I have changed that in my own configuration and edited the instructions above. I’ll see the next time I’m out on a bus if that helps me connect any quicker. Also, Kel Modderman says that in a future version (e.g. the one in svn) I should be able to do away with sudo and use the netdev group instead to use wpa_cli to connect to the supplicant.

  2. The big delay in re-association maybe the DHCP acquistion… I currently use a modified config that takes the timeouts down to the minimum (so request retransmits happen within 1second).

    dhcpd was designed with reliable but slow-to-answer networks in mind… whereas most of the networks you’re using are very high-speed with the DHCP server only 1 hop away. with 50% packet loss you need to send ~8 initial packets to get through the three way DHCP handshake. Aswell as modifying dhcpd to go bang-bang-bang-(x8)… at 100ms intervals you really need a way to starting using addresses before renewal ( eg. the same lease you got yesterday even if it theoretically ran out 23hours ago.

    You could also try run something the equivalent of NSTX, but, ignoring the DNS encapsulation any success “poll” from client to your server, will result in a reply of any pending data. It should be possible to do the entire scan-associate-fa{ke,st}DHCP-poll-reply transaction in under 1 second, but probably not with the software as it stands at the moment. (Open networks only, the WPA setup is too long).

    Also, hack the client and server (netfilter level) to send each packet twice… this should help count dropped packets.
    Happy tinkering!

  3. Thanks for the help in IRC today.

    Here’s what we learned along the way:
    If you’re having trouble getting it to work, you can run wpa_supplicant by itself `sudo wpa_supplicant -iath0 -c/etc/wpa_supplicant/wpa_supplicant.conf -Dwext` This will give you error output so you can diagnose.

    The config can’t be rewritten in one line as network={ key_mgmt=NONE } all whitespace is not equal.

    Installing wpagui is a good idea if you want a more standard interface to your network connection, it’s as good as Gnome’s network manager IMO. By default, the font is slightly too big and the ‘add network’ screen gets cut off. You’ll need to adjust the font using ‘sudo qtconfig’, at 8pt it’s a perfect fit.

Comments are closed.