Wifi roaming on the move

Preface: legal stuff

Depending on where you live, use of random open wifi networks might be considered illegal. Although I know of no law in my country against doing this, where you live, things may be different, so educate yourself before following my example.

Wifi roaming on the move

For the past year I have used my Eee PC on the metro transit bus, as it is the perfect size for this. When I can, I take advantage of open networks to connect back home. In this article I will show how you can actually use such access, will recommend which software works best and will explain how to set it up.

So, what can I really do with the net while in motion?

How about irc? No kidding! This shell one-liner does the job:

while ! ssh -t 10.9.8.7 'screen -UDr' 2>/dev/null ; do echo -n "." ; sleep .1 ; done

We’re concerned about privacy and security on other people’s networks, so we use ssh. Inside that screen session, keep irssi running for a continuous irc presence. Every 10th of a second, the script tries to resume your session. Once a the net passes by, typing “[Enter]~.” drops you back out to retry again. The row of dots serves as a progress bar. If you want to get fancy, you could replace that with an ASCII ‘spinner’. I leave that as an exercise for the reader. 🙂

Come on, is that really usable?

Certainly. As the good folks on #eeepc at irc.freenode.net and #debian-eeepc at irc.oftc.net can attest, even a half dozen brief connections can be enough to provide tech support, rough out some development ideas, or just carry on some friendly chat. If your spouse or housemate is online too, it can even help you make some last-minute grocery-list changes. 🙂 While the script is working, enjoy some offline things such as blogging, reading a cached Planet Debian feed or a PDF book.

OK, so what else do I need to make it work?

Well, you’ve seen so far we need on a server:

  • openssh-server
  • screen
  • irssi

On the Eee, you should also have:

  • openssh-client
  • wpasupplicant
  • gnome-terminal

But what do I need wpasupplicant for if I only use open networks?

Well, wpasupplicant is really handy for fast control of networks in Roaming Mode (as per /usr/share/doc/wpasupplicant/README.modes.gz). A GUI is just too slow. For example, you may need to filter out ‘junk’ open wifi nets: pay-per-use hotspots or nets that hide their name. You’ll not only want a “catch-all” stanza for any open network, but also a number of the most commonly found default network names, e.g.

# Catch-all; associates with any open network:
network={
     key_mgmt=NONE
}
# Commonly found default network names:
network={
     ssid="default"
     key_mgmt=NONE
}
network={
     ssid="linksys"
     key_mgmt=NONE
}
# etc. by watching scan_results closely you'll find several more

While the connect script is running, keep a separate tab open in gnome-terminal for wpa_cli. Use ‘disable_network 0’ to drop the catch-all and let the other stanzas kick in and ‘enable_network 0’ after filtering is no longer needed.

Isn’t it really slow to get connected?

Without some tweaks, yes. But here are a few things I have found by trial and error that help.

One issue is that dhclient takes too long to retry, so you drop the delay between retries back to 1 second in /etc/dhcp3/dhclient.conf:

backoff-cutoff 1;
initial-interval 1;

If the signal is very weak, you’ll want the transmit power turned up to the maximum value for your hardware. For the Eee PC 4G this is 50mW, so you set this in /etc/network/interfaces for ath0, your wireless interface:

wireless-txpower 50mW

Finally, while you’re in motion you are constantly leaving no-longer-usable access points behind. The driver needs to discard them as quickly as possible and scan for new ones. So again in /etc/network/interfaces for ath0, you bring the default scanvalid 60 seconds down to 10 with:

pre-up /sbin/iwpriv ath0 scanvalid 10

Conclusion

The netbook has changed how we use the net. Now that we can take it everywhere, we either pay through the nose for expensive cell network access or else use the patchy wifi coverage blanketing most urban areas. A few lucky cities have such things as municipal wifi nets, but the rest of us have to scrape what access we can wherever we go. You are now equipped to try this out on the bus. If you find any other tips that can help, I’d love to hear from you.

Facebooktwittergoogle_plusredditpinterestlinkedinmail