Routing protocols and firmware

batman-adv explained

batman-adv is a layer-2 mesh protocol in the Linux kernel: how originator messages, the TQ and throughput metrics and gateway mode work, and what it is not.

Updated 4 Nov 2026

What it is

batman-adv ("B.A.T.M.A.N. advanced") is a mesh routing protocol implemented as a Linux kernel driver. The kernel documentation says it "operates on ISO/OSI Layer 2 only and uses and routes (or better: bridges) Ethernet Frames. It emulates a virtual network switch of all nodes participating." Because every node appears link-local, higher protocols are not affected by changes inside the mesh, and the same page says it can run on "wifi as well as ethernet lan, vpn, etc ... (anything with ethernet-style layer 2)" (kernel documentation, read 2026-11-04).

The kernel's own Kconfig help describes it as "a routing protocol for multi-hop ad-hoc mesh networks. The networks may be wired or wireless." (Kconfig, read 2026-11-04.)

In practice, the kernel documentation names IPv4, IPv6 and DHCP as protocols you can run above it. The mesh behaves like one Ethernet segment, so ordinary Ethernet behaviour applies across all of it. Firmware such as Gluon and LibreMesh builds on it; see who uses it.

For where it sits among the other protocols, see how mesh routing works and the routing protocol comparison. For a direct contrast with a layer-3 protocol, see batman-adv vs Babel.

How it finds a path: originator messages

batman-adv implements the B.A.T.M.A.N. approach to routing. The strategy, as the B.A.T.M.A.N. IETF draft states it (and the Open-Mesh wiki repeats), is "to determine for each destination in the mesh one single-hop neighbor, which can be utilized as best gateway to communicate with the destination node". There is no need to find out or calculate the complete route.

The mechanism is the originator message (OGM):

  • On a regular basis every node broadcasts an OGM announcing that it exists.
  • Neighbours rebroadcast it according to the protocol's forwarding rules, so the mesh is flooded with OGMs.
  • A node counts the OGMs it receives from each originator via each neighbour. The neighbour that delivers the best-scoring stream becomes the next hop towards that originator.
  • Flooding stops when every node has seen the OGM, when it is lost, or when its TTL (time to live) expires. The wiki does not state a numeric TTL, and we have not confirmed one.

Per originator, a node holds a list of candidate neighbours from which one best next hop is chosen; there is no map of the whole topology (the kernel source keeps a neighbour list per originator). Traffic to a destination is handed to that one neighbour, which looks up its own best next hop, and so on.

The OGM interval is configurable. The kernel documentation shows the setting returning 1000 (milliseconds) and notes that in very mobile scenarios a lower value "will make the mesh more responsive to topology changes, but will also increase the overhead" (kernel documentation, read 2026-11-04). The same page's batctl example lines conflict with the batctl man page, so we do not reproduce them (see the batctl note below).

The metric: B.A.T.M.A.N. IV and V

batman-adv ships two protocol variants that cannot be mixed. The Kconfig help for B.A.T.M.A.N. V says it is "not compatible to B.A.T.M.A.N. IV networks".

B.A.T.M.A.N. IV: transmit quality (TQ)

The BATMAN_IV page says the older algorithm was enhanced with the Transmit Quality (TQ) algorithm to cope with asymmetric links, where one direction works much better than the other. In outline, as that page describes it (the kernel's bat_iv_ogm.c implements the same counts: an OGM starts with TQ set to BATADV_TQ_MAX_VALUE, 255, and local TQ is 255 × the echo count ÷ the receive count, capped at 100%):

  • A node counts the rebroadcasts of its own OGMs by a neighbour (echo link quality, EQ) and the OGMs it receives from that neighbour (receive link quality, RQ). Transmit quality is then TQ = EQ / RQ.
  • The OGM carries a one-byte TQ field. It is set to 255 (the maximum) when the OGM is generated. Each node that receives it folds its own local link quality into the value before rebroadcasting.
  • A node ends up knowing the combined quality of the path towards every originator.

A per-node setting, the hop penalty, takes a value from 0 to 255. The batctl man page says 255 sets an OGM's TQ to zero when it is forwarded (batctl man page, read 2026-11-04).

TQ is a loss-based quality score in the same family of ideas as ETX, the expected number of transmissions per delivered packet. The sources we read do not equate the two, so treat that as an analogy, not a definition.

B.A.T.M.A.N. V: throughput

The Kconfig help calls B.A.T.M.A.N. V "the successor of the currently used B.A.T.M.A.N. IV protocol". It lists the main changes: the OGM protocol is split into a neighbour discovery protocol (Echo Location Protocol, ELP) and a new flooding protocol (OGMv2), and the metric is based on throughput. It also says "B.A.T.M.A.N. V is currently considered experimental".

The kernel source agrees on the metric: bat_v.c stores a per-neighbour throughput value (a moving average), and treats a candidate as similar to the best only if it is more than three quarters of the reference throughput (read 2026-11-04).

We do not know whether the "experimental" wording is out of date. The Open-Mesh BATMAN_V page was behind a bot wall and could not be read. Gluon's documentation for v2025.1.3 (released 2026-08-18) lists known issues including incomplete B.A.T.M.A.N. V integration (Gluon v2025.1.3 release page, read 2026-11-04). If you build a network on V, test it first.

Gateway mode

batman-adv has a built-in way to share an internet connection. The batctl man page (batctl 2026.3-1, read 2026-11-04) documents the setting as:

[ meshif netdev ] gw_mode|gw [ off | client | server ] [ sel_class | bandwidth ]

What the man page says about it:

  • A node in server mode tells the rest of the mesh how much bandwidth its internet connection has. The optional argument is a number, optionally followed by kbit or mbit. The documented default is 10000, shown as 10.0/2.0 MBit.
  • A node in client mode chooses between the gateways announced by servers. The optional argument is the selection class.
  • For B.A.T.M.A.N. IV the documented default selection class is 20 (a late switch, 20 TQ points better). For B.A.T.M.A.N. V it is 5000 (a late switch at 5000 kbit/s of extra throughput), where throughput is the lower of the gateway's advertised value and the maximum bandwidth across the whole path.

Gateway mode only steers traffic towards a gateway. The uplink itself is not set up by this setting; that is configured outside batman-adv.

Setting it up, and a note on batctl syntax

The kernel documentation shows how to create and populate a batman-adv interface with ip from iproute2 (kernel documentation, read 2026-11-04; applies to the mainline kernel module):

ip link add name bat0 type batadv
ip link set dev eth0 master bat0

The first line creates the mesh interface bat0. The second attaches a lower interface to it, after which batman-adv starts using and broadcasting on that interface. The documentation says to repeat the second step for every interface you want in the mesh.

batctl is the companion configuration and diagnostic tool. Its syntax has drifted:

  • The current man page (batctl 2026.3-1, read 2026-11-04) writes commands with a meshif <netdev> prefix, for example [ meshif netdev ] gw_mode|gw. The -m option, "specify mesh interface (default 'bat0')", still appears in its options list.
  • Older material, and some lines in the kernel documentation, use -m bat0 as a flag. The kernel documentation also contains batctl -M bat0 ... lines, but on the man page -M is a different flag (it stops batctl creating the interface automatically when you add one), so we do not reproduce those lines.

For any batctl command, read the batctl man page for the version you have installed. The prefix dates from batctl 2019.3 (2019-08-01): the CHANGELOG.rst in the batctl 2025.4 tarball has that entry as "use type specific prefixes to select mesh interface or vlan instead of '-m'", and a 2019.4 (2019-10-25) entry "fix deprecation warning for option '-m'". To build a working node on OpenWrt, see the OpenWrt batman-adv node guide; to try it on a bench first, see the Raspberry Pi mesh lab.

What it is not

  • Not an IP router. It works below IP, on Ethernet frames. IP addressing, DHCP, DNS, firewalling and NAT are all separate jobs. A mesh network built on batman-adv still needs something above it to hand out addresses and reach the internet.
  • Not a radio. It needs an Ethernet-style link to run over. On Wi-Fi, Gluon uses an 802.11s mesh-point interface; wired and VPN links also work. It does not itself make two Wi-Fi radios talk. See 802.11s on OpenWrt.
  • Not a LoRa protocol. Meshtastic, MeshCore and Reticulum do their own routing and do not use it. It assumes Ethernet frames.
  • Not a security layer. Nothing in the sources we read makes batman-adv encrypt or authenticate traffic on its own.

Who uses it

  • Gluon (Freifunk firmware). Gluon describes itself as "a modular framework for creating OpenWrt-based firmware images for wireless mesh nodes" and says several Freifunk communities in Germany use it as the foundation of their firmware. It ships gluon-mesh-batman-adv. The mandatory site setting routing_algo selects BATMAN_IV or BATMAN_V; the default gateway selection class is 20 for IV and 5000 kbit/s for V (Gluon site.conf documentation, read 2026-11-04). Gluon's wireless mesh network type is 802.11s, so Gluon runs batman-adv over 802.11s links. Gluon v2025.1 ships batman-adv 2024.3 (Gluon v2025.1 release notes, read 2026-11-04). See Freifunk.
  • LibreMesh. The lime-packages repository contains lime-proto-batadv alongside packages for other protocols. LibreMesh's own "What is LibreMesh" page says batman-adv forms layer-2 clouds and Babel is the default layer-3 protocol, with both running by default on different VLANs (libremesh.org, read 2026-11-04); see the LibreMesh explainer. The configuration file only lists which protocols are available, so we do not claim what a particular image runs.

Which variant, IV or V, Freifunk communities or Gluon sites run in production is not documented on the pages we read, so we do not state it. We also did not find a UK community running batman-adv. See join a community Wi-Fi mesh for what to do when no group exists near you.

Maintenance status

Dated as of 2026-11-04.

Item Status Source
Linux kernel net/batman-adv Active. Last touched 2026-10-06, a merge of the batadv-next pull request 20260930 kernel commit history
batman-adv and batctl tarballs Release 2026.3 published 2026-08-31 for both batman-adv and batctl. Earlier: 2026.2 (2026-06-30), 2026.1 (2026-04-08), 2026.0 (2026-02-24), 2025.5 (2025-12-19), 2025.4 (2025-10-24) Open-Mesh downloads listing (batman-adv) and (batctl)
batctl in Debian unstable 2026.3-1 (trixie carries 2025.0-2, bookworm 2023.0-1) Debian sources
OpenWrt packages OpenWrt 25.12 ships batman-adv and batctl 2025.4, from the openwrt/routing feed branch openwrt-25.12; the 24.10 branch of that feed has 2024.3. Only master/snapshot builds use 2026.3, where the net/batman-adv and net/batctl Makefiles in openwrt/packages pin PKG_VERSION 2026.3 routing feed batman-adv Makefile (openwrt-25.12), batctl Makefile, openwrt/packages

The live open-mesh.org wiki sits behind a proof-of-work wall that automated fetches cannot pass, so the protocol pages cited here are from a dated archive copy.

In the UK

batman-adv is software, so it has no UK rules of its own. What matters is the link underneath it. On licence-exempt Wi-Fi bands the radio rules for the device apply; on amateur bands you need an amateur licence and cannot obscure the meaning of messages. We found no UK community mesh that publishes its routing protocol, so we cannot say whether any UK group uses batman-adv. See find a local mesh and the Freifunk page, which notes that the Freifunk directory lists no UK communities.

What we could not confirm

  • Whether the "experimental" wording for B.A.T.M.A.N. V in the kernel Kconfig is out of date, because the BATMAN_V wiki page could not be read.
  • Which variant Freifunk communities, Gluon sites and LibreMesh images run in production.
  • A numeric TTL or hop limit for OGMs.
  • When batman-adv entered the mainline kernel, and who developed the original B.A.T.M.A.N. protocol. The sources we read for this page do not say, so we leave both out.
  • UK deployments of batman-adv.

Sources

  1. IETF draft: Better Approach To Mobile Ad-hoc Networking (B.A.T.M.A.N.), draft-wunderlich-openmesh-manet-routing-00
  2. Linux kernel source: net/batman-adv/bat_iv_ogm.c (TQ calculation)
  3. Linux kernel documentation: batman-adv
  4. Linux kernel source: net/batman-adv/Kconfig
  5. Linux kernel source: net/batman-adv/types.h
  6. Linux kernel source: net/batman-adv/bat_v.c
  7. Open-Mesh wiki: BATMAN_IV (web.archive.org copy of 2026-06-16)
  8. batctl manual page (Debian unstable, batctl 2026.3-1)
  9. Open-Mesh downloads: batman-adv release tarballs (live listing, read 2026-11-04)
  10. Open-Mesh downloads: batctl release tarballs (live listing, read 2026-11-04)
  11. Debian sources: batctl versions
  12. Linux kernel commit history for net/batman-adv
  13. Gluon documentation
  14. Gluon site.conf documentation
  15. Gluon v2025.1 release notes
  16. Gluon v2025.1.3 release page
  17. OpenWrt routing feed, branch openwrt-25.12: batman-adv Makefile
  18. OpenWrt routing feed, branch openwrt-25.12: batctl Makefile
  19. batctl 2025.4 release tarball (CHANGELOG.rst)
  20. LibreMesh: What is LibreMesh
  21. LibreMesh: lime-packages