RADIUSdesk WiFi Hotspot Manager and GUI for FreeRADIUS
MESHdesk Streamlined Mesh Controller

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


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 subsequent documents. 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 are 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.

scp kmod-* root@192.168.1.1:/tmp
  • Shh into the mesh node and issue the following commands:
cd /tmp
opkg install kmod-*
  • 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 on Node1
  • Use these sample files as reference
/etc/config/wireless
#Keep as is (can change Channel)
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
 
#Change SSID
config wifi-iface 
        option device   radio0
        option network  lan
        option mode     ap
        option ssid     Node1  
        option encryption none
 
#Add this interface
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'
 
/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
 
#Add this network
config interface 'mesh'
        option ifname 'adhoc0'
        option mtu '1528'
        option proto 'batadv'
        option mesh 'bat0'
 

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
/etc/config/wireless
#Keep as is (can change Channel)
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
 
#Change SSID and network (bridge)
config wifi-iface 
        option device   radio0
        option network  mb
        option mode     ap
        option ssid     Node2  
        option encryption none
 
#Add this interface
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'
 
/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
 
#Add this network
config interface 'mesh'
        option ifname 'adhoc0'
        option mtu '1528'
        option proto 'batadv'
        option mesh 'bat0'
 
#Add the mb bridge
config interface mb
        option ifname   bat0
        option type     bridge
        option proto    static
        option ipaddr   192.168.99.26
        option netmask  255.255.255.0

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.
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
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.

Activate a mesh in OpenWRT

Let us consider the following snippet from the /etc/config/wireless file

...
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'
...

The following points are important:

  • We give the wireless network a name (wmesh) in order to address it with ease, should we need to. Compare the following commands. One tries to address an interface without a name and the second one with a name:
#No name for wifi-iface
uci set wireless.@wifi-iface[1].ssid=mesh
#Name for wifi-iface
uci set wireless.wmesh.ssid=mesh
  • We specify the physical interface name that this wireless network will identify itself as in the ifconfig and iw commands (adhoc0).
  • We also specify which the network interface this wireless network will attach to (mesh).
  • The value of ssid and bssid is supplied and chosen by us. It has to be the same (common) on all the participating nodes.

This completes the definition of the ad-hoc wireless network. Next we will consider how we go about to increase the MTU of the interface.

  • We can not increase the MTU in the wireless configuration (/etc/config/wireless).
  • We can however:
    • Define a network interface in the /etc/config/network file with the increased MTU.
    • Attach it to the ad-hoc physical interface.
  • To attach it to the wireless network we make us of the network option in the wireless interface definition. (This option is typically used to bind the wireless network to a bridge which is also defined in the /etc/config/network file.)
config interface 'mesh'
        option ifname 'adhoc0'
        option mtu '1528'
        option proto 'batadv'
        option mesh 'bat0'
  • The ifname option should contain the same value as ifname in the wireless network's definition and is the name of the physical interface.
  • The proto option of batman is a new addition and will tell the setup scripts that this network interface (adhoc0) should be part of the Batman-adv mesh with the mesh interface name of bat0.
  • The settings in turn for the bat0 interface can be tweaked inside the /etc/config/batman-adv file.
  • The /etc/config/batman-adv file has an interfaces option. This is the network interface(s) names which is defined in etc/config/network and not the physical interface name.