Mesh networking

Mesh vs peer-to-peer vs client-server

Client-server, peer-to-peer, and mesh describe who talks to whom. In client-server, every device talks to a central server. In peer-to-peer, devices talk to each other directly as equals. A mesh is a peer-to-peer network in which devices also relay traffic for each other, so two devices can communicate without being in direct contact.

TL;DR

Client-server keeps one source of truth but stops working together when the server is unreachable. Peer-to-peer over a direct radio link needs no infrastructure but reaches only one radio range, and a mesh adds relaying at the cost of routing, battery and airtime. Most real systems combine them, using a server when reachable and direct links when not.

Learning objectives

After reading this article you will be able to:

  • Distinguish client-server, peer-to-peer and mesh by who talks to whom
  • Explain why peer-to-peer over the internet still depends on infrastructure
  • Choose an architecture using the source of truth, offline needs and device distance

Client-server network model

In a client-server system, devices (clients) send requests to a server, and the server answers. Almost every app on a phone works this way: the app is a client, and the data lives on servers in a data centre. Clients rarely talk to each other directly. When two people message each other, each phone talks to the server, and the server passes the message along.

The model is popular for good reasons. There is one place to store data, apply rules, check permissions, and fix bugs. The server is the source of truth, so there is no question of which copy is right.

What it depends on is a working path from every client to the server, all the time. If the server goes down, or a device loses its connection, that device can no longer do anything that needs the server, even if the person it wants to reach is standing next to it.

Peer-to-peer network model

In peer-to-peer (P2P) systems, devices talk to each other directly as equals. Each one can both ask and answer. File-sharing networks, video calls that connect browsers directly, and phones exchanging data over Bluetooth are all peer-to-peer.

Peer-to-peer describes the relationship between devices, not the link they use. Two computers can be peers across the internet, in which case they still depend on internet infrastructure to reach each other. Two phones can also be peers over a direct radio link, such as Bluetooth Low Energy or Wi-Fi Direct on Android, in which case they need no infrastructure at all. Only the second kind keeps working when the internet is gone.

The limit of plain peer-to-peer is reach. Over a direct link, a device can only talk to devices within its own radio range.

Mesh network vs peer-to-peer

A mesh is peer-to-peer with relaying. Each device talks directly to its neighbours, and also forwards messages for others, so a message can reach a device several hops away. That removes the range limit of a single direct link and removes the dependency on a central server. The cost is the work of routing: discovering neighbours, choosing paths, stopping loops, and retrying lost messages, all on devices that move and run on batteries.

Client-server vs peer-to-peer vs mesh comparison

Client-server, peer-to-peer and mesh networks differ in who talks to whom, where the data lives, what keeps working when the server or internet fails, how far they reach, and what they cost.

Client-serverPeer-to-peerMesh
Who talks to whomEvery client to the serverDevices directly, as equalsDevices directly, and through each other
Where the data livesOn the serverOn the devicesOn the devices
If the server or internet failsClients stop working togetherDirect links keep workingDirect and relayed paths keep working
ReachAnywhere the internet reachesOne link’s range, unless over the internetMany hops, as far as the devices extend
Main costRunning servers and connectivityFinding and connecting to peersRouting, battery, and airtime

Hybrid client-server, peer-to-peer and mesh systems

Very few networked systems use only one of these shapes. A messaging app can use its server when it is reachable and fall back to direct links when it is not. A mesh can include a gateway device that has an internet connection and passes data to and from a server. A server can stay the system of record while devices exchange work locally and report back later.

When choosing, three questions settle most cases:

  1. Where is the source of truth? If one server must decide, devices can still work locally, but they need a way to hand their results back and to handle being told no.
  2. What must keep working without the internet? Anything on that list needs a direct or relayed path between devices.
  3. How far apart are the devices? Within one radio range, direct peer-to-peer may be enough. Across a building, a site, or a moving fleet, relaying starts to matter.

Frequently asked questions

Is a mesh network the same as a peer-to-peer network?

A mesh is peer-to-peer with relaying. In plain peer-to-peer, devices talk to each other directly as equals; in a mesh, they also forward messages for others, so a message can reach a device several hops away.

Does peer-to-peer work without the internet?

It depends on the link. Two computers that are peers across the internet still depend on internet infrastructure to reach each other, while two phones that are peers over a direct radio link, such as Bluetooth Low Energy or Wi-Fi Direct on Android, need no infrastructure at all.

Why do most phone apps use a client-server design?

There is one place to store data, apply rules, check permissions, and fix bugs. The server is the source of truth, so there is no question of which copy is right.

What does a mesh cost compared with client-server?

A mesh removes the dependency on a central server, but it takes on the work of routing, which means discovering neighbours, choosing paths, stopping loops, and retrying lost messages, all on devices that move and run on batteries.

Can a mesh network still connect to a server?

Yes. A mesh can include a gateway device that has an internet connection and passes data to and from a server, and a server can stay the system of record while devices exchange work locally and report back later.

Sources

Build it with Offline Protocol

Offline Protocol keeps your backend as the system of record and adds direct and relayed paths between devices for the moments the server cannot be reached. The docs set out what the SDK handles and what stays in your application.

Read what the SDK handles