This is an old revision of the document!
====== Creating a basic Batman-adv mesh ====== ===== Introduction ===== We assume you just read the Overview document on Batman-adv and are now eager to build your first Batman-adv mesh.\\ This document will help you in a step by step manner to find your feet and build your confidence as you build your first basic Batman-adv mesh. ===== Required ingredients ===== ^ Item ^ Detail ^ | 2 Access Points | These should be Atheros based Access Points flashed with the latest version of OpenWRT (Attitude Adjustment). We will use two Ubiquity PicoStation 2's | | Internet connection | This need to be provided by a switch with an Ethernet cable | | CAT 5 Cable | To connect one of the Access Points to the Internet | | A ssh terminal | e.g. putty or a Linux workstation | ===== When everything is complete ===== {{:technical_discussions:basic.jpg|}} \\ When everything is complete we will have a mesh with the following: * One node which serve as an exit point (gateway) as well as an entry point. * A second node which serve as an entry point. * This mesh can be considered as an extended bridge where traffic will: * Enter at one of the entry points. * Be routed through the mesh cloud. * Exit at the single exit point and released onto the LAN. ===== Not covered here ===== * Multiple entry points per mesh node. * Using VLAN's to **separate** traffic within the mesh. * Using VLAN's at the exit point (gateway). * Making the mesh more secure. * Creating a NATted exit point. * Adding a Captive Portal at the exit point. These items are covered in the Advanced Setup document. You can do them once you have completed the basic setup in this document. ===== Our approach ===== The changes we have to make to a standard install of OpenWRT on the PicoStation is actually minor.\\ We will do a quick and dirty setup of our basic mesh and continue with a detailed explanation on what we did and the result of it. ===== Installing batman-adv ===== Do the following on each of the mesh nodes. * Go to the following URL http://downloads.openwrt.org/attitude_adjustment/12.09/atheros/generic/packages/ and download these tow packages: * kmod-batman-adv_3.3.8+2012.3.0-3_atheros.ipk * kmod-lib-crc16_3.3.8-1_atheros.ipk * Copy them onto the mesh node: <code bash> scp kmod-* root@192.168.1.1:/tmp </code> * Shh into the mesh node and issue the following commands: <code bash> cd /tmp opkg install kmod-* </code> * This will install Batman-adv. ===== Configure the two nodes ===== ==== Our LAN ==== We assume the LAN has the following: ^ Item ^ Value ^ Comment ^ | Subnet | 192.168.99.0/24 | | | Mask | 255.255.255.0 | | | Gateway | 192.168.99.1 | The gateway is not shown in the schematic but provided by a device on the LAN | | DHCP Server | 192.168.99.100-200 | There are a DHCP Server running on the LAN with a reserved range | ==== Our mesh nodes ==== ^ Item ^ Value ^ Comment ^ | Node1 - IP | 192.168.99.25 | | | Node1 - SSID | Node1 | | | Node2 - IP | 192.168.99.26 | | | Node2 - SSID | Node2 | | ==== Configure Node1 ==== * Change the following files one **Node1** <file bash /etc/config/wireless > config wifi-device radio0 option type mac80211 option channel 11 option macaddr 00:15:6d:da:c5:6c option hwmode 11g # REMOVE THIS LINE TO ENABLE WIFI: # option disabled 1 config wifi-iface option device radio0 option network lan option mode ap option ssid Node1 option encryption none config wifi-iface 'wmesh' option device 'radio0' option ifname 'adhoc0' option network 'mesh' option mode 'adhoc' option ssid 'mesh' option bssid '02:CA:FE:CA:CA:40' </file> <file bash /etc/config/network > # Copyright (C) 2006 OpenWrt.org config interface loopback option ifname lo option proto static option ipaddr 127.0.0.1 option netmask 255.0.0.0 config interface lan option ifname 'eth0 bat0' option type bridge option proto static option ipaddr 192.168.99.25 option netmask 255.255.255.0 config interface 'mesh' option ifname 'adhoc0' option mtu '1528' option proto 'batadv' option mesh 'bat0' </file> Easy isn't it? By changing a mere two files; we just completed the configuration of **Node1**. Next we will configure **Node2**. ==== Configure Node2 ==== * Change the following files one **Node2** <file bash /etc/config/wireless > config wifi-device radio0 option type mac80211 option channel 11 option macaddr 00:15:6d:da:c5:6c option hwmode 11g # REMOVE THIS LINE TO ENABLE WIFI: # option disabled 1 config wifi-iface option device radio0 option network mb option mode ap option ssid Node2 option encryption none config wifi-iface 'wmesh' option device 'radio0' option ifname 'adhoc0' option network 'mesh' option mode 'adhoc' option ssid 'mesh' option bssid '02:CA:FE:CA:CA:40' </file> <file bash /etc/config/network > # Copyright (C) 2006 OpenWrt.org config interface loopback option ifname lo option proto static option ipaddr 127.0.0.1 option netmask 255.0.0.0 config interface lan option ifname eth0 option type bridge option proto static option ipaddr 192.168.1.1 option netmask 255.255.255.0 config interface 'mesh' option ifname 'adhoc0' option mtu '1528' option proto 'batadv' option mesh 'bat0' config interface mb option ifname bat0 option type bridge option proto static option ipaddr 192.168.99.26 option netmask 255.255.255.0 </file> By changing these two files; we just completed the configuration of **Node2**. ==== Basic testing ==== * Reboot both nodes and see if you can ping both of them from the LAN. * Connect with a WiFi client to the two SSIDs advertised and ensure you get an IP Address from the DHCP server on the LAN. * If the LAN is connected to the Internet, test your internet connectivity through the mesh. ===== How does it work ===== The rest of this document will explore our basic two node mesh network in more detail. ==== What is needed? ==== * We needed to install two optional packages: * kmod-batman-adv * kmod-lib-crc16 * These are both kernel modules. The batman-adv package however also includes some extra files. <code bash> root@OpenWrt:~# opkg files kmod-batman-adv Package kmod-batman-adv (3.3.8+2012.3.0-3) is installed on root and has the following files: /usr/sbin/batman-adv /lib/modules/3.3.8/batman-adv.ko /etc/hotplug.d/net/99-batman-adv /lib/batman-adv/config.sh /etc/config/batman-adv /usr/sbin/batctl /etc/modules.d/50-batman-adv </code> ^ File ^ Comment ^ | /usr/sbin/batman-adv | Shell script to start and stop the Batman-adv mesh | | /lib/modules/3.3.8/batman-adv.ko | The kernel module - the most important part of Batman-adv | | /etc/hotplug.d/net/99-batman-adv | Hotplug housekeeping rules | | /lib/batman-adv/config.sh | Library used by **batman-adv** and **99-batman-adv** | | /etc/config/batman-adv | Sample config for **bat0** mesh interface | | /usr/sbin/batctl | Command to get values and set values of the Batman-adv mesh | | /etc/modules.d/50-batman-adv | File to enable the loading the batman-adv module during start-up | * By installing these two packages the Access Point is now able to be configured as a mesh node. ==== Configuring the Access Point to be a mesh node ==== We will start this section with an overview of what is required for a Batman-adv mesh and then also have a brief discussion on the way to do this configuration on the OpenWRT. === Requirements for a mesh === For a mesh node to become part of a mesh it needs: * One interface running in **ad-hoc** mode to be assigned to the mesh. * This interface has to run with an enlarged MTU. It has to be 1528 instead of the standard 1520.