BATMAN-adv
Type: Kernel Module (Layer 2 Mesh) Role in Styrene: Physical connectivity layer for fleet devices
BATMAN-adv (Better Approach To Mobile Adhoc Networking - advanced) is a Linux kernel module that creates a virtual network switch across multiple wireless hops.
Why Styrene Uses BATMAN-adv
Reticulum solves logical connectivity (identity-based routing, encryption). BATMAN-adv solves physical connectivity:
| Problem | BATMAN-adv Solution |
|---|---|
| Multi-hop WiFi | Transparent bridging across mesh nodes |
| Path selection | OGM (Originator Messages) measure actual throughput |
| Interference | Adapts routes based on real conditions |
| Node mobility | Updates routes as devices move |
Layer Position
┌─────────────────────────────────────┐
│ Reticulum (identity + encryption) │ ← Sees bat0 as just another interface
├─────────────────────────────────────┤
│ BATMAN-adv (bat0 virtual switch) │ ← YOU ARE HERE
├─────────────────────────────────────┤
│ 802.11s mesh (wlan0, mesh-styrene) │ ← WiFi mesh mode
└─────────────────────────────────────┘
Virtual Interface
BATMAN-adv creates bat0, a virtual Ethernet interface:
- All mesh nodes share the same
bat0broadcast domain - Traffic is encapsulated and routed through optimal path
- Applications see a simple Ethernet interface
Styrene Configuration
Fleet devices use the batman-mesh.nix NixOS module:
styrene.mesh = {
enable = true;
meshId = "styrene";
meshKey = "fleet-key-from-vault";
channel = 6;
gwMode = "client"; # or "server" or "off"
};
Gateway Modes
| Mode | Purpose | Example |
|---|---|---|
server | Bridges mesh to LAN/internet | Hub node |
client | Uses gateway when available | Fleet devices |
off | Pure mesh, no gateway | Isolated mesh |
Key Concepts
OGM (Originator Messages)
Nodes periodically broadcast OGMs to announce presence. Other nodes measure:
- Packet loss
- Latency
- Throughput quality
Routes favor paths with best actual performance, not just fewest hops.
TQ (Transmission Quality)
A 0-255 metric representing link quality. Higher = better. BATMAN-adv selects paths that maximize TQ.
Mesh vs Infrastructure
| 802.11s Mesh | Infrastructure (AP) |
|---|---|
| No central controller | Access Point required |
| Multi-hop native | Single hop only |
| Devices peer directly | All traffic through AP |
| PSK shared across mesh | PSK per-AP |
Styrene uses 802.11s for device-to-device connectivity.
Debugging
# Show mesh neighbors
batctl n
# Show originators (all mesh nodes)
batctl o
# Show gateway list
batctl gwl
# Show transmission quality to node
batctl tq
Complementary Layers
BATMAN-adv and Reticulum are not redundant:
| Layer | Solves | Uses |
|---|---|---|
| BATMAN-adv | ”Get frame from A to B over 3 hops” | MAC addresses, OGMs |
| Reticulum | “Send encrypted message to identity X” | Cryptographic hashes |
Reticulum runs over BATMAN-adv’s bat0 interface.