162306a36Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
262306a36Sopenharmony_ci
362306a36Sopenharmony_ci==========
462306a36Sopenharmony_cibatman-adv
562306a36Sopenharmony_ci==========
662306a36Sopenharmony_ci
762306a36Sopenharmony_ciBatman advanced is a new approach to wireless networking which does no longer
862306a36Sopenharmony_cioperate on the IP basis. Unlike the batman daemon, which exchanges information
962306a36Sopenharmony_ciusing UDP packets and sets routing tables, batman-advanced operates on ISO/OSI
1062306a36Sopenharmony_ciLayer 2 only and uses and routes (or better: bridges) Ethernet Frames. It
1162306a36Sopenharmony_ciemulates a virtual network switch of all nodes participating. Therefore all
1262306a36Sopenharmony_cinodes appear to be link local, thus all higher operating protocols won't be
1362306a36Sopenharmony_ciaffected by any changes within the network. You can run almost any protocol
1462306a36Sopenharmony_ciabove batman advanced, prominent examples are: IPv4, IPv6, DHCP, IPX.
1562306a36Sopenharmony_ci
1662306a36Sopenharmony_ciBatman advanced was implemented as a Linux kernel driver to reduce the overhead
1762306a36Sopenharmony_cito a minimum. It does not depend on any (other) network driver, and can be used
1862306a36Sopenharmony_cion wifi as well as ethernet lan, vpn, etc ... (anything with ethernet-style
1962306a36Sopenharmony_cilayer 2).
2062306a36Sopenharmony_ci
2162306a36Sopenharmony_ci
2262306a36Sopenharmony_ciConfiguration
2362306a36Sopenharmony_ci=============
2462306a36Sopenharmony_ci
2562306a36Sopenharmony_ciLoad the batman-adv module into your kernel::
2662306a36Sopenharmony_ci
2762306a36Sopenharmony_ci  $ insmod batman-adv.ko
2862306a36Sopenharmony_ci
2962306a36Sopenharmony_ciThe module is now waiting for activation. You must add some interfaces on which
3062306a36Sopenharmony_cibatman-adv can operate. The batman-adv soft-interface can be created using the
3162306a36Sopenharmony_ciiproute2 tool ``ip``::
3262306a36Sopenharmony_ci
3362306a36Sopenharmony_ci  $ ip link add name bat0 type batadv
3462306a36Sopenharmony_ci
3562306a36Sopenharmony_ciTo activate a given interface simply attach it to the ``bat0`` interface::
3662306a36Sopenharmony_ci
3762306a36Sopenharmony_ci  $ ip link set dev eth0 master bat0
3862306a36Sopenharmony_ci
3962306a36Sopenharmony_ciRepeat this step for all interfaces you wish to add. Now batman-adv starts
4062306a36Sopenharmony_ciusing/broadcasting on this/these interface(s).
4162306a36Sopenharmony_ci
4262306a36Sopenharmony_ciTo deactivate an interface you have to detach it from the "bat0" interface::
4362306a36Sopenharmony_ci
4462306a36Sopenharmony_ci  $ ip link set dev eth0 nomaster
4562306a36Sopenharmony_ci
4662306a36Sopenharmony_ciThe same can also be done using the batctl interface subcommand::
4762306a36Sopenharmony_ci
4862306a36Sopenharmony_ci  batctl -m bat0 interface create
4962306a36Sopenharmony_ci  batctl -m bat0 interface add -M eth0
5062306a36Sopenharmony_ci
5162306a36Sopenharmony_ciTo detach eth0 and destroy bat0::
5262306a36Sopenharmony_ci
5362306a36Sopenharmony_ci  batctl -m bat0 interface del -M eth0
5462306a36Sopenharmony_ci  batctl -m bat0 interface destroy
5562306a36Sopenharmony_ci
5662306a36Sopenharmony_ciThere are additional settings for each batadv mesh interface, vlan and hardif
5762306a36Sopenharmony_ciwhich can be modified using batctl. Detailed information about this can be found
5862306a36Sopenharmony_ciin its manual.
5962306a36Sopenharmony_ci
6062306a36Sopenharmony_ciFor instance, you can check the current originator interval (value
6162306a36Sopenharmony_ciin milliseconds which determines how often batman-adv sends its broadcast
6262306a36Sopenharmony_cipackets)::
6362306a36Sopenharmony_ci
6462306a36Sopenharmony_ci  $ batctl -M bat0 orig_interval
6562306a36Sopenharmony_ci  1000
6662306a36Sopenharmony_ci
6762306a36Sopenharmony_ciand also change its value::
6862306a36Sopenharmony_ci
6962306a36Sopenharmony_ci  $ batctl -M bat0 orig_interval 3000
7062306a36Sopenharmony_ci
7162306a36Sopenharmony_ciIn very mobile scenarios, you might want to adjust the originator interval to a
7262306a36Sopenharmony_cilower value. This will make the mesh more responsive to topology changes, but
7362306a36Sopenharmony_ciwill also increase the overhead.
7462306a36Sopenharmony_ci
7562306a36Sopenharmony_ciInformation about the current state can be accessed via the batadv generic
7662306a36Sopenharmony_cinetlink family. batctl provides a human readable version via its debug tables
7762306a36Sopenharmony_cisubcommands.
7862306a36Sopenharmony_ci
7962306a36Sopenharmony_ci
8062306a36Sopenharmony_ciUsage
8162306a36Sopenharmony_ci=====
8262306a36Sopenharmony_ci
8362306a36Sopenharmony_ciTo make use of your newly created mesh, batman advanced provides a new
8462306a36Sopenharmony_ciinterface "bat0" which you should use from this point on. All interfaces added
8562306a36Sopenharmony_cito batman advanced are not relevant any longer because batman handles them for
8662306a36Sopenharmony_ciyou. Basically, one "hands over" the data by using the batman interface and
8762306a36Sopenharmony_cibatman will make sure it reaches its destination.
8862306a36Sopenharmony_ci
8962306a36Sopenharmony_ciThe "bat0" interface can be used like any other regular interface. It needs an
9062306a36Sopenharmony_ciIP address which can be either statically configured or dynamically (by using
9162306a36Sopenharmony_ciDHCP or similar services)::
9262306a36Sopenharmony_ci
9362306a36Sopenharmony_ci  NodeA: ip link set up dev bat0
9462306a36Sopenharmony_ci  NodeA: ip addr add 192.168.0.1/24 dev bat0
9562306a36Sopenharmony_ci
9662306a36Sopenharmony_ci  NodeB: ip link set up dev bat0
9762306a36Sopenharmony_ci  NodeB: ip addr add 192.168.0.2/24 dev bat0
9862306a36Sopenharmony_ci  NodeB: ping 192.168.0.1
9962306a36Sopenharmony_ci
10062306a36Sopenharmony_ciNote: In order to avoid problems remove all IP addresses previously assigned to
10162306a36Sopenharmony_ciinterfaces now used by batman advanced, e.g.::
10262306a36Sopenharmony_ci
10362306a36Sopenharmony_ci  $ ip addr flush dev eth0
10462306a36Sopenharmony_ci
10562306a36Sopenharmony_ci
10662306a36Sopenharmony_ciLogging/Debugging
10762306a36Sopenharmony_ci=================
10862306a36Sopenharmony_ci
10962306a36Sopenharmony_ciAll error messages, warnings and information messages are sent to the kernel
11062306a36Sopenharmony_cilog. Depending on your operating system distribution this can be read in one of
11162306a36Sopenharmony_cia number of ways. Try using the commands: ``dmesg``, ``logread``, or looking in
11262306a36Sopenharmony_cithe files ``/var/log/kern.log`` or ``/var/log/syslog``. All batman-adv messages
11362306a36Sopenharmony_ciare prefixed with "batman-adv:" So to see just these messages try::
11462306a36Sopenharmony_ci
11562306a36Sopenharmony_ci  $ dmesg | grep batman-adv
11662306a36Sopenharmony_ci
11762306a36Sopenharmony_ciWhen investigating problems with your mesh network, it is sometimes necessary to
11862306a36Sopenharmony_cisee more detailed debug messages. This must be enabled when compiling the
11962306a36Sopenharmony_cibatman-adv module. When building batman-adv as part of the kernel, use "make
12062306a36Sopenharmony_cimenuconfig" and enable the option ``B.A.T.M.A.N. debugging``
12162306a36Sopenharmony_ci(``CONFIG_BATMAN_ADV_DEBUG=y``).
12262306a36Sopenharmony_ci
12362306a36Sopenharmony_ciThose additional debug messages can be accessed using the perf infrastructure::
12462306a36Sopenharmony_ci
12562306a36Sopenharmony_ci  $ trace-cmd stream -e batadv:batadv_dbg
12662306a36Sopenharmony_ci
12762306a36Sopenharmony_ciThe additional debug output is by default disabled. It can be enabled during
12862306a36Sopenharmony_cirun time::
12962306a36Sopenharmony_ci
13062306a36Sopenharmony_ci  $ batctl -m bat0 loglevel routes tt
13162306a36Sopenharmony_ci
13262306a36Sopenharmony_ciwill enable debug messages for when routes and translation table entries change.
13362306a36Sopenharmony_ci
13462306a36Sopenharmony_ciCounters for different types of packets entering and leaving the batman-adv
13562306a36Sopenharmony_cimodule are available through ethtool::
13662306a36Sopenharmony_ci
13762306a36Sopenharmony_ci  $ ethtool --statistics bat0
13862306a36Sopenharmony_ci
13962306a36Sopenharmony_ci
14062306a36Sopenharmony_cibatctl
14162306a36Sopenharmony_ci======
14262306a36Sopenharmony_ci
14362306a36Sopenharmony_ciAs batman advanced operates on layer 2, all hosts participating in the virtual
14462306a36Sopenharmony_ciswitch are completely transparent for all protocols above layer 2. Therefore
14562306a36Sopenharmony_cithe common diagnosis tools do not work as expected. To overcome these problems,
14662306a36Sopenharmony_cibatctl was created. At the moment the batctl contains ping, traceroute, tcpdump
14762306a36Sopenharmony_ciand interfaces to the kernel module settings.
14862306a36Sopenharmony_ci
14962306a36Sopenharmony_ciFor more information, please see the manpage (``man batctl``).
15062306a36Sopenharmony_ci
15162306a36Sopenharmony_cibatctl is available on https://www.open-mesh.org/
15262306a36Sopenharmony_ci
15362306a36Sopenharmony_ci
15462306a36Sopenharmony_ciContact
15562306a36Sopenharmony_ci=======
15662306a36Sopenharmony_ci
15762306a36Sopenharmony_ciPlease send us comments, experiences, questions, anything :)
15862306a36Sopenharmony_ci
15962306a36Sopenharmony_ciIRC:
16062306a36Sopenharmony_ci  #batadv on ircs://irc.hackint.org/
16162306a36Sopenharmony_ciMailing-list:
16262306a36Sopenharmony_ci  b.a.t.m.a.n@lists.open-mesh.org (optional subscription at
16362306a36Sopenharmony_ci  https://lists.open-mesh.org/mailman3/postorius/lists/b.a.t.m.a.n.lists.open-mesh.org/)
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_ciYou can also contact the Authors:
16662306a36Sopenharmony_ci
16762306a36Sopenharmony_ci* Marek Lindner <mareklindner@neomailbox.ch>
16862306a36Sopenharmony_ci* Simon Wunderlich <sw@simonwunderlich.de>
169