From Hackerspace Brussels
Jump to: navigation, search

Parent: Wbm2009v2

B.A.T.M.A.N. Router Configuration[edit]

Packages that need to be installed[edit]

  • the batman-adv kernelmodule (which includes batctl) from [[1]]

Config snippet[edit]

Configure daemon, logging and wireless[edit]

set -a

## Configuring IP address ##
# PARAM3 should point to the bat0-ip of wbm-140, as this device will be configured
# manually to act as a gateway to the logging-server

uci set network.batman=interface
uci set network.batman.ifname=bat0
uci set network.batman.proto=static
uci set network.batman.ipaddr=$IP
uci set network.batman.netmask=
uci set network.batman.gateway="$GW_IP"

uci set network.wlan.proto=none

uci set wireless.wifi0.channel=11 
uci set wireless.@wifi-iface[0].ssid=batman-adv
uci set wireless.@wifi-iface[0].bssid=02:22:B0:44:94:5D
uci delete wireless.@wifi-iface[0].rate

uci set batman-adv-kernelland.general.interface="ath0 eth0"

## Enabling syslogging to remote target ##
uci set system.@system[0].log_ip="$LOG_IP"

uci commit

Enable daemon[edit]

[ -f /etc/init.d/batman-adv-kernelland ] && {
  /etc/init.d/batman-adv-kernelland enable
  /etc/init.d/batman-adv-kernelland start

Disable daemon[edit]

[ -f /etc/init.d/batman-adv-kernelland ] && {
  /etc/init.d/batman-adv-kernelland stop
  /etc/init.d/batman-adv-kernelland disable

Enable batman-remote-logger[edit]

[ -f /etc/init.d/batman-remote-logger.sh ] && {
  /etc/init.d/batman-remote-logger.sh enable
  /etc/init.d/batman-remote-logger.sh start

Disable batman-remote-logger[edit]

[ -f /etc/init.d/batman-remote-logger.sh ] && {
  /etc/init.d/batman-remote-logger.sh stop
  /etc/init.d/batman-remote-logger.sh disable

Verbose BATMAN log-level[edit]

[ -f /usr/sbin/batctl ] && {
  batctl ll 15

Quiet BATMAN log-level[edit]

[ -f /usr/sbin/batctl ] && {
  batctl 0


General status log-files[edit]

As the the logfiles created by BATMAN are not normal, terminating ones but blocking instead, we're going to install a netcat listening server on each node. A script on a laptop will then fetch all those logs.

Packages that need to be installed on each node:

remote-logger.sh (on each node)[edit]

#!/bin/sh /etc/rc.common

start () {
        # set up log server for blocking logfiles

cat << EOF > /tmp/logserver.sh
while [ 1 ]; do
        /usr/bin/netcat -l -p 2050 < /proc/net/batman-adv/log

        chmod 755 /tmp/logserver.sh

stop () {
        killall logserver.sh
        killall netcat

BATMAN-ADV-loglevel-changer script[edit]

## BATMAN-ADV-loglevel-changer
# First parameter: Hostfile in the format of the battlemesh
#                 (it is picking the third comma seprated argument
#                  of the list as the hosts)
# Second parameter: The new loglevel on all nodes provided in the hostfile

HOSTS="`cat $1 | cut -d "," -f3`"
OPTIONS='-o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no"'
for HOST in $HOSTS; do
        ssh root@$HOST $OPTIONS "/usr/sbin/batctl ll $LOGLEVEL"

Log fetching script on our laptops[edit]

for i in $(seq 1 9)
    nc 172.16.32.${i} 2050 > num$i.log &

BATMAN vis-server[edit]

We're going to dedicate the gateway node (wbm-140) as a vis-server with the following command:

  • echo server > /proc/net/batman-adv/vis

Deactivating it again:

  • echo client > /proc/net/batman-adv/vis

Any BATMAN-Adv-node is automatically a vis-client, it will be sending its local topology map to its closests vis-server. The output on the vis-server will be the complete topology in dot-file-format. It will look something like something in the example here: http://www.open-mesh.net/wiki/VisAdv

Test II[edit]

The same configuration, but with some patches for the batman-adv kernelmodule to make it prefer a different outgoing interface than the one the packets came in from. Therefore connecting two Foneras with a cable - each using a different channel, shall let the data packets hop over those different channels. The patches are available here:

So for this setup also the /etc/config/wireless has to be changed to channel 1 for half of the nodes and to channel 11 for the other ones.

The package here [[6]] includes the modified batman-adv version (thanks Nico!), so just the channels and this package have to be modified for our 2nd test.