B.A.T.M.A.N.-adv (Better Approach To Mobile Ad-hoc Networking – Advanced) is a relatively latecomer among wireless mesh network (Ad-Hoc) routing protocols, specifically designed for decentralized, self-organizing multi-hop wireless networks. Compared to other ad-hoc routing technologies like HWMP and OLSR, its most distinctive feature is that it operates at L2 and can calculate the optimal path in real-time based on link quality and hop count, making it an excellent distributed ad-hoc routing technology.
L2 Working Mechanism
Most implementations of other wireless routing protocols (such as the batman backend program) operate at Layer 3, meaning they exchange routing information by sending IP packets and implement routing decisions by manipulating the kernel routing table. In contrast, batman-adv operates entirely at the ISO/OSI Layer 2—routing information is transmitted via raw Ethernet frames, and data traffic is also handled by batman-adv. It encapsulates and forwards all traffic until it reaches its destination, effectively simulating a virtual network switch participated in by all nodes. Therefore, all nodes appear to be link-local and are unaware of the network topology, remaining unaffected by any network changes.
The simplest way to understand the batman-adv mesh network is to think of it as a distributed switch. Each system running batman-adv (commonly referred to as a “node”) is equivalent to a switch port.
Each node runs an instance of batman-adv. This instance is a virtual network interface (commonly referred to as “bat0”), which acts like a switch port that allows access to the distributed switch. The actual details of communication between nodes (directly or indirectly) are hidden behind the “bat0” network interface.
To enable communication between different bat0 interfaces on different nodes, batman-adv relies on Ethernet-compatible network interfaces, which are attached to bat0 as so-called (lower-level) hardware interfaces. This concept should be familiar to those who understand Linux bridging.
In the previous diagram, even if node3 cannot transmit data over its “mesh0” interface to node2 due to a weak Wi-Fi link, node3 can still communicate with node2. In this case, node1 can be used to forward traffic between node3 and node2. Data can be transmitted via the (usually very stable) Ethernet interface “eth0”. Meanwhile, node1 can communicate with node2 through the “mesh0” interface. All these processes are handled internally by batman-adv, and upper-layer applications can directly use the bat0 interface as if it were any other network interface.
This also means that any other interface can be bridged to the bat0 interface. Another Ethernet interface (in this case, “eth1”) can be used to provide connectivity to clients that do not support batman-adv, allowing them to connect to node1, node2, node3, or other clients that do not support batman-adv. The same applies to Wi-Fi clients connected to the bridged access point interface.
In the example above, the blue Wi-Fi client on node2 should be able to communicate with the red Ethernet client on node3. Even though both clients are unaware of the existence of batman-adv and do not know the medium used by the remote client (Ethernet or Wi-Fi).
This design has some interesting features:
● Network Layer Independence: Any protocol you want can run over batman-adv: IPv4, IPv6, DHCP, IPX, etc.
● Nodes can participate in the mesh network without an IP address.
● Easy integration of non-mesh clients (no manual HNA configuration required): Facilitates the access of mobile clients without the need for manual Host and Network Association (HNA) adjustments.
● Roaming capability for non-mesh clients: Allows non-mesh clients to move freely within the network without losing connection.
● Optimized data flow through the mesh network (e.g., interface alternation, multicast, forward error correction, etc.), improving data transmission efficiency and reliability.
● Running broadcast/multicast-dependent protocols on mesh and non-mesh clients: Services such as Windows LAN, mDNS, streaming, etc., can operate normally in a network environment built on batman-adv.