]> pere.pagekite.me Git - homepage.git/blob - blog/data/2013-10-21-mesh-network-rpi.txt
Generated.
[homepage.git] / blog / data / 2013-10-21-mesh-network-rpi.txt
1 Title: A Raspberry Pi based batman-adv Mesh network node
2 Tags: english, nuug, freedombox, mesh network
3 Date: 2013-10-21 11:40
4
5 <p>The last few days I have been experimenting with
6 <a href="http://www.open-mesh.org/projects/batman-adv/wiki">the
7 batman-adv mesh technology</a>. I want to gain some experience to see
8 if it will fit <a href="https://wiki.debian.org/FreedomBox">the
9 Freedombox project</a>, and together with my neighbors try to build a
10 mesh network around the park where I live. Batman-adv is a layer 2
11 mesh system ("ethernet" in other words), where the mesh network appear
12 as if all the mesh clients are connected to the same switch.</p>
13
14 <p>My hardware of choice was the Linksys WRT54GL routers I had lying
15 around, but I've been unable to get them working with batman-adv. So
16 instead, I started playing with a
17 <a href="http://www.raspberrypi.org/">Raspberry Pi</a>, and tried to
18 get it working as a mesh node. My idea is to use it to create a mesh
19 node which function as a switch port, where everything connected to
20 the Raspberry Pi ethernet plug is connected (bridged) to the mesh
21 network. This allow me to hook a wifi base station like the Linksys
22 WRT54GL to the mesh by plugging it into a Raspberry Pi, and allow
23 non-mesh clients to hook up to the mesh. This in turn is useful for
24 Android phones using <a href="http://servalproject.org/">the Serval
25 Project</a> voip client, allowing every one around the playground to
26 phone and message each other for free. The reason is that Android
27 phones do not see ad-hoc wifi networks (they are filtered away from
28 the GUI view), and can not join the mesh without being rooted. But if
29 they are connected using a normal wifi base station, they can talk to
30 every client on the local network.</p>
31
32 <p>To get this working, I've created a debian package
33 <a href="https://github.com/petterreinholdtsen/meshfx-node">meshfx-node</a>
34 and a script
35 <a href="https://github.com/petterreinholdtsen/meshfx-node/blob/master/build-rpi-mesh-node">build-rpi-mesh-node</a>
36 to create the Raspberry Pi boot image. I'm using Debian Jessie (and
37 not Raspbian), to get more control over the packages available.
38 Unfortunately a huge binary blob need to be inserted into the boot
39 image to get it booting, but I'll ignore that for now. Also, as
40 Debian lack support for the CPU features available in the Raspberry
41 Pi, the system do not use the hardware floating point unit. I hope
42 the routing performance isn't affected by the lack of hardware FPU
43 support.</p>
44
45 <p>To create an image, run the following with a sudo enabled user
46 after inserting the target SD card into the build machine:</p>
47
48 <p><pre>
49 % wget -O build-rpi-mesh-node \
50 https://raw.github.com/petterreinholdtsen/meshfx-node/master/build-rpi-mesh-node
51 % sudo bash -x ./build-rpi-mesh-node > build.log 2>&1
52 % dd if=/root/rpi/rpi_basic_jessie_$(date +%Y%m%d).img of=/dev/mmcblk0 bs=1M
53 %
54 </pre></p>
55
56 <p>Booting with the resulting SD card on a Raspberry PI with a USB
57 wifi card inserted should give you a mesh node. At least it does for
58 me with a the wifi card I am using. The default mesh settings are the
59 ones used by the Oslo mesh project at Hackeriet, as I mentioned in
60 <a href="http://www.hungry.com/~pere/blog/Oslo_community_mesh_network___with_NUUG_and_Hackeriet_at_Hausmania.html">an
61 earlier blog post about this mesh testing</a>.</p>
62
63 <p>The mesh node was not horribly expensive either. I bought
64 everything over the counter in shops nearby. If I had ordered online
65 from the lowest bidder, the price should be significantly lower:</p>
66
67 <p><table>
68
69 <tr><th>Supplier</th><th>Model</th><th>NOK</th></tr>
70 <tr><td>Teknikkmagasinet</td><td>Raspberry Pi model B</td><td>349.90</td></tr>
71 <tr><td>Teknikkmagasinet</td><td>Raspberry Pi type B case</td><td>99.90</td></tr>
72 <tr><td>Lefdal</td><td>Jensen Air:Link 25150</td><td>295.-</td></tr>
73 <tr><td>Clas Ohlson</td><td>Kingston 16 GB SD card</td><td>199.-</td></tr>
74 <tr><td>Total cost</td><td></td><td>943.80</td></tr>
75
76 </table></p>
77
78 <p>Now my mesh network at home consist of one laptop in the basement
79 connected to my production network, one Raspberry Pi node on the 1th
80 floor that can be seen by my neighbor across the park, and one
81 play-node I use to develop the image building script. And some times
82 I hook up my work horse laptop to the mesh to test it. I look forward
83 to figuring out what kind of latency the batman-adv setup will give,
84 and how much packet loss we will experience around the park. :)</p>