Blog

Mobile Mesh Networks with the Raspberry Pi – Part 1

Raspberry Pi, fresh from the oven.

The Raspberry Pi has become the darling child of computer hobbyists everywhere. With prices ranging from $20-35, it’s hard to resist purchasing one and taking it for a spin.

Designed as a teaching aid for Computer Science courses, this computer — no bigger than a playing card — has many other applications. Media server, web server, Ethernet shield — if your computer could do something eight years ago odds are this machine can do it too. The Model B version has two USB ports, HDMI, component, and an audio out port,  as well as an SD card slot and an Ethernet jack. It has 256 MB of RAM, which is more than enough to run headless software.

I thought it might be fun to put a few Pi’s together and and try to create a mesh network that can be rapidly deployed and powered by battery. The following posts will be a build log of my experience; my instructions are not intended for the beginner, but should provide enough detail for an experienced linux user to get a mesh network up and running.

Hardware

You need more than just a board to create a mesh network. I also purchased:

The total cost was approximately $58.

 Software

After some Googling around I found a few potential candidates for the software. There weren’t any clear build instructions for computers, but there were several options for wireless routers. I opted to go with the Pi instead because it would have more  power and flexibility for future projects. Here is some of the software I will be experimenting with:

  • Smesh
  • BATMAN ADV
  • Babel
  • Project Byzantium (This project looked most promising — especially the fact that you can connect to the mesh network and connect to the same node using a single wifi card. However, the list of software they use and their configurations are not readily available.)
  • CoovaChilli (DNS Redirect to capture traffic and drive it to an internal website.)

First Steps

There have been some issues reported regarding the power output of the Pi USB ports, so I wasn’t sure if I would be able to make a quick and dirty mobile mesh network in the first place. But before I could find out, I had to install an operating  system on the board. I chose Arch Linux because it was easy to configure and contained a minimal amount of software packages.

Fortunately, the stock Arch image was very easy to setup, and comes with sshd running. Here are the steps to get the base system running; it is not yet clear how the shift to systemd will work on ARM architecture:

  1. Install the Arch Image to the Pi SD Card: # dd bs=1M if=img of=dev
  2. Grow the partition to use the entire SD card using Gparted or a similar tool.
  3. Boot up the system, and ssh in. Run # pacman -Syu and update pacman.
  4. Because you are ssh’ing in, you need to generate entropy when you create the pacman PGP key. Install haveged, and generate the key: # pacman -S haveged && haveged -w 1024 && pacman-key --init && pkill haveged && pacman -Rs haveged
  5. Install some useful packages: # pacman -S dialog wireless_tools netcfg NOTE: You may need to reboot in order for the usb wifi dongle to show up in iwconfig.
  6. Edit rc.conf to your liking: # nano /etc/rc.conf
  7. If you wish to setup a web server on the Pi, follow the instructions here.

Some basic stats on the Pi.

The first steps were quite successful; I got a full web server up and running with mysqld in under 80MB RAM and a rootfs under 800 MB. What is more, the wifi dongle was recognized out of the box, and was fully powered by the board! In my next post, I will begin installing mesh networking software onto the Pi, and post my build instructions and configurations.

 

See Also

Part 2

Part 3

Part 4

This Post Has 19 Comments

  1. IceQUICK says:

    Thank you for putting this together. We just talked about the Raspberry Pis (Pies?) at our last meeting and this was brought up as a potential use. I’ll forward this series out to our local members.

  2. Jan says:

    According to the german Freifunk initiative BATMANADV causes way too much traffic. Even worse: there more mesh servers or clients there is an exponential increase in useless traffic.

    Have you tried OSLR? It is said to have a way better performance.
    http://www.olsr.org/

      • Deref says:

        What do you mean by “Debian in particular did not agree with BATMAN”? How can a distribution agree or disagree with a protocol? Btw. I’ve checked it and they ship batman-adv with their official kernel since nearly 2 years. And before this time it was a separate package which build a kernel module against their official kernel

        • Eric Erfanian says:

          If I recall correctly the kernel module didn’t play nicely out of the box — devices wouldn’t register and I couldn’t get the control system working.

          It could have been something simple that I was overlooking, but it didn’t fly for me.

          I think I had the issue both on Arch and Debian with BATMAN. At any rate, I stuck with Arch because the package management was faster.

          • Deref says:

            Can you be more specific? What is the control system? batctl? batctl is also a package on debian and works out of the box. Just installed “apt-get install batctl”, loaded the module “modprobe batman-adv”, added a device `batctl if add wlan0`, set an ip for the bat0 device and make it up “ifconfig bat0 192.168.0.1 up”. Done and working here.

      • samacumen says:

        Hi Eric,

        Could you let me know how to make OLSR work on RaspBerry PI. I want to use it on my ArduCopter (UAV) by adapting it to ad-hoc network. Thanks a lot.

        • Eric Erfanian says:

          I no longer have the hardware, so I’d be unable to test the software –sorry. If you figure it out you should link your instructions here so others can find out how to do it.

    • Marek says:

      Do you have a link regarding the traffic overhead caused by batman-adv ? I’d like to read more about that.

    • Deref says:

      Do you have some proof for your statements? Because some Freifunk communities use batman-adv as their protocol of choice instead of OLSR/batmand/babeld/802.11s/…

    • dasbjo says:

      Different routing protocols work better in specific situations than other routing protocols. This is widely known. But this “exponential” behaviour about the routing overhead of batman-adv is FUD and has no theoretical or practical basis.

      And recommending OLSR as a better alternative is also really vague. No one should recommend standard OLSR without mentioning the shortcomings of it ( http://lists.alioth.debian.org/pipermail/babel-users/2009-November/000339.html ). So at least tell them about the configuration problem (the standard configuration doesn’t provide a stable routing scheme).

      You can come to the Wireless Battle of the Mesh v6 ( http://battlemesh.org/ ) next year and discuss this with the developers of the major open source protocols.

      And as additional information: I had batman-adv running under debian with raspberry pi and pandaboard without any problems. I also had no problem with batmand, babeld, olsrd… but with open802.11s

  3. JT says:

    Hi,
    How do you broadcast a message in a Mesh network?
    In terms routing from a particular node to another, all those happened transparently without the user’s interactions and awareness?

  4. inlays56 says:

    Dear all,

    I try to perform steps number 4 & 5 after done with step no 3. Below are the issue when perform the step

    [root@alarmpi ~]# pacman -S dialog wireless_tools netcfg
    error: failed to init transaction (unable to lock database)
    error: could not lock database: Read-only file system

    I try to search in goggle and most of them advice to remove the file as below

    rm /var/lib/pacman/db.lck

    The problem is there is no db.lck under pacman. Please advice

    Thanks

Leave A Reply