Types & Internals
Types
ForwardInfo
Forwarding attribution attached to forwarded messages. This is a display-level hint, not a cryptographic proof.NetworkTopology
MessageDeliveryStats
RouteEntry
RoutingStats
GradientRoutingConfig
DedupStats
FileProgress
MLS Types
ProtocolState
DORS (Dynamic Offline Relay Switch)
DORS automatically selects the optimal transport based on real-time conditions.Scoring Factors
| Factor | Description |
|---|---|
| Signal Strength | RSSI for BLE/WiFi (-50 to -100 dBm) |
| Proximity | Hop count to destination |
| Bandwidth | Transport throughput capability |
| Congestion | Queue depth and backlog |
| Energy | Battery impact of transport |
| Reliability | Historical delivery success rate |
| Load | Current processing capacity |
Transport Weights
BLE: Optimized for energy efficiency and mesh scenarios- Signal: 30%, Energy: 30%, Congestion: 15%, Proximity: 15%
- Bandwidth: 35%, Proximity: 20%, Congestion: 20%, Reliability: 15%
- Bandwidth: 35%, Reliability: 30%, Congestion: 15%, Energy: 10%
Switching Safeguards
| Safeguard | Default | Description |
|---|---|---|
| Hysteresis | 15 points | Minimum score improvement to switch |
| Cooldown | 20 seconds | Wait time between switches |
| Stability Window | 8 seconds | Transport must be stable before switching |
Mesh Networking
Cluster Architecture
Devices organize into clusters (groups of nearby connected peers). Connections between clusters are handled by bridge connections. Connection Roles:MEMBER- Intra-cluster connection (devices in same neighborhood)BRIDGE- Inter-cluster connection (bridges different neighborhoods)
How It Works
- Discovery: Devices broadcast BLE advertisements with mesh metadata (degree, free slots, battery, uptime)
- Cluster Detection: Each device computes a cluster signature from connected peer hashes
- Connection Decisions: MeshController evaluates candidates - prioritizes bridging different clusters
- Rebalancing: Periodically swaps lower-quality peers for better candidates or bridge opportunities
- Delivery: Messages sent to connected peers
Connection Budget
- Default: 4 connections per device
- Minimum: 1 connection maintained
- Connections are scored and rebalanced every ~15 seconds
- Bridge candidates get priority when clusters need unifying
Peer Scoring
| Factor | Weight | Description |
|---|---|---|
| RSSI | 35% | Signal strength to peer |
| Availability | 20% | Free connection slots |
| Uptime | 15% | How long peer has been active |
| Battery | 15% | Peer’s battery level |
| Stability | 10% | Connection reliability history |
| Load | 5% | Current processing load |
bridgeFavor: 0.1) to encourage network unification.
Message TTL
- Default: 8 hops
- Messages are dropped when TTL reaches 0
- Prevents infinite message circulation
Reliability Layer
Acknowledgments
- Messages require ACK for delivery confirmation
- Default timeout: 5 seconds
message_deliveredevent fires on ACK receipt
Retry Queue
- Failed messages are retried with exponential backoff
- Initial delay: 1 second
- Maximum delay: 30 seconds
- Maximum retries: 5
Deduplication
Prevents duplicate message processing:- Bloom Filter Mode: Space-efficient, ~1% false positive rate
- HashMap Mode: Exact tracking, configurable capacity
Troubleshooting
Messages Not Delivering
- Verify both devices have protocol started
- Check they’re within BLE range (~10-30m)
- Ensure TTL is sufficient for network size
- Monitor
message_failedevents for retry information - Check
getEstablishmentState()if encryption is required
No Peers Discovered
- Verify Bluetooth is enabled:
await protocol.isBluetoothEnabled() - Check permissions are granted
- Ensure background modes enabled (iOS)
- Verify devices are within range
Secure Session Not Establishing
- Ensure encryption is enabled (default: true)
- Check
getEstablishmentState(peerId)for current state - Verify
hasPendingKeyPackage(peerId)returns true - Check for
secure_session_failedevents - Try
resetTofuForPeer(peerId)if key mismatch is suspected
Frequent Disconnections
- Check signal strength via
neighbor_discoveredRSSI - Increase
stabilityWindowSecsin DORS config - Reduce
rebalanceIntervalfrequency - Check for BLE interference
High Battery Drain
- Reduce connection count (native mesh config)
- Verify DORS is selecting BLE over WiFi Direct
- Check for excessive retry activity
- Use
setBatteryLevel()to inform mesh decisions
Transport Not Switching
- Verify transport is enabled in config
- Check hysteresis threshold isn’t too high
- Ensure cooldown period has elapsed
- Use
forceTransport()to test manually
Linking Error
If you see the linking error message:- Run
pod install(iOS) - Rebuild the app after installing
- Verify not using Expo Go (native modules required)