Difference between revisions of "Mesh/BATMAN-adv"

From Sudo Room
Jump to navigation Jump to search
(change the wording)
 
(15 intermediate revisions by 3 users not shown)
Line 1: Line 1:
These notes are valid for OpenWrt 12.09 (Attitude Adjustment), which uses BATMAN 2012.4.0. In newer versions, the version of BATMAN used is 2013.0.0 and the syntax for configuring BATMAN differs slightly. See [http://www.open-mesh.org/projects/batman-adv/wiki/Batman-adv-openwrt-config this page on open-mesh.org] for more info.
The [http://www.open-mesh.org/projects/batman-adv/wiki batman-adv] is an implementation of the [http://en.wikipedia.org/wiki/B.A.T.M.A.N. BATMAN routing protocol]. The protocol is configured with a file, but these settings can be changed with [http://downloads.open-mesh.org/batman/manpages/batctl.8.html batctl]. The advantage of routing using batman-adv, rather than [https://github.com/cjdelisle/cjdns cjdns], is its a layer two protocol, which can send all types of layers three packets (udp, tcp/ip, etc). The protocol "forwards all traffic until it reaches the destination, hence emulating a virtual network switch of all nodes participating. Therefore all nodes appear to be link local and are unaware of the network's topology as well as unaffected by any network changes.<ref>[http://www.open-mesh.org/projects/batman-adv/wiki/Wiki BATMAN advanced overview]</ref>"


= Wireless configuration =
= [http://downloads.open-mesh.org/batman/manpages/batctl.8.html batctl] configuration=  
 
These functions change BATMAN-adv configurations through batctl:
 
* [http://downloads.open-mesh.org/batman/manpages/alfred-gpsd.html alfred-gpsd] - a used to distribute GPS location information about your batman-adv mesh network. This information could be, for example, combined with [http://www.open-mesh.org/projects/batmand/wiki/VisualizeMesh vis] to visualize your mesh topology with true geographic layout. The server fetches the information from locals nodes serving data from [http://manpages.ubuntu.com/manpages/karmic/en/man8/gpsd.8.html gpsd].
* [http://downloads.open-mesh.org/batman/manpages/batadv-vis.html batadv-vis] - its a server that saves local client tables and distributes these tables via [http://www.open-mesh.org/projects/open-mesh/wiki/Alfred alfred]. These tables can be used to create network topology maps.
* [http://www.open-mesh.org/projects/batman-adv/wiki/Multi-link-optimize bonding] - when there's multiple interfaces with similar throughput, bonding can be used to increase frame throughput. It uses [http://oit2.utk.edu/helpdesk/kb/entry/1699/ round robin load balancing] to evenly distribute frames.
* [http://www.open-mesh.org/projects/batman-adv/wiki/DistributedArpTable-technical dat] - a distributed arp table is a Distributed Hash Table aimed to store ARP entries and to allow nodes to perform fast lookup operations. All the operations in the DHT (get and store) are performed on a set of nodes computed by means of a distributed hash function which input value is an IPv4 address.
* [http://www.open-mesh.org/projects/batman-adv/wiki/Fragmentation-technical fragmentation] - a driver that sets fragmentation, which sends frames in fragmented frames when a wireless interfaces can't send/receive packets more than 1500 bytes. The protocol adds its own header to existing frames, which makes the packets have 1528 bytes.
* gw_mode - a server is an internet gateway, a client sends and receives traffic to and from the gateway
* [http://www.open-mesh.org/projects/batman-adv/wiki/NetworkCoding nc] (network coding) - when forwarding packets in a wireless mesh network, bandwidth can be saved by exploiting the information already present at the destinations of a forward. One way of doing this is network coding, where two packets are combined before transmission.
* traceroute - tries to find the bat-host name if the given parameter was not a MAC address. It can also try to guess the MAC address using an IPv4/IPv6 address or a hostname when the IPv4/IPv6 address was configured on top of the batman-adv interface of the destination device and both source and destination devices are in the same IP subnet.
 
= [http://downloads.open-mesh.org/batman/manpages/batmand.8.html batmand] configuration =
 
There functions change BATMAN configurations through [http://downloads.open-mesh.org/batman/manpages/batmand.8.html batmand]:
 
* s (visualization server) - Batman daemons may send their local  view  about their  single-hop  neighbors  to the vis server. It collects the information and provides data in  a  format  similar  to  [http://www.olsr.org/ OLSR's topology]  information  output.
* o (originator interval in ms) - a node transmits broadcast messages  (we  call  them  [http://www.open-mesh.org/projects/batman-adv/wiki/OGM originator message or OGM], [http://www.open-mesh.org/projects/batman-adv/wiki/Ogm-v2 version 2]) to inform the neighboring does about it's existence.  Originator interval is the time to  wait  after  sending one  message  and  before  sending the next message. The default value is 1000 ms (1 second).  In a mobile network, you may  want to detect network changes very quickly, so you need to send message very often, for example, use a  value  of  500  ms.  In  a static  network, you can save bandwidth by using a higher value.
 
= Configuration files =
== Device configuration ==
 
This configuration is valid for [http://wiki.openwrt.org/about/history OpenWRT 12.09] (Attitude Adjustment), which uses BATMAN 2012.4.0. In newer versions, the version of BATMAN used is 2013.0.0 and the configuration of BATMAN slightly differs.


In /etc/config/wireless:
In /etc/config/wireless:
Line 9: Line 32:
option type 'mac80211'
option type 'mac80211'
option hwmode '11g'
option hwmode '11g'
option channel '3'  
option channel '3'       # You may want another channel
option disabled '0'
option disabled '0'
option phy 'phy0'
option phy 'phy0'
Line 20: Line 43:
option network 'lan'
option network 'lan'
option mode 'ap'
option mode 'ap'
option ssid 'sudomesh'
option ssid 'sudomesh'   # You should change the ssid to be unique for dev purposes


# the mesh interface
# the mesh interface
Line 29: Line 52:
option network 'mesh'
option network 'mesh'
option mode 'adhoc'
option mode 'adhoc'
option bssid 'CA:FE:C0:DE:F0:0D'
option bssid 'CA:FE:C0:DE:F0:0D' # You should change this to be unique for development purposes, but for meshing this should be the same for all routers on the mesh
option ssid 'sudomesh-backchannel'
option ssid 'sudomesh-backchannel' # You should change the ssid to be unique for development purposes, but for meshing this should be the same for all routers on the mesh
</pre>
</pre>


= Network configuration =
Write some of this stuff down for reference later! You might need it!
 
== Network configuration ==


In /etc/config/network:
In /etc/config/network:
Line 63: Line 88:
</pre>
</pre>


= BATMAN configuration =
== BATMAN configuration ==


In /etc/config/batman-adv:
There are [http://www.open-mesh.org/projects/batman-adv/wiki/Tweaking other options], but these are the recommended settings in /etc/config/batman-adv:


<pre>
<pre>
config mesh 'bat0'
config mesh 'bat0'
option interfaces 'adhoc0' # the interface for which to enable batman0
option interfaces 'adhoc0' # the interface for which to enable batman0
option 'aggregated_ogms' # no idea what this means
option 'aggregated_ogms'
option 'ap_isolation' # no idea what this means
option 'ap_isolation'
</pre>
</pre>


= System configuration =
* [http://www.open-mesh.org/projects/batman-adv/wiki/Tweaking aggregated_ogms] - an option that combines the [http://www.open-mesh.org/projects/batman-adv/wiki/OGM originator messages] into a single packet instead of a lot of smaller packets.
* [http://www.open-mesh.org/projects/batman-adv/wiki/Ap-isolation ap_isolation] - an option that prevents any communication between stations connected to the same access point. The clients of the access point won't be able to communicate to each other, which makes it more secure, but less efficient for networking. There's [http://www.open-mesh.org/projects/batman-adv/wiki/Extended-Isolation extended ap isolation], which prevents all the wirelsss-to-wireless traffic and at the same time marks clients as isolated based on the user configuration.
* multicast mode - an option that reduces unnecessary packet transmissions. This optimization announces multicast listeners via the translation table mechanism, thereby signaling interest in certain multicast traffic instead of all of it. If disabled multicast traffic is forwarded to the every node in the network (broadcast).
* [http://www.open-mesh.org/projects/batman-adv/wiki/Understand-your-batman-adv-network routing_algo] - an option to change the routing algorithm.
 
== System configuration ==


In /etc/config/system you can set hostname and timezone. This is not strictly necessary for BATMAN to work, but it should be set correctly. The below timezone is correct for the pacific U.S. timezone. The naming convention for hostnames is: <router-model-name>-<some-unique-name-you-choose>
In /etc/config/system you can set hostname and timezone. This is not strictly necessary for BATMAN to work, but it should be set correctly. The below timezone is correct for the pacific U.S. timezone. The naming convention for hostnames is: <router-model-name>-<some-unique-name-you-choose>
Line 94: Line 124:


You should see the 'sudomesh' and 'sudomesh-backchannel' wifi interfaces when running `sudo iwlist wlan0 scan`
You should see the 'sudomesh' and 'sudomesh-backchannel' wifi interfaces when running `sudo iwlist wlan0 scan`
= References =
<references/>

Latest revision as of 01:50, 22 July 2014

The batman-adv is an implementation of the BATMAN routing protocol. The protocol is configured with a file, but these settings can be changed with batctl. The advantage of routing using batman-adv, rather than cjdns, is its a layer two protocol, which can send all types of layers three packets (udp, tcp/ip, etc). The protocol "forwards all traffic until it reaches the destination, hence emulating a virtual network switch of all nodes participating. Therefore all nodes appear to be link local and are unaware of the network's topology as well as unaffected by any network changes.[1]"

batctl configuration

These functions change BATMAN-adv configurations through batctl:

  • alfred-gpsd - a used to distribute GPS location information about your batman-adv mesh network. This information could be, for example, combined with vis to visualize your mesh topology with true geographic layout. The server fetches the information from locals nodes serving data from gpsd.
  • batadv-vis - its a server that saves local client tables and distributes these tables via alfred. These tables can be used to create network topology maps.
  • bonding - when there's multiple interfaces with similar throughput, bonding can be used to increase frame throughput. It uses round robin load balancing to evenly distribute frames.
  • dat - a distributed arp table is a Distributed Hash Table aimed to store ARP entries and to allow nodes to perform fast lookup operations. All the operations in the DHT (get and store) are performed on a set of nodes computed by means of a distributed hash function which input value is an IPv4 address.
  • fragmentation - a driver that sets fragmentation, which sends frames in fragmented frames when a wireless interfaces can't send/receive packets more than 1500 bytes. The protocol adds its own header to existing frames, which makes the packets have 1528 bytes.
  • gw_mode - a server is an internet gateway, a client sends and receives traffic to and from the gateway
  • nc (network coding) - when forwarding packets in a wireless mesh network, bandwidth can be saved by exploiting the information already present at the destinations of a forward. One way of doing this is network coding, where two packets are combined before transmission.
  • traceroute - tries to find the bat-host name if the given parameter was not a MAC address. It can also try to guess the MAC address using an IPv4/IPv6 address or a hostname when the IPv4/IPv6 address was configured on top of the batman-adv interface of the destination device and both source and destination devices are in the same IP subnet.

batmand configuration

There functions change BATMAN configurations through batmand:

  • s (visualization server) - Batman daemons may send their local view about their single-hop neighbors to the vis server. It collects the information and provides data in a format similar to OLSR's topology information output.
  • o (originator interval in ms) - a node transmits broadcast messages (we call them originator message or OGM, version 2) to inform the neighboring does about it's existence. Originator interval is the time to wait after sending one message and before sending the next message. The default value is 1000 ms (1 second). In a mobile network, you may want to detect network changes very quickly, so you need to send message very often, for example, use a value of 500 ms. In a static network, you can save bandwidth by using a higher value.

Configuration files

Device configuration

This configuration is valid for OpenWRT 12.09 (Attitude Adjustment), which uses BATMAN 2012.4.0. In newer versions, the version of BATMAN used is 2013.0.0 and the configuration of BATMAN slightly differs.

In /etc/config/wireless:

config wifi-device 'radio0'
	option type 'mac80211'
	option hwmode '11g'
	option channel '3'        # You may want another channel
	option disabled '0'
	option phy 'phy0'

# the interface where non-mesh nodes connect
config wifi-iface
	option device 'radio0'
	option ifname 'ap0'
	option encryption 'none'
	option network 'lan'
	option mode 'ap'
	option ssid 'sudomesh'   # You should change the ssid to be unique for dev purposes

# the mesh interface
config wifi-iface
	option device 'radio0'
	option ifname 'adhoc0'
 	option encryption 'none'
	option network 'mesh'
	option mode 'adhoc'
	option bssid 'CA:FE:C0:DE:F0:0D' # You should change this to be unique for development purposes, but for meshing this should be the same for all routers on the mesh
	option ssid 'sudomesh-backchannel' # You should change the ssid to be unique for development purposes, but for meshing this should be the same for all routers on the mesh

Write some of this stuff down for reference later! You might need it!

Network configuration

In /etc/config/network:

config interface 'loopback'
	option ifname 'lo'
	option proto 'static'
	option ipaddr '127.0.0.1'
	option netmask '255.0.0.0'

# set up ethernet bridging between eth0 and bat0
# this means that packets can move between the ethernet port
# and the wifi mesh
config interface 'lan'
	option type 'bridge'
	option proto 'static'
	option ipaddr '10.42.10.11' # this should be a unique IP
	option netmask '255.255.0.0'
	option dns '208.67.222.222'
	option gateway '192.168.1.1' # an internet gateway, not sure how to deal with multiple gateways yet
	option ifname 'eth0 bat0'

# the mesh interface
config interface 'mesh'
	option ifname 'adhoc0'
	option proto 'none'
	option mtu '1528'

BATMAN configuration

There are other options, but these are the recommended settings in /etc/config/batman-adv:

config mesh 'bat0'
	option interfaces 'adhoc0' # the interface for which to enable batman0
	option 'aggregated_ogms'
	option 'ap_isolation'
  • aggregated_ogms - an option that combines the originator messages into a single packet instead of a lot of smaller packets.
  • ap_isolation - an option that prevents any communication between stations connected to the same access point. The clients of the access point won't be able to communicate to each other, which makes it more secure, but less efficient for networking. There's extended ap isolation, which prevents all the wirelsss-to-wireless traffic and at the same time marks clients as isolated based on the user configuration.
  • multicast mode - an option that reduces unnecessary packet transmissions. This optimization announces multicast listeners via the translation table mechanism, thereby signaling interest in certain multicast traffic instead of all of it. If disabled multicast traffic is forwarded to the every node in the network (broadcast).
  • routing_algo - an option to change the routing algorithm.

System configuration

In /etc/config/system you can set hostname and timezone. This is not strictly necessary for BATMAN to work, but it should be set correctly. The below timezone is correct for the pacific U.S. timezone. The naming convention for hostnames is: <router-model-name>-<some-unique-name-you-choose>

config system
	option hostname	tl-wr703n-foo
	option timezone	PST8PDT,M3.2.0,M11.1.0


You may also have to turn off dnsmasq. (someone else can chime in if this contradicts their working knowledge)

/etc/init.d/dnsmasq disable

Testing

You should see the 'sudomesh' and 'sudomesh-backchannel' wifi interfaces when running `sudo iwlist wlan0 scan`

References