Mesh networking

How does a message cross a mesh network?

A message crosses a mesh network by hopping from device to device until it reaches its destination. Each device that receives it decides whether to deliver it, forward it, or drop it, using the message's destination, a hop limit, and a record of the messages it has already seen.

TL;DR

Devices keep listening for neighbours, pass a message on by flooding or along a learned route, and stop loops with a hop limit and duplicate suppression. Acknowledgments with retries confirm arrival, store-and-forward holds messages when no path exists, and end-to-end encryption hides content from relays. An acknowledgment means the message reached the recipient's device, not that the app stored it.

Learning objectives

After reading this article you will be able to:

  • Explain how a message hops across several devices to reach its destination
  • Compare flooding with route-based forwarding across a mesh
  • Describe how hop limits, duplicate checks and acknowledgments keep delivery under control

Neighbour discovery in a mesh network

Before anything can be relayed, each device needs to know who is in range, and it finds out by listening for announcements. Radios such as Bluetooth Low Energy do this with advertising: a device broadcasts small packets at intervals, and devices scanning nearby hear them. On a local IP network, devices can announce themselves with a discovery protocol such as multicast DNS.

The result is a list of direct neighbours. It changes constantly as devices move, sleep, or go out of range, so a mesh has to keep listening rather than discover once.

Flooding vs routing for the next hop

A mesh either floods the message to every neighbour or routes it along one learned path. These are the two broad approaches, and many real systems mix them.

Flooding. The sender broadcasts the message to every neighbour, and each node that hears it for the first time broadcasts it again. Flooding needs no map of the network and finds a path if one exists, which makes it tolerant of devices that move quickly. The cost is that many nodes transmit every message, so it uses more airtime and battery as the network grows. Bluetooth Mesh uses a managed form of flooding, in which only nodes with the relay feature enabled pass messages on.

Routing. Nodes learn which neighbour leads toward which destination and send each message along one path. Proactive protocols such as OLSR (RFC 3626) keep routes up to date all the time. Reactive protocols such as AODV (RFC 3561) look for a route only when there is something to send. Routing uses far less airtime, but it depends on fresh knowledge of the network, which is harder to keep when devices are moving.

The sender and recipient are never in range of each other. The message reaches the recipient in three hops through two relays; the grey devices are other paths it could have taken.

Loop prevention with hop limits and duplicate suppression

A hop limit and duplicate suppression stop a message from looping forever. In a mesh, the same message can reach a node more than once, by different paths, and without limits it could circle forever.

  • A hop limit. The sender sets a time to live (TTL), a count that each relay lowers by one. When it reaches zero, the message is not forwarded again. It is the same idea as the time to live field in an IPv4 header (RFC 791) and the hop limit in IPv6 (RFC 8200).
  • Duplicate suppression. Every message carries a unique identifier. Each node remembers the identifiers it has handled recently and drops any copy it has already seen.

The hop limit also sets how far a message can travel. A higher limit reaches further but lets each message use more of the network, so it is a trade-off rather than a setting to maximise.

Delivery acknowledgments and retries

Reliable meshes add acknowledgments: the recipient sends a small confirmation back, and the sender retries if none arrives within a timeout, usually waiting longer before each attempt. This is called exponential backoff. Radio links lose packets, and a relay can walk out of range halfway through a route, so a mesh that only forwards and forgets gives the sender no idea whether anything arrived. Because retries create more copies, they rely on duplicate suppression so that the recipient handles the message once.

Duplicate suppression also has to let a genuine retry cross every hop. From 0.33.0 the Offline Protocol mesh SDK gives a resend sent a full acknowledgement timeout after the previous one a new resend generation, at most three, and relays carry each generation once. In a simulated crowd of forty phones, every delivery receipt now comes back.

When there is no path at all, a mesh can hold the message and try later instead of failing. That is store-and-forward.

As one concrete example, the Offline Protocol mesh SDK documents these defaults for version 0.33.0: messages start with a TTL of 8 hops, an acknowledgment times out after 10 seconds, a message is retried up to 10 times with backoff from 1 to 300 seconds, and each device remembers 5,000 message identifiers for 7 days.

Message protection from mesh relays

With end-to-end encryption, only the sender and the recipient hold the keys; relays see ciphertext plus the little routing information they need to pass it on. Every relay handles the message, so its content needs protection that does not depend on trusting the relays. Signatures let the recipient check who sent the message and that nothing changed in transit.

Delivery is also not the same as success. An acknowledgment says the message reached the recipient’s device. Whether the app on that device stored it, or a backend later accepted it, are separate questions that the application has to answer for itself.

Frequently asked questions

What is the difference between flooding and routing in a mesh network?

With flooding, each node that hears a message for the first time broadcasts it again, which needs no map of the network but uses more airtime and battery as the network grows. With routing, nodes learn which neighbour leads toward which destination and send each message along one path, which uses far less airtime but depends on fresh knowledge of the network.

What does TTL mean in a mesh network?

The time to live (TTL) is a count the sender sets and each relay lowers by one, and when it reaches zero the message is not forwarded again. It is the same idea as the time to live field in IPv4 and the hop limit in IPv6, and it also sets how far a message can travel.

Can relays read the messages they forward across a mesh?

Not with end-to-end encryption. Only the sender and the recipient hold the keys, so relays see ciphertext plus the little routing information they need to pass it on.

What happens to a mesh message when no path exists?

A mesh can hold the message and try later instead of failing. That is called store-and-forward.

What are the Offline Protocol mesh SDK's default delivery settings?

For version 0.33.0, messages start with a TTL of 8 hops, an acknowledgment times out after 10 seconds, and a message is retried up to 10 times with backoff from 1 to 300 seconds. Each device remembers 5,000 message identifiers for 7 days.

Sources

Build it with Offline Protocol

In the Offline Protocol mesh SDK, routing, hop limits, acknowledgments, retries, and duplicate suppression are handled for you, and each default can be changed. The configuration reference lists them with their values.

Read the configuration reference