Inspiration

During catastrophic natural disasters—such as earthquakes, severe monsoon floods, and hurricanes—cellular infrastructure is among the very first systems to collapse. Power grids fail, mobile base transceiver stations (BTS) shut down, and fiber optic backhauls sever. Instantly, victims and first responders are left holding modern smartphones that are reduced to completely inert bricks.

Traditional consumer communication applications unconditionally rely on centralized client-server backbones. When the server is unreachable, the application is useless. We asked ourselves a fundamental question: Why should two human beings standing 100+ meters apart need a distant cellular tower or a cloud datacenter in another continent to exchange a life-saving message?

This sparked the creation of RelayNet 2.0: an autonomous, decentralized, and self-healing Mobile Ad-Hoc Network (MANET) protocol engineered to transform everyday smartphones into physical, multi-hop relay nodes—operating with Zero Cellular Towers, Zero Wi-Fi Routers, and Zero Centralized Servers.


What it does

RelayNet 2.0 establishes a spontaneous, self-forming wireless mesh network purely over device-to-device radio links (Bluetooth Low Energy and high-throughput Wi-Fi Direct).

  • 📢 Public Emergency Mesh Broadcast: Survivors and rescue workers can send emergency broadcasts and critical distress alerts (🆘 SOS). Messages propagate autonomously across intermediate hops using store-and-forward gossip flood routing with Time-To-Live (TTL=3) limits.
  • 🎙️ Tactical Walkie-Talkie Push-to-Talk (PTT): When rapid tactical coordination is needed, responders can hold a single button to transmit clear voice notes. Utilizing ultra-efficient AMR-NB compression at 1.5 KB/sec, a 2-second voice note produces a tiny 3 KB payload that delivers with sub-100 millisecond airtime latency.
  • 🔒 Zero-Trust ECDH + AES-CTR Confidential Whispers: While public disaster alerts reach everyone, sensitive operations (casualty counts, tactical movements) can be conducted via confidential 1-on-1 sessions. Nodes exchange EC public keys upon link initiation, encrypting payloads with AES in Counter Mode (AES-CTR). Relaying nodes only see encrypted ciphertext.
  • ✨ Intelligent Peer Indicators: When a targeted private message arrives while the user is viewing the public emergency feed, the sender's node chip in the peer bar lights up with a vibrant, non-intrusive neon-green border and an eye-catching [NEW] badge.
  • 🧠 On-Device Edge NLP Triage Engine: Zero cloud models required. A localized morphological stemming and fuzzy matching engine analyzes distress payloads in real-time across both English and Roman Urdu keywords (zakhmi, fire, trapped, blood, accident), automatically tagging messages with visual hazard badges to prioritize critical casualties.
  • 📊 Integrated MANET Telemetry Suite: Built directly into the client, users and researchers can run automated packet sequence benchmarks (N test packets) to measure Round-Trip Time (RTT), one-way latency, hop counts, and Packet Delivery Ratio (PDR), with one-tap export to CSV.

How we built it

RelayNet 2.0 is engineered from the ground up in Kotlin 1.9 for modern Android devices:

  • Mesh Transport Layer: Built on Google Nearby Connections API utilizing the P2P_CLUSTER topology. We decoupled peer discovery onto low-power Bluetooth Low Energy (BLE) while steering actual payload transmission dynamically across multi-channel Wi-Fi Direct.
  • Persistence & Anti-Entropy Synchronization: Backed by an offline Room Database (SQLite). When nodes reconnect after temporary radio obstruction, they exchange lightweight 64-bit ID hashes (SYNC_CATALOG) to backfill missed distress packets without causing redundant network flood storms.
  • Audio Engineering: Custom audio pipeline leveraging Android native MediaRecorder and MediaPlayer targeting Adaptive Multi-Rate Narrowband (AMR-NB) at an 8 kHz sampling rate with a 12.2 kbps bitrate, fitting tactical voice notes neatly within single frame radio payloads.
  • Asymmetric & Symmetric Cryptography: Automated Elliptic Curve Diffie-Hellman (ECDH) key agreement coupled with AES-CTR encryption using Android KeyStore-backed key material.
  • Modern Reactive UI: Engineered using Jetpack Compose and Material Design 3, featuring single-row ergonomic touch targets, dynamic radar pulsing indicators, and real-time StateFlow reactive UI state streams.

Challenges we ran into

Developing an industrial-grade ad-hoc mesh protocol on commercial, off-the-shelf mobile hardware presented several fundamental physical and architectural hurdles:

1. 🔋 Radio Power & Battery Optimization

Continuous peer discovery and Wi-Fi Direct polling can aggressively drain device batteries. Early implementations that held aggressive high-performance Wi-Fi locks consumed upwards of 350–400 mAh.
Solution: We completely eliminated continuous infrastructure STA locks (WIFI_MODE_FULL_LOW_LATENCY) and restructured the background mesh service around a lean, CPU-only PowerManager.PARTIAL_WAKE_LOCK. This keeps the packet-relaying loop responsive in the background while allowing the radio baseband and display to sleep dynamically, reducing continuous battery consumption by over 65% (down to ~35–50 mAh per hour).

2. 📏 Physical RF Propagation & Range Reality

Consumer smartphone 2.4 GHz and 5 GHz radios have finite physical limits. Line-of-sight propagation is susceptible to ground multipath fading, while indoor environments suffer extreme attenuation through reinforced concrete.
Solution: Rather than making unrealistic single-hop claims, we architected multi-hop gossip routing. Through empirical validation in open sports fields, we achieved 180+ meters reliable direct Line-of-Sight single-hop transmission. For non-line-of-sight and room-to-room dead zones (where single-hop spans 10–15 meters through brick walls), our autonomous store-and-forward intermediate relaying successfully bridges spans exceeding 300+ meters.

3. 🌐 Dense-Network Collisions & Over-the-Air Stalls

When two adjacent nodes discover each other simultaneously, both calling connection requests over-the-air results in fatal radio collisions (Nearby Connections status 8003/8002).
Solution: We implemented a deterministic lexicographical tie-breaker. The node with the higher unique alphanumeric device ID initiates connection negotiations immediately, while the lower node yields for 4.5 seconds to accept incoming handshakes. Furthermore, in-memory seen-message hash sets (seenMessageIds) eliminate infinite routing loops and broadcast storms.

4. ⚡ Socket Lifecycle & Ghost Peer Pruning

In mobile mesh networks, nodes are physically mobile; sockets disconnect abruptly when a relay node walks out of range. Uncaught exceptions on broken virtual output streams previously stalled background coroutines.
Solution: We wrapped all socket write operations in resilient fault handlers. When an endpoint drops, RelayNet immediately purges the dead socket, cleanses the active peer routing table, and broadcasts a lightweight PEER_LOST gossiped packet across the mesh to ensure ghost peers do not linger in nearby devices' routing tables.

5. 📱 Multi-OEM Android Fragmentation

Different Android OEMs (Samsung, Xiaomi, Oppo, Pixel) implement aggressive background battery killer daemons and non-standard Wi-Fi Direct driver handshakes.
Solution: We tuned connection lifecycles across Android API 26 (Android 8.0) all the way up to API 35 (Android 15), supporting dual-radio fallback and bundling offline sideloading capabilities so RelayNet can be transferred phone-to-phone via Quick Share, ShareMe, or Bluetooth.


Accomplishments that we're proud of

  • Empirical 94.2% Packet Delivery Ratio (PDR): Validated through automated 500-packet stress runs in open and obstructed environments.
  • Sub-100ms Tactical Voice Latency: Enabling near real-time walkie-talkie communication between disconnected nodes without internet or infrastructure.
  • Zero-Cloud Bilingual NLP Triage: Successfully classifying urgent casualty and hazard signals on-device across both English and Roman Urdu colloquial terms.
  • Scientific MANET Telemetry: Integrating an academic-grade telemetry benchmarking engine that computes real-world RTT latency and hop count with instant CSV export for data science verification.

What we learned

  • Mobile Ad-Hoc Networks (MANETs) on consumer smartphones are intensely constrained by physical RF physics; multi-hop gossip with strict deduplication is vastly superior to rigid routing trees.
  • Efficient data serialization and codec selection (such as AMR-NB over raw PCM) make the difference between a packet fitting into a single unfragmented radio burst or dropping entirely.
  • True disaster resilience requires designing for zero assumptions: no internet, no SIM, no background cloud services, and zero user configuration.

What's next for RelayNet 2.0: Offline Mesh Network

  • LoRa Hardware Bridge: Integrating USB-OTG and BLE bridges to long-range LoRa transceivers (SX1262 / SX1276) for 5+ kilometer inter-cluster gateway hops.
  • Geographic Coordinate Mesh Routing: Embedding GPS coordinates into emergency envelopes to visualize a live, off-grid GIS casualty heatmap.
  • Public First Responder Sideloading: Collaborating with disaster management authorities and search-and-rescue teams for field deployment trials during seasonal flood evacuations.

Built With

  • aes
  • aes-ctr
  • andriodkeystore
  • android
  • apiandroid
  • ble
  • compose
  • connections
  • coroutinesstateflow
  • ctr
  • database
  • design
  • direct
  • ecdh
  • foreground
  • google
  • jetpack
  • kotlin
  • material
  • nearby
  • nlp-triage
  • serviceroom
  • sqlite
  • telemetry
  • wifi
Share this project:

Updates

Submission history