Autonomous Drone Mesh DTN: Disaster Response System
An offline-first, dual-radio Delay-Tolerant Networking (DTN) drone platform delivering zero-install survivor triage, cryptographically signed store-and-forward sync, and live flight control without cloud or cellular networks.
Verified results and performance
Project details
- Role
- Embedded & Full-Stack Systems Engineer (Final-Year Project, Team of 4)
- Timeline
- 2025 to 2026
- Tracks
- embedded, software
Technologies and skills
Abstract
In post-disaster scenarios (earthquakes, floods, landslides), cellular base stations collapse and GPS locks fail under dense canopy or rubble. Aero-Link is an offline-first Delay-Tolerant Drone Mesh Network (DTN) running on UAV-mounted Raspberry Pi 4 edge nodes (DRONE_A, DRONE_B, DRONE_S). Rather than single-radio AP/client time-slicing or complex multi-hop routing (802.11s), Phase 2 isolates an always-on 5 GHz user Access Point (wlan0) from a 2.4 GHz AR9271 IBSS ad-hoc cell (wlan1, fixed BSSID 02:12:34:56:78:9A), allowing victims to stay connected uninterrupted while drones exchange signed UDP presence beacons and pull-sync deltas over HTTPS. To survive GPS-denied clock jumps and out-of-order reboots, replication uses monotonic local_seq cursors and boot_id beacon epochs alongside HKDF-SHA256 purpose-separated keys (K_MSG, K_SYNC, K_TOKEN) and Fleet Root CA pinning. Hardware nodes pair a Seeed Studio XIAO ESP32-C3 aux module (INA3221 bidirectional dual-battery sensing, TinyGPS++, NimBLE AD Type 0x07 discovery, RFM95 915 MHz LoRa watchdog fallback) with a live CC3D MAVLink gateway on DRONE_S, operated through three offline-first Flutter applications (GCC desktop, Rescue App, Emergency App).
The Spark: From Phase 1 Time-Slicing to a Phase 2 Clean Rebuild
In post-disaster scenarios such as earthquakes, floods, and landslides, cellular base stations lose power or backhaul connectivity while dense canopy and rubble block GPS signals. Trapped civilians cannot install apps or bypass TLS warnings, and rescue teams operate blind across disconnected field sectors.
Phase 1 proved end-to-end message propagation across Raspberry Pi nodes, but exposed seven severe architectural limits: cycling a single Wi-Fi radio between Access Point and client modes kicked connected victims off Wi-Fi for ~40 seconds every cycle, sync failed if two nodes entered client windows simultaneously, field reports never replicated, and Bluetooth inquiry scanning failed to wake civilian phones.
"In a disaster zone, connectivity honesty and zero-drop user access matter more than assuming real-time links exist everywhere."
Instead of patching stale state, Phase 2 executed a clean scripted rebuild from blank SD cards featuring dual-radio networking, clock-independent DTN sync, layered edge security, a unified ESP32-C3 hardware aux module, a live MAVLink control gateway, and a cross-platform Flutter suite.
The physical System Drone (DRONE_S / AeroSync 5) 225 mm quadcopter carrying a Raspberry Pi 4 companion computer and dual AR9271 radios.
Dual-Radio Networking & System Architecture
Each drone node runs the exact same software image, specialized only by per-node config files (DRONE_A, DRONE_B, DRONE_S). Crucially, each node separates user access and inter-drone synchronization onto two physically distinct Wi-Fi interfaces:
- Why IBSS Over 802.11s and AP/Client Cycling (Decision D2): Because the Raspberry Pi 4's onboard
brcmfmacchip does not support IBSS mode, an external AR9271 (ath9k_htc) USB adapter handles the 2.4 GHz IBSS cell (RESCUE_DTN, pinned BSSID02:12:34:56:78:9Aso split cells never form), leaving onboardwlan0dedicated permanently to the 5 GHz victim/rescuer AP (RESCUE_x). Complex 802.11s + BATMAN-adv multi-hop routing was deliberately rejected as unnecessary failure-mode overhead for a three-node DTN fleet. - Honest Connectivity Model: The Ground Control Center joins one node in range (
https://10.42.0.1:8443) and never fabricates live global state. Every UI surface explicitly renders data freshness (formatAge()) reflecting the last successful DTN sync or fallback LoRa beacon.
Civilian Phone / Rescue Phone / GCC Desktop
│
│ (Always-on 5 GHz AP: RESCUE_A/B/S @ 10.42.0.1)
▼
+-------------------------------------------------------------------+
| UAV EDGE NODE (Raspberry Pi 4 Model B) |
| |
| wlan0 (onboard brcmfmac) -> Permanent 5 GHz User AP (10.42.0.1) |
| wlan1 (AR9271 ath9k_htc) -> 2.4 GHz IBSS Cell (10.99.0.1/.2/.3) |
| aux (XIAO ESP32-C3) -> INA3221, TinyGPS++, NimBLE, RFM95 |
| fc (DRONE_S only) -> CC3D Serial <-> UDP :14550 MAVLink |
+-------------------------------------------------------------------+
│
│ (2.4 GHz IBSS Ad-Hoc Cell: RESCUE_DTN, Ch 6 / 2437 MHz)
│ (Fixed BSSID 02:12:34:56:78:9A prevents IBSS split-cells)
▼
[ Neighboring Drone Nodes (Store-and-Forward HTTPS Pull Sync) ]
System architecture spanning Civilian Access, Dual-Radio Drone DTN Mesh, and Ground Control / Rescue operations.
Distributed Systems & Clock-Independent Sync
Maintaining consistent shared state across intermittently connected drones in GPS-denied terrain required solving three core distributed systems failures:
1. Monotonic Sequence Replication (local_seq) vs. Wall Clocks
- The Problem: Raspberry Pi 4 nodes lack battery-backed Real-Time Clocks (RTC). In GPS-denied indoor or jungle zones, nodes boot to epoch dates (
1970) or stalefake-hwclocktimes before acquiring GPS fixes. LegacyWHERE local_ts > cursorsynchronization silently dropped victim messages created during backward clock jumps. - The Solution: Upgraded
sync_engine.pyand SQLite schema v3 to track per-table monotonic sequence cursors (local_seq) locally per node (GET /sync/<table>?since_seq=...). Nodes replicate every new row deterministically regardless of wall-clock skew, while keeping signed origin timestamps (updated_at) for semantic conflict resolution and marking pre-fix timestamps as relative (time_source = 'relative').
2. Boot-Session Epochs (boot_id) on Signed UDP Beacons
- The Problem: Signed UDP presence beacons on port
48555(10s broadcast interval) use monotonic counters to block replay attacks. However, when a drone rebooted and reset its counter to1while peers had already recorded counter500, peers permanently rejected all beacons as replays until databases were wiped. - The Solution: Added a per-boot
boot_idUUID alongside the counter inside canonical HMAC verification (_beacon_payload_canonical). Peers still reject duplicate/older counters inside the active epoch, but seamlessly reset the peer replay window when a valid signed beacon presents a newboot_id.
3. Per-Table Conflict Resolution & Selective Non-Replication
All replicated tables (messages, personnel, personnel_locations, announcements, gs_messages, checkins, message_replies, lora_events) are registered centrally in REPLICATED_TABLES with per-table error isolation:
messages:CLAIMEDstrictly overridesNEW; ties between dual offline claims resolve deterministically to the earliest signedclaimed_at.personnel:REVOKEDpermanently overridesACTIVEacross all hops to lock out compromised responder accounts immediately.message_replies: Indexed byvictim_device_idand replicated fleet-wide so a victim who switches drones on a second pass still receives replies written earlier.lora_eventsvs.node_health: LoRa fallback receptions derive their primary key deterministically from frame content + listeningnode_idso two drones hearing the same downed drone produce two corroborating evidence rows without duplicating on re-sync. Meanwhile,node_healthis deliberately not replicated so stale self-opinions never poison live fleet health;DEGRADEDstatus is always derived from fresh evidence (FALLBACK_EXPIRY = 120s) rather than permanently latched flags.
Layered Edge Security Architecture
Designed around an explicit threat model across isolated trust boundaries with zero cloud identity dependencies:
- HKDF-SHA256 Purpose Key Separation (
crypto_keys.py): Derives three cryptographically isolated 256-bit keys (K_MSG,K_SYNC,K_TOKEN) from one deploy-generatedNODE_MASTER_SECRET(salt="rescue-mesh-phase2-v1"). Compromising an inter-node header (X-Node-Auth) cannot forge victim triage records or mint responder tokens. - Fleet Root CA Pinning:
deploy/make_fleet_ca.shgenerates a fleet Root CA and per-node TLS certificates for HTTPS port8443. All Flutter clients embed the Root CA viaRescueMeshClientinshared_dartand fail closed against evil-twin access points. - Network Segregation (HTTP :80 vs. HTTPS :8443) & Privacy:
http_app.pyserves captive portal detection probes (RFC 7710), form intake, and/area-map(returning positions only, stripping content and user IDs) over plain HTTP so panicked civilians face zero TLS warning friction, while signing every ingested record withK_MSGat write time. - Stateless Offline Responder Auth & Carried QR Enrolment:
POST /auth/loginverifies 16-byte salted PBKDF2-SHA256 (100,000 iterations) PIN hashes viahmac.compare_digestand mintsK_TOKEN-signed tokens (base64url(payload).hmac), validated locally on any drone even before sync converges (session_clocktolerates clock offsets via local monotonic deadlines). Field rescuers issued credentials at Drone A can carry their HMAC-signed record in a QR code and self-enrol at an unsynced Drone B viaPOST /enrol(ingest_personnel). - Anti-DoS Rate Limiting & Log-Injection Defense:
ratelimit.pyenforces thread-safe sliding-window per-IP and global write caps (GlobalLimiter) to withstand MAC/DHCP-spoofing floods on the open captive portal.audit.pypasses every external string (SOS messages, LoRa payloads) through_SanitiseFilter, escaping non-printable control characters (\x00-\x1f,\x7f) to keep the shared audit log tamper-proof and grep-safe.
Edge Stack, ESP32-C3 Aux Hardware & System Drone
On every Raspberry Pi 4 node running SQLite in WAL mode (PRAGMA journal_mode=WAL), dedicated systemd daemons manage each boundary cleanly:
- Seeed Studio XIAO ESP32-C3 Aux Module (
firmware/aux1/src/main.cpp):- Symmetric Watchdog State Machine (
INIT -> NORMAL <-> FALLBACK): Monitors Pi keep-alive pings over native USB CDC serial. After 15 seconds of Pi silence (following startup grace), transitions intoFALLBACKand beacons compactFB|pipe-delimited frames (carryingnode_id, GPS fix, battery, and flash-cached last SOS summary) over RFM95 LoRa (915 MHz, SF7, BW 125 kHz) every 30s; recovers cleanly back toNORMALafter 3 consecutive Pi pings (15s hysteresis) so transient daemon restarts never permanently trap a healthy drone. - INA3221 Bidirectional Sensing & Bench Hardware Fixes: Monitors two flight battery packs (
0.100 ohmshunts) separating charging (current < 0) from discharging (current > 0) via compiler-safe explicit 13-bit mask/subtract sign extension (ina13Bit()), with NVS-persisted channel presence flags (battAPresent/battBPresent) eliminating phantom ~4.18 V readings on unwired floating channels. Bench debugging also caught and documented moving LoRa SPI MISO from D9 to D0 (GPIO2) and placing the fixed 128-bit NimBLE UUID (2b57461c-1c04-49c4-944a-13643c1618da) in AD Type0x07complete-services list so phone background BLE scanners reliably wake on nearby drones.
- Symmetric Watchdog State Machine (
- System Drone
DRONE_S(mavlink_gateway/mav_gateway.py):- Fitted with a second AR9271 adapter so it participates as a full IBSS mesh peer while bridging raw MAVLink bytes bidirectionally between its CC3D Open Revolution Mini flight controller serial port and UDP
:14550. Commands are strictly live (never store-and-forwarded), reachable either directly (10.42.0.1:14550) or relayed over the mesh through volunteer nodes (10.99.0.3:14550), firewalled vianftables, heartbeat-gated (linkFresh < 2s), and bench-verified props-off viaDO_MOTOR_TESTand force-disarm (21196).
- Fitted with a second AR9271 adapter so it participates as a full IBSS mesh peer while bridging raw MAVLink bytes bidirectionally between its CC3D Open Revolution Mini flight controller serial port and UDP
deploy/systemd/ Service Units:
dtn-net.service Brings up wlan1 AR9271 IBSS cell (RESCUE_DTN)
rescue-portal.service http_app.py on HTTP :80 (CAP_NET_BIND_SERVICE)
rescue-mesh-api.service api.py on HTTPS :8443 (Fleet-CA TLS + Auth/Sync)
rescue-mesh-sync.service sync_daemon.py (UDP :48555 beacons + pull sync)
rescue-mesh-auxbridge.service aux_bridge.py (115200 USB CDC JSON <-> ESP32-C3)
rescue-mesh-mavgw.service mav_gateway.py (DRONE_S CC3D serial <-> UDP :14550)
rescue-mesh-firewall.service nftables rules locking down internal ports
Zero-install victim portal: RFC 7710 captive detection, plain HTTP guidance, and signed local SQLite persistence.
Cross-Platform Flutter Client Suite & Mission Layer
shared_dart: Unified models (BatteryState,SessionClock,ConversationThread) and Fleet-CA pinning HTTP client shared across all three Flutter apps.- Ground Control Center (
gcc_app, Desktop):- Offline MBTiles Tactical Map & Explicit Modes: Prevents accidental taps during high-stress ops; hides unapproved AI plan drafts from the live operations overlay by safety invariant (
draft_visibility_test.dart). - Mission Layer & Fleet Simulator: Models
MissionState, validates mission placements against UAV specs + radio reach (MissionValidator), supports an OpenAI-compatible tactical advisor returning JSON validated before operator approval, and runs both REAL (DRONE_SMAVLink withSYS_STATUSbattery watchdog) and DEMO fleet lifecycles (enforcing a1.5xreturn-to-home battery reserve auto-RTL rule).
- Offline MBTiles Tactical Map & Explicit Modes: Prevents accidental taps during high-stress ops; hides unapproved AI plan drafts from the live operations overlay by safety invariant (
- Rescue Team App & Emergency App (
rescue_app,emergency_app):- Rescuers scan HQ credentials via QR (handling noisy arbitrary barcodes gracefully), push foreground GPS heartbeats, claim survivor tickets, and exchange multi-hop replies.
- Civilians use local BLE drone proximity radar (with per-drone cooldown deduplication) and dynamically fetch
/portal-optionssynced by content fingerprint from whichever node is in range.
Ground Control Center desktop UI displaying fleet status, victim distress queue, and tactical operations map.
Flutter mobile clients: Rescue Personnel dispatch workflow, BLE drone scanner, and Emergency civilian check-in UI.
Automated Verification & Hardware Simulation
| Suite / Module | Tooling | Verified Coverage | Key Invariants Verified |
|---|---|---|---|
Node Backend (backend/tests/) | pytest | 106 passed | local_seq clock-skew immunity, boot_id epoch transitions, CLAIMED/REVOKED precedence, HKDF token verification, GET /area-map anonymization, audit log sanitization (test_audit_sanitise.py), sliding-window DoS caps. |
GCC Desktop (gcc_app/test/) | flutter test | 94 passed | Unapproved AI plan invisibility, MAVLink binary command framing, fleet 1.5x RTH reserve math, mission range/battery feasibility checks, UI empty/gated smoke coverage. |
Emergency & Shared (emergency_app/, shared_dart/) | flutter test, dart test | 44 passed (23 + 21) | BLE AD payload parsing & cooldown logic, local location ring buffer, offline clock-skew session deadline checks, signed bidirectional BatteryState classification, plus live backend client tests. |
Hardware & Multi-Node Integration (tools/) | PTY serial, bash loopback | Interactive scripts | tools/aux_bridge_pty_test.py & tools/mavgw_pty_test.py validate USB/FC serial framing and MAVLink read-only tapping without hardware; tools/local_two_node_test.sh runs two isolated backend nodes on loopback to assert full DTN convergence. |
Discuss this project
Have questions about the architecture or design decisions?