Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

MeshNetwork

How to use batman-adv to create a Mesh network

Project Setup and Configuration

This repository contains the setup and configuration guide for a Mesh Network over WiFi on Raspberry Pis. Follow the steps below to get started.

Table of Contents

  1. Prerequisites

  2. Configure Environment

  3. Startup Script

Prerequisites

Make sure you have the following prerequisites:

  • Raspberry Pi 3B+ (Minimum 2)

  • Ubuntu 22.04

  • Batman-adv

Configure Environment

Step 1:

sudo apt-get update && sudo apt-get upgrade -y

Step 2: Download Batman and extract files

curl -O https://downloads.open-mesh.org/batman/releases/batman-adv-2023.3/batman-adv-2023.3.tar.gz
tar -xvzf  batman-adv-2023.3.tar.gz

Step 3: Install make and gcc

sudo apt install make
sudo apt-get install gcc

Step 4: Compile source code and install batman on the system

cd batman-adv-2023.3/
sudo make all
sudo make install

Step 5: Install batctl and network configuration tools

sudo apt install batctl
sudo apt install iw
sudo apt install net-tools
sudo apt install wireless-tools

Step 6: Disable wpa_supplicant to freely configure network interfaces

Note:

sudo service wpa_supplicant stop
sudo systemctl mask wpa_supplicant.service

Output: Created symlink /etc/systemd/system/wpa_supplicant.service → /dev/null.

Step 7: Configure interfaces

sudo ip link set <if> down  #e.g. <if> = wlan0
sudo iw <if> set type ibss #ibss means ad-hoc mode
sudo ifconfig <if> mtu 1468
sudo iwconfig <if> channel 3
sudo ip link set <if> up
sudo iw <if> ibss join <ssid> 2432  # e.g. <ssid> = my-mesh-network

Step 8: Load the kernel module & Check it

sudo modprobe batman-adv
lsmod | grep "batman_adv"

Step 9:

sudo batctl if add <if>#  e.g. <if> =  wlan0
sudo ip link set up dev <if>
sudo ip link set up dev bat0
sudo ifconfig bat0 172.27.0.1/16  # Can be any other valid IP.

Step 10: Verify the Mesh Network

sudo iwconfig

Step 11: Print originators/neighbor nodes

sudo batctl o #Shows originators
sudo batctl n #Shows neighbor mesh nodes

Step 12: Mixing non-B.A.T.M.A.N. systems with batman-adv

ip link add name br0 type bridge
ip link set dev br0 up
ip link set dev bat0 master br0
ip link set dev eth0 master br0

Mixing non-B.A.T.M.A.N. systems with batman-adv

In this example, the blue wifi-client on node2 should be able to talk to the red ethernet client on node3. Even when they both don't have any knowledge about batman-adv or the medium (ethernet vs. wifi) of the remote client.

Startup Script

After configuring the mesh network step by step, it would be easier to have a script that execute all steps in one command. Therefore, a script is provided to create the mesh network using a single command. First make the script executable using this command:

chmod +x /path/to/mesh-network-startup.sh

Later, launch the script:

sudo bash /path/to/mesh-network-startup.sh

PS: Don't forget to change parameters in the script according to your needs.

About

How to use batman-adv to create a Mesh network

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages