DEV Community

Cover image for Building a Decentralized Mesh Network in Rust — Lessons from the Global South
Michael Muriithi
Michael Muriithi

Posted on

Building a Decentralized Mesh Network in Rust — Lessons from the Global South

Optimized using real-world mesh data

The Problem

2.6 billion people lack reliable internet access. When disasters strike,
infrastructure fails, or communities are remote — traditional communication
breaks down precisely when coordination is most critical.

I'm a cybersecurity student in Nairobi, Kenya. I've seen what happens when
communities lose connectivity: families can't check on each other after floods,
rescue teams can't coordinate, and activists can't organize safely.

So I built GhostWire — a decentralized, censorship-resistant mesh
communication platform that works without any central servers.


What Is GhostWire?

GhostWire is a peer-to-peer encrypted communication platform written in Rust.
Instead of connecting to a server, devices connect directly to each other.
Messages hop from node to node through whatever path is available.

If a node goes offline, the mesh routes around it. If the internet goes down,
GhostWire switches to WiFi Direct, Bluetooth, or even LoRa radio.

Live site: https://phantomojo.github.io/GhostWire-secure-mesh-communication/
GitHub: https://github.com/Phantomojo/GhostWire-secure-mesh-communication


The Architecture

Networking: libp2p

We use libp2p — the same P2P networking stack used by
IPFS and Ethereum. It handles peer discovery, connection establishment, and
multiplexing. On top of that, we run a S/Kademlia-hardened DHT for routing
and Gossipsub for message propagation.

// Simplified peer discovery
let swarm = SwarmBuilder::with_new_identity()
    .with_tokio()
    .with_tcp(
        tcp::Config::default(),
        noise::Config::new,
        yamux::Config::default,
    )?
    .with_behaviour(|_| Behaviour::new())?
    .build();
Enter fullscreen mode Exit fullscreen mode

Encryption: Defense in Depth

Every message is encrypted end-to-end before it leaves your device:

Layer Algorithm Purpose
Symmetric AES-256-GCM Message encryption + integrity
Key Exchange X25519 Perfect forward secrecy
Signatures Ed25519 Identity verification
Post-Quantum ML-KEM-768 Future-proof (planned)

No server, no relay, no intermediate node ever sees plaintext.

AI-Powered Routing

This is where GhostWire gets interesting. Instead of using fixed routing rules,
we trained AI models on real mesh network data from Barcelona's GuifiSants
— one of the world's largest community mesh networks.

  • L1 — LightGBM anomaly detector: AUC 1.0, 76.7μs inference, exported as ONNX and wired into Rust via ONNX Runtime
  • L3 — Graph Neural Network: Trained on 7,931 samples across 63 nodes over 31 days. Learns which paths work best in real conditions.
# Training pipeline (simplified)
model = lgb.LGBMRegressor(
    n_estimators=500,
    learning_rate=0.05,
    max_depth=7,
    num_leaves=31
)
model.fit(X_train, y_train)
onnx_model = convert_lightgbm(model, initial_types=initial_type)
onnx.save(onnx_model, "ghostwire_routing.onnx")
Enter fullscreen mode Exit fullscreen mode

The model runs in 76.7 microseconds — fast enough for real-time routing
decisions on a Raspberry Pi.

7 Transport Layers

Transport Range Use Case
WiFi Direct ~100m Urban mesh, device-to-device
Bluetooth LE ~50m Indoor, low-power
LoRa ~15km Rural, long-range
WebRTC Internet Bridge across networks
TCP/IP Internet Standard connectivity
Reticulum Multi-hop Amateur radio mesh
Briar Bluetooth/WiFi Activist communication

GhostWire selects the best available path automatically. No internet? It falls
back to RF mesh. No WiFi? Bluetooth. The mesh adapts.


Why Rust?

Three reasons:

  1. Memory safety without GC — GhostWire runs on resource-constrained devices
    (Raspberry Pi, old laptops). We can't afford a garbage collector pause during
    emergency communication.

  2. Fearless concurrency — The networking stack handles hundreds of
    simultaneous peer connections. Rust's ownership model means we don't worry
    about data races.

  3. Performance — The LightGBM inference runs in 76.7μs. The crypto is
    hardware-accelerated. Rust lets us squeeze every microsecond out of the
    hardware.


The Human Side

GhostWire isn't just a technical project. It's built on a philosophy:

In Hindu and Buddhist cosmology, Indra's Net is an infinite web. At each
intersection hangs a jewel. Each reflected in all others. No jewel is more
important. The net has no center. The net has no edge.

The original internet architects independently rediscovered what African
philosophy had encoded for millennia: systems built on mutual relationship
rather than central authority are more resilient, more equitable, and more
aligned with existence itself.

We're building this as part of the GCD4F 2026 competition (Global Climate
Data for Future) under the "AI for Society" track, representing the Open
University of Kenya.


We Need Contributors

GhostWire is AGPL-3.0 licensed and actively seeking contributors:

  • Rust developers — libp2p networking, transport layers, crypto
  • AI/ML engineers — GNN model training, routing optimization
  • Security researchers — independent audit, threat modeling
  • Frontend developers — React/TypeScript dashboard
  • Documentation writers — guides, tutorials, translations

Good first issues are labeled on GitHub. Our CONTRIBUTING.md has detailed
setup instructions.


Links


Built in Nairobi, for the world. 🇰🇪

Top comments (6)

Collapse
 
theeagle profile image
Victor Okefie

The routing model trained on real mesh data from GuifiSants is the part most mesh networks skip, they simulate, you measured. 76.7 microseconds on a Raspberry Pi means the AI doesn't become the bottleneck in a crisis. That's the difference between research and something that actually deploys.

Collapse
 
phantomojo profile image
Michael Muriithi

Thank you, Victor

This means a lot coming from someone who clearly understands the space.

You hit on the exact thing we care about most: the gap between research and deployment. Most mesh AI papers train on synthetic topology data and report accuracy numbers that collapse the moment you
point them at a real network with flaky links, power-cycling nodes, and actual human traffic patterns. We went to GuifiSants because their data is messy, real, and unforgiving — which is exactly what a routing model needs to survive in the wild.

The 76.7μs on Pi wasn't an accident either. We deliberately chose LightGBM → ONNX as the Layer 1 fast path because a 2B-parameter model, no matter how smart, is useless if it takes 200ms to decide where to forward a packet during an emergency. The AI has to be faster than the crisis.
If you're open to it, we'd really appreciate you sharing the post with your network. We're actively looking for:
- Feedback from people who've deployed or studied mesh networks
- Contributors — especially folks with ops experience who can tell us where our assumptions break
- Testers with Raspberry Pis or Android devices who want to run nodes
GhostWire is still early, but it's being built for the real world, not a lab. The more eyes from people who've actually shipped things, the better it gets.

Thanks again for reading and for the kind words. 🙏

Collapse
 
theeagle profile image
Victor Okefie

You're welcome, sir, always happy to contribute.

Collapse
 
futurecontributor profile image
Said

I have been dreaming of this since I heard the Huawei nearlink, but you made it even better than I imagined. Congratulations. I wish so badly I knew more about CS to contribute.

Collapse
 
phantomojo profile image
Michael Muriithi

Appreciate the comment and the CS thing, that's not the only way you can contribute, there are other ways you may contribute, since I'm swamped with Life while also building all of it alone, you can pick anything non-technical to help me with, like the blogs and such other things, since we need more eyes and stars on this project

Collapse
 
pluno profile image
Pluno

✨️

Some comments may only be visible to logged-in visitors. Sign in to view all comments.