# open-mesh-mirror/batman-adv architecture

> Architecture diagram of the GitHub repository open-mesh-mirror/batman-adv, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/open-mesh-mirror/batman-adv
- Repository: https://github.com/open-mesh-mirror/batman-adv

## Overview

batman-adv is a Linux kernel Layer-2 mesh driver: it presents a virtual Ethernet interface and routes or bridges frames across participating nodes. The main workflow is to configure a mesh and its physical interfaces, exchange protocol messages to discover neighbors and routes, then forward client frames toward their mesh destination. The tree and README identify additional gateway, multicast, address-resolution, loop-avoidance, fragmentation, diagnostics, and configuration capabilities. Edges for unsampled subsystems reflect documented roles; detailed call wiring is shown only where the excerpts support it.

Main entry points: [`net/batman-adv/routing.c`](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/routing.c) (Frame routing), [`net/batman-adv/netlink.c`](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/netlink.c) (Generic netlink), [`net/batman-adv/main.c`](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/main.c) (Module and packet dispatch), [`net/batman-adv/bat_v.c`](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v.c) (BATMAN V protocol)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["Interfaces and control"]
  node_meshif["Virtual mesh interface<br/>[mesh-interface.c]"]
  node_hardif["Physical interfaces<br/>[hard-interface.c]"]
  node_netlink["Generic netlink<br/>[netlink.c]"]
  node_main["Module and packet dispatch<br/>[main.c]"]
  node_netlink_api["Mesh configuration and state<br/>[batman_adv.h]"]
end

subgraph group_mesh["Mesh routing"]
  node_algo["Algorithm selection<br/>[bat_algo.c]"]
  node_batv["BATMAN V protocol<br/>[bat_v.c]"]
  node_elp["Neighbor probing<br/>[bat_v_elp.c]"]
  node_ogmv["BATMAN V announcements<br/>[bat_v_ogm.c]"]
  node_bativ["BATMAN IV protocol<br/>[bat_iv_ogm.c]"]
  node_originator[("Originator tracking<br/>[originator.c]")]
  node_routing["Frame routing<br/>[routing.c]"]
  node_send["Packet transmission<br/>[send.c]"]
end

subgraph group_services["Mesh services"]
  node_tt[("Client translation table")]
  node_gateway["Gateway selection<br/>[gateway_client.c]"]
  node_dat[("Distributed ARP table")]
  node_multicast["Multicast handling<br/>[multicast.c]"]
  node_bla["Bridge loop avoidance"]
  node_fragment["Frame fragmentation<br/>[fragmentation.c]"]
end

subgraph group_operations["Diagnostics and tests"]
  node_trace["Kernel logging and tracing<br/>[trace.c]"]
  node_tp["Throughput meter<br/>[tp_meter.c]"]
end

node_admin(("Operator and batctl"))
node_kernel_net(("Linux networking"))

node_admin -->|"configures mesh"| node_netlink
node_netlink -->|"uses command schema"| node_netlink_api
node_netlink -->|"configures interface"| node_meshif
node_kernel_net -->|"supplies frames"| node_meshif
node_meshif -->|"attaches interfaces"| node_hardif
node_hardif -->|"receives packets"| node_main
node_main -->|"dispatches packets"| node_bativ
node_main -->|"initializes protocol"| node_batv
node_batv -->|"probes neighbors"| node_elp
node_batv -->|"announces topology"| node_ogmv
node_bativ -->|"updates node state"| node_originator
node_ogmv -->|"updates node state"| node_originator
node_algo -->|"selects algorithm"| node_batv
node_algo -->|"selects algorithm"| node_bativ
node_main -->|"dispatches packets"| node_routing
node_routing -->|"looks up routes"| node_originator
node_routing -->|"looks up clients"| node_tt
node_routing -->|"delivers frames"| node_meshif
node_routing -->|"forwards frames"| node_send
node_send -->|"transmits frames"| node_hardif
node_routing -.->|"handles oversized frames"| node_fragment
node_routing -.->|"checks gateway route"| node_gateway
node_routing -.->|"resolves ARP"| node_dat
node_routing -.->|"handles multicast"| node_multicast
node_routing -.->|"coordinates bridge loops"| node_bla
node_admin -->|"enables debug"| node_trace
node_admin -->|"requests measurement"| node_tp
node_netlink -.->|"reports gateway state"| node_gateway

click node_meshif "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/mesh-interface.c"
click node_hardif "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/hard-interface.c"
click node_netlink "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/netlink.c"
click node_main "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/main.c"
click node_algo "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_algo.c"
click node_batv "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v.c"
click node_elp "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v_elp.c"
click node_ogmv "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v_ogm.c"
click node_bativ "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_iv_ogm.c"
click node_originator "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/originator.c"
click node_routing "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/routing.c"
click node_send "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/send.c"
click node_tt "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/translation-table.c"
click node_gateway "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/gateway_client.c"
click node_dat "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/distributed-arp-table.c"
click node_multicast "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/multicast.c"
click node_bla "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bridge_loop_avoidance.c"
click node_fragment "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/fragmentation.c"
click node_netlink_api "https://github.com/open-mesh-mirror/batman-adv/blob/main/include/uapi/linux/batman_adv.h"
click node_trace "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/trace.c"
click node_tp "https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/tp_meter.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_meshif,node_hardif,node_netlink,node_main,node_netlink_api toneBlue
class node_algo,node_batv,node_elp,node_ogmv,node_bativ,node_originator,node_routing,node_send toneAmber
class node_tt,node_gateway,node_dat,node_multicast,node_bla,node_fragment toneMint
class node_trace,node_tp toneRose
class node_admin,node_kernel_net toneIndigo
```

## Components

### Interfaces and control

- [Virtual mesh interface](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/mesh-interface.c): `net/batman-adv/mesh-interface.c`
- [Physical interfaces](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/hard-interface.c): `net/batman-adv/hard-interface.c`
- [Generic netlink](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/netlink.c): `net/batman-adv/netlink.c`
- [Module and packet dispatch](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/main.c): `net/batman-adv/main.c`
- [Mesh configuration and state](https://github.com/open-mesh-mirror/batman-adv/blob/main/include/uapi/linux/batman_adv.h): `include/uapi/linux/batman_adv.h`

### Mesh routing

- [Algorithm selection](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_algo.c): `net/batman-adv/bat_algo.c`
- [BATMAN V protocol](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v.c): `net/batman-adv/bat_v.c`
- [Neighbor probing](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v_elp.c): `net/batman-adv/bat_v_elp.c`
- [BATMAN V announcements](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_v_ogm.c): `net/batman-adv/bat_v_ogm.c`
- [BATMAN IV protocol](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bat_iv_ogm.c): `net/batman-adv/bat_iv_ogm.c`
- [Originator tracking](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/originator.c): `net/batman-adv/originator.c`
- [Frame routing](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/routing.c): `net/batman-adv/routing.c`
- [Packet transmission](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/send.c): `net/batman-adv/send.c`

### Mesh services

- [Client translation table](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/translation-table.c): `net/batman-adv/translation-table.c`
- [Gateway selection](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/gateway_client.c): `net/batman-adv/gateway_client.c`
- [Distributed ARP table](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/distributed-arp-table.c): `net/batman-adv/distributed-arp-table.c`
- [Multicast handling](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/multicast.c): `net/batman-adv/multicast.c`
- [Bridge loop avoidance](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/bridge_loop_avoidance.c): `net/batman-adv/bridge_loop_avoidance.c`
- [Frame fragmentation](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/fragmentation.c): `net/batman-adv/fragmentation.c`

### Diagnostics and tests

- [Kernel logging and tracing](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/trace.c): `net/batman-adv/trace.c`
- [Throughput meter](https://github.com/open-mesh-mirror/batman-adv/blob/main/net/batman-adv/tp_meter.c): `net/batman-adv/tp_meter.c`

### Other components

- **Operator and batctl**
- **Linux networking**

## Connections

- Operator and batctl → Generic netlink: configures mesh
- Generic netlink → Mesh configuration and state: uses command schema
- Generic netlink → Virtual mesh interface: configures interface
- Linux networking → Virtual mesh interface: supplies frames
- Virtual mesh interface → Physical interfaces: attaches interfaces
- Physical interfaces → Module and packet dispatch: receives packets
- Module and packet dispatch → BATMAN IV protocol: dispatches packets
- Module and packet dispatch → BATMAN V protocol: initializes protocol
- BATMAN V protocol → Neighbor probing: probes neighbors
- BATMAN V protocol → BATMAN V announcements: announces topology
- BATMAN IV protocol → Originator tracking: updates node state
- BATMAN V announcements → Originator tracking: updates node state
- Algorithm selection → BATMAN V protocol: selects algorithm
- Algorithm selection → BATMAN IV protocol: selects algorithm
- Module and packet dispatch → Frame routing: dispatches packets
- Frame routing → Originator tracking: looks up routes
- Frame routing → Client translation table: looks up clients
- Frame routing → Virtual mesh interface: delivers frames
- Frame routing → Packet transmission: forwards frames
- Packet transmission → Physical interfaces: transmits frames
- Frame routing → Frame fragmentation: handles oversized frames
- Frame routing → Gateway selection: checks gateway route
- Frame routing → Distributed ARP table: resolves ARP
- Frame routing → Multicast handling: handles multicast
- Frame routing → Bridge loop avoidance: coordinates bridge loops
- Operator and batctl → Kernel logging and tracing: enables debug
- Operator and batctl → Throughput meter: requests measurement
- Generic netlink → Gateway selection: reports gateway state
