Wifi roaming on the move redux

It has been nearly six years with a netbook and five since I last wrote about wifi roaming from the bus to stay on irc without a costly celluar link during the daily commute.  Since then, some readers have asked me to share my refinements to the method in a followup post. So here it is.

The software

On the server:

  • openssh-server
  • screen
  • irssi

On the client:

  • screen
  • wpasupplicant
  • isc-dhcp-client
  • openssh-client
  • openbox
  • sudo & gksudo (optional)
  • urxvt
  • wavemon (optional)
  • three shell scripts (provided below)

Putting it together: on the client

Make sure if you have a wireless manager installed (such as NetworkManager) it is configured to skip your wireless interface, disabled entirely, or if possible, removed. Set up /etc/wpa_supplicant/wpa_supplicant.conf and /etc/network/interfaces for roaming, as per the instructions in /usr/share/doc/wpasupplicant/README.modes.gz. Don’t forget to add yourself to the netdev group if you are not in it already.

In /etc/wpa_supplicant/wpa_supplicant.conf, list common names of open networks. Normally the catch-all network that associates with any essid, i.e. the first stanza below, works well. However, occasionally the strongest signal is neither one of the common networks nor an easily accessible network (e.g. web portals), so having a list of common open networks helps to quickly select from among those instead. The more you travel, the more of these will discover and add. Just use reconfigure from wpa_cli to reload your edited list each time you add a new one.

ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
network={
        key_mgmt=NONE
}
network={
        ssid="default"
        key_mgmt=NONE
}
network={
        ssid="linksys"
        key_mgmt=NONE
}
...

Since you’ll be using ssh repeatedly to connect and it has to be fast, make sure your server is set up to accept your key and use ssh-add so that you only have to enter your ssh key password once.

You can tweak isc-dhcp-client to make connections faster. In /etc/dhcp/dhclient.conf, use:

backoff-cutoff 1;
initial-interval 1;

Here are a few scripts I wrote to facilitate quick roaming from one open AP to another and reconnect to irssi running in screen, to break a connection and try the next one, and to recover from occasional lockups (more about that later).

~/bin/screen_reconnect

This is a script to reconnect continuously via ssh to a screen session:

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

Just substitute the IP of your own server here. Using an IP instead of domain name makes the connection faster because a DNS lookup is not required.

~/bin/wifi_reassociate

This script closes any open ssh sessions and informs wpa_supplicant to attempt to connect again.

#/bin/sh
/sbin/wpa_cli rea
killall ssh >/dev/null 2>&1

~/bin/wifi_killall

This optional, somewhat ugly script addresses an issue I hope you never have. On my ASUS Eee PC 1001PX, occasionally scanning stops. When this happens, and I have never figured out why, apparently ACPI events are blocked. At this point wifi becomes unusable and ACPI sleep is inhibited. By trial and error I found that if you bring down the interface, kill all network-related processes, and bring it up again, ACPI events are unblocked and wifi is usable once more (and any pending request to sleep will finally happen). The script requires sudo, and to use the openbox key binding, gksudo.

#/bin/sh
sudo ifdown wlan0
# in case any of these are hung
sudo killall dhclient3
sudo killall wpa_cli
sudo killall wpa_action
sudo killall wpa_supplicant
# in case any of these are *really* hung
sleep 1
sudo killall -9 dhclient3
sudo killall -9 wpa_cli
sudo killall -9 wpa_action
sudo killall -9 wpa_supplicant
sudo dhclient -r
sudo ifup wlan0

Openbox

Since certain actions need to be performed repeatedly and quickly, it is useful to have hotkeys bound in your window manager to the scripts. In ~/.config/openbox/rc.xml, key bindings for <alt>-r to reassociate and <alt>-d to disconnect a hung connection would look like:

  
<keyboard>
  <!-- My keybindings -->
  <keybind key="A-R">
    <action name="Execute">
        <execute>/home/synrg/bin/wifi_reassociate</execute>
    </action>
  </keybind>
  <keybind key="A-D">
    <action name="Execute">
        <execute>gksudo /home/synrg/bin/wifi_killall</execute>
    </action>
  </keybind>
</keyboard>

Putting it together: on the server

There is very little to do here. Just start screen, and start irssi in screen. Running screen on the client as well as the server means you should either bind the screen meta keys to a different key sequence on each system, or else learn to press meta twice to pass through meta to the server screen as needed. I use the latter approach. Alternatively, you could use a tabbed terminal on the client, or separate terminals per client process instead of screen. This is a matter of personal taste.

Ready to roam

Here is a typical setup for roaming on the bus:

In a terminal (I use urxvt), first ssh-add, then start screen with these three processes running in separate virtual terminals:

  • /sbin/wpa_cli
  • screen_reconnect
  • wavemon (optional)

March of the dots

Most of the commute, just enjoy watching the dots march by, waiting for a new connection. If you estimate a connection is unusable, press <alt>-r to reassociate immediately, giving the next network a chance. If the connection is already firmly established, this might not work on the first try. If the dots don’t resume immediately, wait a bit and press it again. This might take a few tries.

Changing selected networks on the fly

Use wpa_cli when you need to do some fine-tuning of network selections on the fly. While normally you can just watch the march of the dots until a connection is acquired, sometimes you can improve your chances of connecting to a good network by manually controlling the selected candidate networks here.

For example, by watching the speed of the bus relative to known “good” APs, you can predict which networks are more likely to succeed. Rather than connect to any arbitrary network, you might select a specific one by id, and then later when it goes out of range, revert to the original configuration, e.g.

> select_network 5
...
> reconfigure

You can use tab-completion in wpa_cli to type these commands quickly or else just abbreviate the commands.

Another common scenario is when you pass through a business area with many captive portal hotspots. These rarely make good choices because they either require a password not known to you or else you can’t click through “I agree” in time before the bus moves on. In this case, you might just disable the catch-all stanza and let the common open network stanzas you listed (“default”, “linksys”, etc.) do the work:

> disable_network 1

Become a type ahead wizard

While running, a continuous stream of periods fills the screen, which provides you with a highly visible cue that no available APs are in range. When the movement stops, you know a connection is being attempted.

While waiting to connect, you can type ahead any comments you want to make in the current irssi window (taking care to remember which one you are in!) While having periods interspersed in what you type may be disorienting at first, you get used to it.

There is a point when a connection is first established and ssh is accepting input, but anything you type can no longer be seen while you’re typing. Depending on whether the connection was completely successful or not, what you type now may or may not finally be sent. For best results, only type ahead before the dots stop moving.

Eventually you can become skilled enough at this to type ahead a comment in one channel, switch channels with /win # and continue typing ahead in the new channel, all buffered until the next few seconds (or even fraction of a second) of connection time.

Fine-tune antenna direction with wavemon

When the bus has come to a standstill, you may find wavemon useful to pull in a weak signal. Because wavemon has continuously updated signal level and link quality bars, you can use it to fine-tune the antenna position. Just turn your laptop until the bars are at their maximum.

Captive portals

I have not figured out how to do any automation for this, so it really is a crapshoot, as it is likely the bus has moved on by the time you’ve managed to manually navigate the login through a captive portal. But in rush hour, you may have the luxury of time to connect to these as you pass them. I have recently learned about the CoovaFX Firefox plugin which automates logins to captive portals. I’m going to give it a try to see if it helps. Update: I can’t recommend this plugin, as it is not compatible with Iceweasel >= 23.0. Also, the standard it is based on, WISPr, appears to have an uncertain future. That, coupled with the fact that the plugin appears to not be open source means I’m still looking for alternatives.

Summary

If all of this sounds a bit nuts to you, well, it probably is. But after half a decade enjoying free access to irc from the bus, it all seems perfectly natural to me! If you try this method and like it, please let me know in the comments. Likewise, if you have any improvements to the process or scripts, please share them!

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Bits from the Eee PC team, Spring 2009

Lenny well supported

We’re pleased that Lenny released with good support for the Eee PC and are now turning our efforts to make Squeeze even better, while continuing to provide support for our Lenny user base.  The standard Lenny installer can install Debian on all models of Eee and our custom installer provides the ability to install over wireless for almost every model (more about this later) from a very small image.  The latter continues to be our recommended install method, since in addition to being wireless-ready, the custom installer also handles a few other small eee-specific configuration chores to make as much as possible “just work” right after the install.

Solid mainstream support

We’ve made good on our promise to make Debian work on the Eee PC, not a derivative, many of which use a custom kernel instead of the stock kernel as we do and use a special desktop instead of our users’ favourites.  While we agree that some intriguing things can be done in these areas, it is no substitute for mainstream support.  Our users are better served by a solid foundation than specialised modifications that limit their choices.  We want them to be able to enjoy the freedom to mold Debian, the universal OS, into whatever suits them best.

Squeeze support started

Work is well underway on supporting all Eee models in Squeeze.  For months, several team members have been experimenting with new kernels, producing support for them in eeepc-acpi-scripts.  The current release of this key package (version 1.1.0) supports Linux 2.6.29 and contains enhancements for wifi, sound hotkeys, bluetooth, external displays and OSD.

Squeeze will support wired & wifi on all current models

With the appearance of 2.6.29 in Sid, all ethernet and wifi cards used in all models of Eee today are supportable without the need for out-of-kernel or non-free drivers.  Madwifi is replaced by the free ath5k driver, the non-free rt2860 package is replaced by mainstream kernel support, (though it still requires non-free firmware provided separately by firmware-linux — for now in 2.6.29, the firmware is included in the kernel, but that is a bug fixed in 2.6.30,) rtl8187se is included, making it possible now for us to support the model 701SD, and ath9k is included, making full support for newer models such as the 1000HE possible.

Lenny backports and live demo

All of these changes can be enjoyed today by Lenny users.  Just add Daniel Baumann’s Lenny kernel backport repository and then install the 2.6.29 kernel and an updated acpid.  See our upgrade howto for details.  You can try a small (less than 256M) demo of this configuration by downloading beta 2 of our Live USB image.

Accessibility

Late last year, we discussed how to make it easier for the blind to install Debian unassisted on their Eee PCs.  As it was a simple change, we now include brltty in the custom installer, but we understand that some users also need software synthesized text-to-speech, something for which there is no support yet in the standard Debian-installer.  We understand this isn’t an easy thing to fix, but hope someone will rise to the challenge.

Growing team of developers

We welcome Darren Salt and Raphael Geissert to the team this year.  Both have been actively making contributions to the eeepc-acpi-scripts package over the past months, fixing some outstanding bugs and readying it to handle changes in more recent kernel releases.

Moved eeepc.debian.net to new hosting

Nico Golde, who hosted eeepc.debian.net for the first year development, has turned his focus to other areas of Debian.  Glenn Saberton has stepped in to provide a new home for it.  We thank them both for their efforts and for a smooth, uneventful transition from one host to the other.

Size of user community

Speaking of the move, earlier this year, Glenn shared with us some interesting archive traffic statistics that give us a rough idea how many users we have.  For the months of December and January, after factoring out bot hits, we were seeing about 300,000 hits from 15,000 unique users per month.  The site handles roughly 60G of traffic per month, most of that from thousands of downloads of our custom installer image.  It’s hard to draw any firm conclusions about the size of our user base from these stats, as many users may be on dynamic IP numbers, inflating the numbers, but we can conservatively say we have at least 5000 users.  Other interesting statistics are that we have anywhere up to 80 users at any given time on our irc channel and over 250 users on the mailing list.

Help wanted

The Asus Eee PC line continues to expand, with 24 models listed so far.  It is a challenge to keep up support for all of them.  We’re encouraged to see Asus choose a new b/g/n wifi chipset for their 1002HA that is supported by a DFSG free driver — ath9k in this case.  It appears that the new Atom N280-based 1000HE uses the same chipset as well (though be careful: I know of at least one user who bought a 1000HE in Argentina expecting it to have this chipset and was disappointed to find it had the Ralink chipset instead, we guess because of availability).  If this trend continues, we’ll be that much closer to our goal of full support for Squeeze main.  As it stands, we’re already as close as we can get given the state of rt2860 and no prospect on the horizon for replacing the non-free firmware.

If you would like to help us out in any way, whether by testing, debugging, patching, or improving our documentation, get in touch with our team.  We rely on your feedback to keep Lenny in good shape and work towards making Squeeze even better for all users of Debian on the Eee PC.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

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

Bits from the Debian Eee PC team, autumn 2008

Some brief highlights of the last three months of Debian Eee PC development.

Thermal and ACPI breakage resolved in 2.6.26-7

We’re pleased to see that in the upload to Sid of linux-image-2.6.26-1-686 version 2.6.26-7, the pair of 2.6.26 bugs we’ve been tracking that have made it difficult for Eee users to upgrade their systems have been resolved. Since then 2.6.26-8 has been uploaded and is expected to enter Lenny this week due to a freeze exception. Once the new kernel has migrated we will move quickly to build and release a new installer that includes it.

Ath5k wifi works on Eee PC in Linux 2.6.27

Jean-Christophe reports that ath5k works in Linux 2.6.27 on the Eee PC 701, and just needs a small patch to work with our eeepc-acpi-scripts package. This is good news for those of us with models 701, 900, 900A and 1000HD who have been wanting to get off of the non-free Madwifi drivers and onto DFSG free drivers.

New Eee PC model 701SD wifi support in the works

Users of the new Eee PC Model 701SD have just started showing up looking for support in mainstream Linux distros. Martin Filtenborg confirmed using our Eee PC Live image with the GPL’d rtl8187se driver from Realtek that we can at least use it to connect to an unencrypted AP, get an IP address and ping other hosts.

Of course, it is one thing to have a working vendor-supplied driver and quite another to have mainstream support. We’ll make do with what we have now, but will be seeking a mainstream solution as soon as possible.

We’re seeking more testers and developers to work on this. To date, an ITP has not been filed, as it is not yet clear who is going to carry this work forward.

Chasing the 5 second boot

An interesting discussion on Arjan van de Ven and
Auke Kok’s work to get an Eee 901 to boot in 5 seconds
took place this month. While the Debian Eee PC team is not making work on this a priority, we’ll keep an eye on it to see if Debian can incorporate some or all of the techniques they used so that our users can benefit without making radical changes to their systems.

Working towards mainstream support for rt2860

Our filing of an ITP for rt2860 (the wifi driver for models 901, 1000 and 1000H) was followed by discussion about how to separate out the GPL’d driver from the embedded non-free firmware so that it can at least go into contrib. Glenn Saberton has been working on rewriting the build system around kbuild and separating out the firmware.

Numerous improvements to ACPI scripts

Since my last progress report, there have been numerous improvements to the eeepc-acpi-scripts package to deal with all of the various models we now support and make the scripts more robust and flexible. Check out the changelog for details.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

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.

Facebooktwittergoogle_plusredditpinterestlinkedinmail

Debian-eeepc now has atl2 ethernet

With Kel Modderman’s help, we now have a working atl2 driver for the Eee PC. This brings the Debian-eeepc project one step closer to providing a pure Debian replacement for the Xandros OS that ships with the unit. Now that Asus has released the GPLed source that was missing before, we now just have to ensure both the atl2 and asus_acpi modules get merged upstream.

The driver for the wifi in the Eee isn’t under the GPL, however, and therefore only works on the Xandros kernel provided with the default OS. Since I really can’t live without wifi and it is not my first choice to buy replacement hardware, in the interim, I’m living with using the Xandros kernel and modules on Debian. I can learn from studying the Xandros components in action, but it’s not a solution I’m happy with in the long term. The Debian-eeepc project’s goal is to produce a pure Debian solution, at least as far as that is possible given the hardware present in an unmodified system. On that front, I think the best bet is for ath5k to support the particular Atheros chip in the Eee. (Yes, I know about ndiswrapper, but for both technical and philosophical reasons I won’t use it.)

Facebooktwittergoogle_plusredditpinterestlinkedinmail