Always wondered about mesh networking, but afraid to try? The lads at Freifunk have made it easy for all of us.
The Freifunk Firmware (FFF) is a friendly repackaging of the OpenWRT embedded Linux [Hack #67] for the Linksys WRT54G and some other wireless routers. It offers a nice web admin interface that is easily customizable with your own templates and opens SSH, not Telnet, by default.
Most interestingly, the FFF allows you to easily enable Freifunk's implementation of OLSR mesh networking. If your node can get a signal from another OLSR node, appropriately configured, they will agree to carry traffic for each other and for other nodes on the mesh. If one node has a connection to the Internet, Net traffic will go through it transparently. This makes it easy to purchase a lot of bandwidth collectively, and then distribute it throughout a wide cloud of meshed nodes.
5.7.1. Getting the Firmware
To download the Freifunk Firmware, visit http://ff-firmware.sourceforge.net, or go straight to Sven-Ola's (the maintainer) package directory: http://styx.commando.de/sven-ola/ipkg.
You want the file labeled g/openwrt-freifunk-language-version number.bin, with your language of choice (en, de, etc.) and the latest version number. If your WRT is a 54GS or GS, look for the appropriate directory.
5.7.2. Uploading the Firmware
See "Upgrade Your Wireless Router" [Hack #67] for information on how to flash a WRT with a new firmware. If you have an untouched Linksys WRT unit, it has a web admin interface to which you can upload the .bin file; otherwise, you might have to upload it using TFTP.
Once you've flashed the WRT with the new firmware and rebooted, you should see an admin interface that looks something like Figure 5-3.
5.7.3. Getting Meshed Up
Clicking the Admin link leads you to a set of interesting configuration options. The Freifunk Firmware almost comes ready to mesh out of the box.
Figure 5-3. Freifunk Firmware web admin GUI
You must make sure to assign a different, non-conflicting IP address to each of the routers that you're going to mesh. By default, each new Linksys WRT comes configured as 192.168.1.1. Many people prefer to allocate a chunk of the 10.*.*.* space instead. It should be noted that both of these IP address ranges follow the Internet RFC 1918, which defines private IP addresses that are not routable on the Internet.
In the Admin Wireless menu, you can pick an IP range and address for your new node. Set the ESSID here as well, and to enable OLSR meshing, put the WRT into Ad-hoc Mode and save the new settings. After changing the IP address, you can restart the WRT either via the web admin GUI or simply by powercycling the device, and the changes should take effect. If youre changing the default IP address, you should powercycle the box anyway. Figure 5-4 shows the settings on the test mesh.
The Admin WAN screen lets you set your connection to the outside world. If one of the nodes in your mesh has a connection to the Internet, all the others will route through it. Plug an Ethernet cable into the back of the node thats going to act as an Internet gateway, and set it via the WAN screen either to a static IP address or to obtain an IP address via DHCP.
Figure 5-4. Configuring the Admin images/U2192.jpg border=0> Wireless screen
The Freifunk Firmware will mesh via OLSR out of the box, once you've configured your OLSR settings as described previously. The Admin OLSR screen lets you limit the nodes that can connect to this network. Up to a limit, though, the more mesh nodes, the merrier. One option you should set here is OLSR DHCP. This indicates an IP address range that the node will offer, via DHCP, to non-OLSR devices that try to connect to it. Its optional, but in the interests of open connectivity, enable it on each node in your mesh. Make sure the DHCP IP range is different from the range you're using for your main mesh network, though.
5.7.4. Rinse and Repeat
Now, take a second WRT. It's best to unplug the first one, in case you accidentally associate with it, or talk to it through an Ethernet cable instead. Go through the same process.
In the Admin images/U2192.jpg border=0> Wireless dialog, set the IP of this node to be a different address in the same range (in the examples, I used 10.1.29.1 and 10.1.29.2). Set the ESSID to the same as the first WRT, because all the nodes in your mesh should have the same ESSID. Make sure the WRT is set to Ad-hoc Mode. Fix the OLSR DHCP settings as discussed previously.
Finally, reboot the WRT. Repeat this process on as many nodes as you want to add to your mesh.
5.7.5. Meshing Made Easy
Once you've configured all your mesh nodes, turn the whole lot off then on again. Using the Status interface in the web admin GUI, you can watch the nodes discover each other and create routes back towards the Internet.
Figure 5-5 shows the Status/Routes display on a mesh node. As you can see, the Internet gateway is 10.1.50.1, which is the wireless interface on the second router.
Figure 5-5. Node with Internet gateway showing OLSR routes
Adding new nodes to the mesh and watching them discover each other is lovely to see!
5.7.6. Troubleshooting the Firmware Upload
If your WRT is in a state where it won't appear to boot properly, it might give you some indications of trouble. For example, it might be hanging while the DMZ light shines constantly. Try putting the firmware into failsafe mode; power on the router, and then, just as the DMZ light starts to flash, hold down the Reset button on the back of the WRT with a small implement, such as a pen tip, for a few seconds.
This should cause the WRT to boot into failsafe mode, which should enable you to upload new firmware and connect to the device via Telnet. You should also be able to flash a new firmware to the device, using an Ethernet cable, your laptop, and a TFTP client such as atftp. When the WRT boots up, it waits for a three-second window in which it can expect to have a new firmware flashed onto it.
Here's a sample conversation between atftp and a WRT:
jo@frot:~$ atftp tftp> connect 192.168.1.1 tftp> mode octet tftp> timeout 1 tftp> trace tftp> put openwrt-g-freifunk-1.0.2-en.bin … [ lots of activity ensues ]
It might be that you have installed an OpenWRT-based firmware without an admin GUI and it boots immediately, without waiting for three seconds while the DMZ light flashes. The NVRAM, the writeable permanent memory of the WRT, needs to be told to boot_wait for a new firmware image via TFTP:
frot:/home/jo# telnet 192.168.1.1 [login screen exchanged; type in admin username and password.] @OpenWrt:/# nvram set boot_wait=on @OpenWrt:/# nvram commit
Next time you reboot, you should see the WRT waiting for a few seconds before the DMZ light starts to flash.
5.7.7. See Also
Bluetooth, Mobile Phones, and GPS
Network Discovery and Monitoring
Wireless Network Design
Appendix A. Wireless Standards
Appendix B. Wireless Hardware Guide