Wbm2009v2/config-Batman

From Hackerspace Brussels
Jump to: navigation, search

Parent: Wbm2009v2

Contents

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

[edit] Packages that need to be installed

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

[edit] Config snippet

[edit] Configure daemon, logging and wireless

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
IP="@PARAM2@"
GW_IP="172.16.32.140"
LOG_IP="192.168.42.44"

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=255.255.255.0
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

[edit] Enable daemon

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

[edit] Disable daemon

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

[edit] Enable batman-remote-logger

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

[edit] Disable batman-remote-logger

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

[edit] Verbose BATMAN log-level

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

[edit] Quiet BATMAN log-level

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

[edit] Logging

[edit] General status log-files

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:

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

#!/bin/sh /etc/rc.common
START=95

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

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

        chmod 755 /tmp/logserver.sh
        /tmp/logserver.sh&
}

stop () {
        killall logserver.sh
        killall netcat
}

[edit] BATMAN-ADV-loglevel-changer script

#!/bin/sh
## 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`"
LOGLEVEL="$2"
OPTIONS='-o "UserKnownHostsFile /dev/null" -o "StrictHostKeyChecking no"'
for HOST in $HOSTS; do
        ssh root@$HOST $OPTIONS "/usr/sbin/batctl ll $LOGLEVEL"
done

[edit] Log fetching script on our laptops

#!/bin/sh
for i in $(seq 1 9)
do
    nc 172.16.32.${i} 2050 > num$i.log &
done

[edit] BATMAN vis-server

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

[edit] Test II

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.