MeshCore routing algorithms
Every message traversing the LocalMesh network makes autonomous routing decisions. Understanding these algorithms helps you deploy more effective nodes and troubleshoot coverage gaps.
How does a message find its way through the mesh network?
Traditional networks rely on routers with preconfigured paths. A mesh network has no such luxury. When a rambler in the Peak District sends a message, no central authority exists to direct it toward Birmingham.
Instead, MeshCore uses a hybrid model: discovery flood via repeaters when needed, then more targeted forwarding over learned paths.
This guide explains precisely how MeshCore routing functions, which optimisations conserve airtime and battery, and how you can tune routing behaviour for your specific deployment across Britain.
Basic routing protocol mechanisms
Four fundamental mechanisms underpin MeshCore routing:
Discovery flood + learned paths
Initial delivery can use discovery flood through repeaters. After delivery feedback, follow-up traffic can use a known path rather than flooding every attempt.
Duplicate detection
Every message carries a unique identifier. Nodes maintain a cache of recently-seen IDs, discarding duplicates that arrive via alternative paths.
Hop count limiting
Hop controls prevent uncontrolled propagation. MeshCore supports higher protocol hop ceilings (up to 64), while practical propagation is tuned on repeaters (for example via flood.max).
Repeater-scoped forwarding
Forwarding is a repeater/relay role rather than universal client behaviour, which keeps airtime use more predictable.
How flooding routing works
The flooding algorithm forms the heart of MeshCore routing. Follow a message as it traverses the network:
Step 1: message is sent
A user in Edinburgh sends a message to a destination without a known path. The packet is prepared and emitted over LoRa.
Step 2: nearby repeaters forward
Repeaters in range process and deduplicate the message. Clients can receive traffic, but they are not the general forwarding layer.
Step 3: route learning
On successful delivery, MeshCore can learn repeater path information for later unicast traffic.
Step 4: targeted follow-up traffic
Subsequent messages can follow the learned path, reducing unnecessary network-wide propagation.
Flooding optimisations
Raw flooding would overwhelm any network. MeshCore applies these refinements:
- • Message deduplication: Identical messages arriving via different paths are forwarded only once, preventing exponential traffic growth.
- • Path learning: successful delivery can produce route information for direct follow-up forwarding.
- • Repeater flood controls: operators tune propagation limits (such as flood.max) to protect airtime.
- • Role separation: clients focus on end-user messaging while repeaters handle forwarding.
Hop limiting mechanism
Protocol hop ceiling
MeshCore documentation references an internal maximum of 64 hops at protocol level.
Operational tuning
Real-world propagation is tuned at repeater level (for example flood.max) to match local density and airtime budget.
Range depends on deployment
Per-hop distance depends on terrain, antenna quality, RF noise floor, and repeater placement.
How hop counting works
Every packet header includes a hop_limit field. Each forwarding node increments this counter:
Initial delivery: discovery flood via repeaters Delivery success: path information can be learned Follow-up unicast: forwarded over learned repeater path Flood control: tuned on repeaters (e.g. flood.max)
This mechanism prevents messages from circulating indefinitely, conserving precious battery power and leaving airtime available for new communications.
Advantages of MeshCore routing
Self-organising
No network administrator configures routing tables. Nodes discover each other automatically, adapting to additions and failures without intervention.
Energy-efficient
Optimisations ensure only necessary transmissions occur. Battery-powered nodes can run for days whilst still contributing to network coverage.
Robust against failure
If a repeater fails on the South Downs, messages automatically route via alternative paths. The network heals without anyone noticing.
Scalable range
Adding nodes extends coverage proportionally. A repeater on the Malvern Hills might bridge entire counties with no configuration changes.
Simple protocol
Flooding-based routing requires minimal state maintenance compared to complex link-state protocols. This simplicity aids debugging and reduces firmware complexity.
No single point of failure
With no central router, no single component can bring down the network. Even losing half the nodes leaves remaining devices communicating.
Routing configuration examples
Adjust routing behaviour through the MeshCore CLI or Python API:
CLI: set hop limit
Extend range for rural deployments spanning the Scottish Highlands:
MeshCore --set router.hop_limit 5 MeshCore --set router.rebroadcast_mode ALL_SKIP_DECODING
Python API: routing configuration
Automate deployment configuration across multiple nodes:
import MeshCore
interface = MeshCore.SerialInterface()
node = interface.getNode("^local")
# Set routing parameters
node.router.hop_limit = 4
node.router.rebroadcast_mode = MeshCore.Router.ALL_SKIP_DECODING
node.writeConfig()
Advanced: rssi threshold
Ignore weak links that might cause unreliable forwarding:
MeshCore --set router.rebroadcast_min_rssi -120 # -120 dBm = very weak Signal # -100 dBm = average Signal (recommended) # -80 dBm = strong Signal
Frequently asked questions about routing
Does MeshCore only use flooding?
No. Discovery can use flood behaviour, then MeshCore can forward later unicast traffic over learned repeater paths.
What happens if two nodes forward a message simultaneously?
Random backoff delays make simultaneous transmission unlikely. When collisions do occur, other network nodes typically receive at least one copy successfully, maintaining message delivery.
Can I set different hop limits per message type?
Operational behaviour is typically tuned by repeater policy and node role, keeping routine traffic constrained while preserving reach for priority use.
How does MeshCore prevent route loops?
Duplicate detection combined with hop counting eliminates loops. A message cannot revisit a node (duplicate detection) and eventually expires (hop limit) regardless of network topology.
What latency should I expect?
Latency depends on RF conditions, spreading factor, queue depth, and repeater policy. Validate with field tests in your own deployment area.
Can I disable routing for my node?
Yes. Setting rebroadcast_mode to "NONE" creates a leaf node that receives messages but never forwards. Useful for battery-critical portable devices.
Start with MeshCore routing development
The MeshCore routing protocol enables resilient, self-healing communication across Britain without dependence on internet infrastructure. Understanding these mechanisms helps you deploy more effective networks.