# Overview
What MESH is, and what ECHO and HALO run over it.
MESH is peer-to-peer networking for devices that share a **topic**, the key that names one group of devices, such as
the devices that have one space open. The devices on a topic find each other, prove they belong and open direct links,
then run any number of protocols side by side over each link. MESH treats every route as a transport. A direct WebRTC
link and a WebSocket through a server are both ways to reach a peer, and MESH uses both at once.
## How devices reach each other
In most web apps, two devices talk through a server. Each device holds a connection to the server, and the server
passes every message between them. MESH starts the same way, then adds a direct link.
Every device keeps one WebSocket to a **signaling server**, which introduces the devices on a topic to each other.
After the introduction, two devices open a **direct link**, a connection that runs between the two of them, and
exchange data over it.
A server can join a topic too. A **peer** is anything a device exchanges a topic's data with: another device, or such
a server. The server reaches devices that no direct link can, because they are offline or their network blocks the
link.
In DXOS, that server is [EDGE](/docs/edge/overview/), and it plays both parts:
- It is the signaling server, so it introduces peers.
- It is an always-online peer, so it holds a copy of each space that replicates through it.
In the diagram, each box is a peer and each arrow is a link. The arrow between the two devices is a direct link over
WebRTC. It carries a **Teleport** session, the stream MESH runs its protocols on. The other two arrows are the
WebSockets to EDGE.
## Where ECHO and HALO use MESH
ECHO and HALO reach MESH through **swarms**. A swarm is the set of direct links a device keeps for one topic.
| What | Who uses it | How |
| ----------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------------------- |
| Space replication | ECHO | Each open space joins a [swarm](/docs/mesh/concepts/swarms/) and replicates its documents and feeds over every link in it |
| Presence | ECHO, HALO | Peers in a swarm [announce](/docs/mesh/concepts/presence/) that they are online |
| Device sync | HALO | An identity's devices join a swarm of their own and replicate the identity's state |
| Invitations | HALO | Host and guest of an interactive [invitation](/docs/halo/concepts/invitations/) meet in a swarm keyed by the invitation |
| Going offline | Apps | `client.mesh.updateConfig(ConnectionState.OFFLINE)` leaves every swarm. The tutorials' offline switch calls it |
## How these pages are organized
Your app rarely calls MESH directly. The protocols that run over it do. These pages explain how MESH works, so there
is no learning path, API group or guides.
- [Why MESH?](/docs/mesh/why-mesh/) argues for direct links between devices, with a server as one more route.
- [Architecture](/docs/mesh/concepts/architecture/) shows the layers, from the transport up to the extensions ECHO and
HALO run. The other concept pages take one layer each.
- The [glossary](/docs/mesh/resources/glossary/) defines every MESH term.
---
# Why MESH?
Why devices connect to each other directly, and why a server stays one of the routes.
Most apps send every change through a server, even between two laptops on the same desk. MESH links devices to each
other directly. A direct link has three advantages:
- It is faster between nearby devices.
- It keeps working when the internet or the server is out of reach.
- It carries data that reaches no server unless WebRTC has to fall back to a TURN relay.
A **TURN relay** is a server that forwards a link's encrypted bytes between two devices that have no route to each
other. A server also stays one of MESH's routes, for the devices a direct link cannot reach.
## The pattern
Two devices join the same **topic**, the key that names the group of devices sharing one space. The signaling server
introduces them, and they open a direct link. A change made on one device arrives on the other over that link.
A server can join the topic as well. It is then an **always-online peer**, and the same change also goes to it. A
third device that comes online later gets the change from the always-online peer.
## Only through a server, against a direct link
| | Through a server only | Direct link between devices |
| ---------------------------------- | --------------------------------------- | ------------------------------------------- |
| Latency between two nearby devices | A round trip to the nearest data center | The local network, or the shortest route |
| Devices never online together | Works. EDGE holds the copy | Does not work on its own |
| Server unreachable | Sync stops | Sync continues between the devices it links |
| Who handles the data in transit | The server | The two devices, and a TURN relay if needed |
| Peers behind strict NAT | Works | Needs a TURN relay |
Neither column is enough alone, so MESH uses both. The server is one more transport, not a separate path beside MESH.
## Practical problems
### Two devices in one room
Two laptops on the same network editing one document should not wait on a data center. Over a direct link, a change
arrives in the time the local network takes.
### The server is down or unreachable
If your device loses its route to the server but can still reach its peers, it keeps syncing with them. When the
server comes back, both sides catch up with it.
### Devices that are rarely online together
A phone and a laptop that are never awake at the same time can never form a direct link. An always-online peer is the
transport that reaches them. Each device syncs with that peer's copy when it is online.
### Data on a direct link
Some data should pass through as few machines as it can. On a direct link, only the two devices handle it. When the
devices have no route to each other, WebRTC sends the link through a TURN relay, which forwards the bytes encrypted.
## Today: both at once
[EDGE](/docs/edge/overview/) is both the signaling server and the always-online peer. It holds a copy of each space
that replicates through it. See [Replication and backup](/docs/edge/concepts/replication/).
A space that replicates through EDGE sends EDGE its changes. EDGE can read them only if the space gives EDGE more than
`pull` access, the lowest access level, which lets a member store and relay the space's encrypted data. See HALO's
[Spaces and membership](/docs/halo/concepts/spaces-membership/).
ECHO replicates each space two ways at the same time. One is the space's **swarm**, the set of direct links a device
keeps for the space's topic. The other is EDGE.
Two settings control the EDGE side:
- The `subductionReplicator` and `feedReplicator` flags in `runtime.client.edgeFeatures` are set per client. They
decide whether the client replicates with EDGE at all. Composer, the `dx` CLI and the configuration in
[Installation](/docs/echo/learn/installation/) turn both on.
- `Space.setEdgeReplication` is set per space. On a client with the flags on, it turns the EDGE side off for one
space. That space then syncs only over direct links.
CRDT merging makes the duplicate delivery harmless. A change that arrives twice is applied once.
## Next
[Architecture](/docs/mesh/concepts/architecture/) shows how the pieces fit together.
---
# Architecture
The layers of MESH, from the transport up to the extensions ECHO and HALO run.
MESH has five layers. A swarm finds peers through signaling and opens a direct link to each peer it picks. A Teleport
session runs on each link, a transport carries the session, and protocols run on the session as extensions. ECHO's
and HALO's protocols are extensions too.
## Model
Three words recur on these pages:
- A **topic** is the key that names one group of devices, such as the devices with one space open.
- A **peer** is anything a device exchanges a topic's data with: another device, or EDGE.
- A **direct link** is a connection between two devices.
In the diagram, each box is a layer, and each arrow points from a layer to one it uses. The swarm uses two layers,
signaling to find peers and Teleport to talk to them, so the five do not form a single stack.
The table takes the layers one at a time, with the package that holds each.
| Layer | What it does | Package in `packages/core/mesh` | Page |
| ---------- | ------------------------------------------------------------------------------- | --------------------------------------------------- | ------------------------------------------------------ |
| Transport | Moves bytes between two devices | `network-manager` (`transport/`) | [Transports](/docs/mesh/concepts/transports/) |
| Teleport | Multiplexes channels over one direct link and runs extensions on them | `teleport` | [Teleport](/docs/mesh/concepts/teleport/) |
| Signaling | Introduces peers on a topic and relays the messages that set up a direct link | `messaging`, `network-manager` (`signal/`) | [Signaling and discovery](/docs/mesh/concepts/signaling/) |
| Swarm | Keeps the set of direct links for one topic, as its topology decides | `network-manager` (`swarm/`, `topology/`) | [Swarms and topology](/docs/mesh/concepts/swarms/) |
| Extensions | The protocols ECHO and HALO run over a direct link: replication, Automerge, gossip, admission, notarization, invitations | `teleport-extension-*`, and the client's own | [Teleport](/docs/mesh/concepts/teleport/) |
The diagram shows the path between two devices. `edge-client` holds the other path, the device's WebSocket to EDGE.
That WebSocket is a transport too, but it runs no Teleport session. It carries signaling and the replication to EDGE's
copy of each space. See [Connecting](/docs/edge/concepts/connecting/).
## Behavior
- The client's services own MESH. Your app never constructs a swarm or a transport. It opens a space, and the space
joins its swarm.
- Every direct link in a space's swarm runs the auth extension. Each side proves it holds a key the space or identity
admitted. The code that joined the swarm decides what to do with a peer that fails.
- Feed replication opens alongside the auth extension, not after it. The other space extensions open after the peer
has authenticated. See [Teleport](/docs/mesh/concepts/teleport/#behavior).
## Limits
- The packages `rpc`, `rpc-tunnel` and `websocket-rpc` also live in `packages/core/mesh`, but they connect a browser
worker to its tabs, not one device to another. These pages leave them out.
- Iroh, in `packages/core/mesh/iroh`, is a design for a further transport, not code. See
[Transports](/docs/mesh/concepts/transports/).
---
# Signaling and discovery
How a device finds the peers in a space and sets up a direct link.
Signaling is how a device learns which peers are on a **topic**, the key that names one group of devices. It is also
how the device exchanges the messages that open a direct link to one of those peers. EDGE is the signaling server.
## Model
Two browsers cannot open a connection to each other unaided. Neither knows the other's address, and most sit behind a
router that hides it. WebRTC needs a server that both can already reach to pass the first messages between them. That
server is the **signaling server**.
A space's topic is its space ID, which is the first 20 bytes of the SHA-256 of its space key. Every member of the
space, and EDGE, computes the same topic. An invitation has a topic of its own, carried in the invitation code.
On this page, a **peer** is another device on the same topic, and a **direct link** is a connection between two of
them. The direct links a device keeps for one topic are its swarm. EDGE is a peer too, but a device reaches it over
its WebSocket and needs no introduction.
**The signal manager.** A **signal manager** is the part of the client that talks to the signaling server. Each device
has one, and the `runtime.client.edgeFeatures.signaling` flag decides which:
- If the flag is on and the client has an EDGE URL, it is the EDGE signal manager, which sends everything over the
device's [WebSocket to EDGE](/docs/edge/concepts/connecting/).
- Otherwise, the client uses an in-memory signal manager that only reaches peers in the same process. Tests use this
one.
**Join, query and leave.** A device joins a topic to say it is there, queries the topic to list the peers on it, and
leaves when it closes the space. EDGE tells each peer on the topic when another joins or leaves.
**Offers, answers and signals.** To open a direct link, one peer sends an offer to another through EDGE, and the other
accepts or rejects it with an answer. The two then trade WebRTC signals until the link opens. From then on, nothing
for that link goes through signaling.
A signal is a session description or an ICE candidate, which is one address a device might be reached at.
The diagram reads from top to bottom. Each column is a party, and each arrow is one message. Every arrow but the last
passes through EDGE. The last one is the direct link.
**ICE and TURN.** **ICE**, short for Interactive Connectivity Establishment, is how WebRTC finds a route between two
devices from their candidates.
- Behind most home routers, a direct route exists.
- Behind strict NATs and firewalls, it does not. The link then goes through a **TURN** server, which relays the link's
encrypted bytes. TURN is short for Traversal Using Relays around NAT.
## Configuration
| Setting | Effect |
| ---------------------------------------- | ------------------------------------------------------------------------------------------ |
| `runtime.client.edgeFeatures.signaling` | Uses EDGE as the signaling server. Without it, devices in different processes never meet |
| `runtime.services.ice` | A fixed list of ICE servers (STUN and TURN), passed straight to WebRTC |
| `runtime.services.iceProviders` | URLs that return ICE servers, fetched once and cached. DXOS runs one at `https://dxos.network/ice` |
The configuration in [Installation](/docs/echo/learn/installation/) sets the signaling flag and the DXOS ICE provider.
See EDGE's [Configuration](/docs/edge/resources/configuration/) for the rest.
## Behavior
- Signaling carries only the messages that set up a direct link. Replication never goes through it.
- A device that loses its WebSocket keeps its open direct links. It cannot open new ones until it reconnects.
## Limits
- A TURN relay sees encrypted bytes only, but every byte of that link goes through it.
---
# Swarms and topology
One swarm per topic, and how MESH decides which peers to connect.
A swarm is the set of direct links a device keeps for one **topic**, the key that names one group of devices. Its
topology is the rule that decides which of the peers on the topic to link to.
## Model
A space has twelve devices online. Should your device link to all eleven others, or to a few of them? A swarm answers
that question for one topic.
A **direct link** is a connection between two devices, and on this page a **peer** is the device at the other end of
one. EDGE is a peer of another kind. It is always online, and a device reaches it over a WebSocket, outside every
swarm.
**One swarm per topic.** Each open space has a swarm, keyed by the space's topic. So does an identity's own HALO space,
which is how its devices sync with each other. So does each invitation in progress.
If your device is in five spaces, it is in five swarms. Two devices that share several spaces have a separate direct
link in each.
**Candidates and links.** Signaling tells the swarm which peers are on the topic. Those peers are its **candidates**.
The **topology** is the rule that picks which candidates to link to and when to drop a link, and the swarm carries
that out.
## Topologies
| Topology | Rule | Used for |
| --------------- | ---------------------------------------------------------------- | ------------ |
| MMST | Link to a few peers, chosen so the swarm usually stays connected | Space swarms |
| Invitation | The host dials one guest at a time. Guests accept every link | Invitations |
| Fully connected | Link to every peer | Tests |
| Star | Every peer links to one central peer | Tests |
**MMST**, short for mostly minimal spanning tree, keeps the swarm reachable without linking every pair. Each device
follows the same rules:
- It opens direct links until it has a minimum number.
- It chooses them from a random sample of candidates, taking the ones nearest its own key by XOR distance.
- It refuses offers once it has its maximum.
Every device picks by the same distance, so the links usually join the whole swarm, and a change reaches every device
through intermediaries.
MMST does not guarantee a connected swarm, however. Two groups whose devices already have their minimum open no link
between them, and then only EDGE joins them.
For a space swarm, the minimum is 4 links, the maximum is 10, and the sample is 20 candidates. The topology makes at
most one change every 10 seconds, so links do not flap.
## The connection limiter
Opening a direct link over WebRTC is expensive, and a device that opens many spaces at once could start hundreds
together. The code calls a direct link a connection, which gives the limiter its name. It lets at most 50 links be
opening at a time, and the rest wait in a queue.
## Behavior
- A device leaves a swarm when it closes the space or goes offline, and joins again when it reopens it.
## Limits
- MMST guarantees neither the shortest route between two devices nor that any route joins them. EDGE replication
covers the gaps.
- A swarm with one device online has no direct links. That device syncs only with EDGE.
---
# Transports
The links MESH carries its protocols over, and how it uses several at once.
A transport moves bytes between a device and a **peer**, which is another device or EDGE. MESH multiplexes transports.
Here that means the same data goes over whichever transport reaches the peer, and a space uses more than one at once.
## Model
MESH has four transports.
| Transport | Where | Notes |
| -------------- | --------------------- | ------------------------------------------------------------------------------------ |
| WebRTC | Browsers and Electron | The default between devices. Uses ICE to find a route, and TURN when there is none |
| TCP | Node | For Node peers, such as agents and tests, that can reach each other directly |
| Memory | Tests | Connects peers in the same process |
| EDGE WebSocket | Everywhere | The device's one WebSocket to EDGE. Carries signaling and replication to EDGE's copy |
ICE is how WebRTC finds a route between two devices, and a TURN server relays the bytes when it finds none. See
[Signaling and discovery](/docs/mesh/concepts/signaling/).
WebRTC, TCP and memory each make a **direct link**, a connection between two devices, and the link carries a
[Teleport](/docs/mesh/concepts/teleport/) session.
The EDGE WebSocket is a transport of another kind. It links a device to EDGE, not to another device. It carries no
Teleport session, and it multiplexes its own channels, one per EDGE service. See
[Connecting](/docs/edge/concepts/connecting/).
## Several transports at once
A space's changes leave a device two ways:
- They go over each direct link in the space's [swarm](/docs/mesh/concepts/swarms/), the set of direct links the
device keeps for that space.
- They go over the WebSocket to EDGE, which keeps a copy and passes them on to the devices it reaches.
Another device may get the same change by both routes. CRDT merging applies it once.
A device does not choose one transport per peer. It sends both ways, and each peer gets the changes by the route
that reaches it:
- If a peer is reachable directly, it gets changes quickly over the direct link.
- If a peer is offline, or behind a network no direct link crosses, it gets them through EDGE.
## Behavior
- In the browser, the client's services run in a browser worker, which cannot open WebRTC connections. The tab opens
them and passes the bytes to the worker.
- A dropped direct link does not lose data when the space replicates through EDGE. EDGE has every change that reached
it, and the next link catches up. With EDGE replication off, the changes wait on the device for the next direct
link.
## Limits
- No transport dials a peer by its public key yet. [Iroh](https://www.iroh.computer/), a QUIC transport that does, is
planned. It traverses NATs itself and falls back to a relay. A design in `packages/core/mesh/iroh` would first use
it for presence and gossip directly between peers, beside EDGE. The design has no code yet.
---
# Teleport
One multiplexed stream per connection, and the extensions that run on it.
Teleport is the session two devices run over one **direct link**, the connection between them. It multiplexes named
channels over that link, and runs extensions on them, each a protocol of its own. ECHO and HALO use extensions to
replicate, announce presence and admit members.
## Model
HTTP/2 sends many requests over one connection, so a slow response does not hold up the others. Teleport does the
same for the protocols that two devices run over one direct link.
**One session per link.** A swarm is the set of direct links a device keeps for one space, identity or invitation. When
a swarm opens a direct link, each side starts a Teleport session on it. The session splits the link into named
**channels**, each a stream of bytes of its own, and balances the bytes between them.
**Extensions.** An **extension** is a protocol with a name. Each side adds the extensions it runs, and an extension
opens once both sides have added it. A peer that does not know an extension never opens it.
| Extension | Added by | Does |
| ---------------------------------------- | --------------- | ----------------------------------------------------------------------------- |
| `dxos.mesh.teleport.control` | Teleport itself | Sends heartbeats, and tells the other side which extensions this side has |
| `dxos.mesh.teleport.auth` | ECHO, HALO | Lets each side prove it holds a key the space or identity admitted |
| `dxos.mesh.teleport.automerge` | ECHO | Replicates the space's Automerge documents |
| `dxos.mesh.teleport.replicator` | ECHO, HALO | Replicates the space's feeds |
| `dxos.mesh.teleport.gossip` | ECHO, HALO | Carries [presence](/docs/mesh/concepts/presence/) announcements |
| `dxos.mesh.teleport.admission-discovery` | ECHO | Lets a newly admitted member fetch the credential that admitted it |
| `dxos.mesh.teleport.notarization` | ECHO | Lets a member ask another to write a credential to the space for it |
| `dxos.halo.invitations` | HALO | Runs an [invitation](/docs/halo/concepts/invitations/) between host and guest |
All eight extensions run an RPC service on a channel named `rpc`. Four of them get that from Teleport's
`RpcExtension` base class, which opens the channel and runs the service: auth, admission discovery, notarization and
invitations. The other four open the channel themselves.
## Behavior
- Every direct link in a space's swarm runs the auth extension. What happens to a peer that fails depends on the code
that joined the swarm:
- If a device is fetching its admission credential, it closes the session.
- If the space is already open, it logs the failure and leaves the session open.
- On a space's link, feed replication opens alongside the auth extension, not after it, and does not wait for it.
Feeds can start to replicate before the peer has authenticated.
- The space adds gossip, admission discovery, notarization and Automerge replication only after the peer has
authenticated.
- An invitation's link has no auth extension. Besides the control extension every session carries, it adds only
`dxos.halo.invitations`, which checks the guest by the invitation's auth method. The `none` method checks nothing.
- Replication over Teleport is the same replication as through EDGE. See
[Spaces and databases](/docs/echo/concepts/spaces/) for what it replicates.
- When a link drops, the session and its extensions close. The swarm opens a new link, which runs them again from the
start. Replication resumes from what each side already has.
## Limits
- Teleport does not choose routes or peers. That is the [swarm](/docs/mesh/concepts/swarms/)'s job.
- An extension a peer does not support is skipped, not negotiated down. Both sides need the same version to talk.
---
# Presence and network status
Who is online, and how an app reads and changes its own connection.
Presence is how a device learns which other members and devices are online. Network status is what your app reads to
know whether its own device is connected. It is also the switch that takes the device offline.
## Model
No server keeps the list of who is online in a **swarm**, the set of direct links a device keeps for one space or
identity. The devices tell each other.
**Gossip.** **Gossip** is passing a message on from one device to the next. Every device in a swarm announces itself
every 10 seconds over the gossip extension. It also passes on the announcements it receives to its other links, so an
announcement reaches devices that its sender has no direct link to.
**Online and offline.** A peer whose announcement has not arrived for 20 seconds counts as offline. ECHO uses this for
a space's members, and HALO uses it for an identity's devices.
**Network status.** `client.mesh.networkStatus` is an observable of the device's own state:
| Field | Meaning |
| ---------------- | ---------------------------------------------------------------------- |
| `swarm` | `ONLINE` while the device joins swarms, `OFFLINE` after it leaves them |
| `signaling` | The state of each signaling server connection |
| `connectionInfo` | The swarms the device is in, and their direct links |
**Going offline.** `client.mesh.updateConfig(ConnectionState.OFFLINE)` makes the device leave every swarm.
`ConnectionState.ONLINE` joins them again. The tutorials' offline switch calls it, so you can watch two windows diverge
and merge.
**Example** (Going offline and coming back)
```ts
import { ConnectionState } from '@dxos/client/mesh';
await client.mesh.updateConfig(ConnectionState.OFFLINE);
// Edit while offline; changes stay on this device.
await client.mesh.updateConfig(ConnectionState.ONLINE);
// The swarm reconnects and the changes merge.
```
## Behavior
- Going offline does not close spaces or stop writes. Changes stay on the device and replicate when it is online again.
- Presence follows swarms. A device is online in the spaces it has open, not in all of them.
## Limits
- Presence is eventually right. A device that drops off the network shows as online for up to 20 seconds.
- Gossip runs over direct links. In a space where no other device is online, a device sees no presence.
---
# Glossary
Every MESH term, defined once.
EDGE's terms, such as router, Durable Object and environment, are in EDGE's [glossary](/docs/edge/resources/glossary/).
### [Always-online peer](/docs/mesh/why-mesh/)
An always-online peer is a server that joins a [topic](#topic) as a [peer](#peer) and holds a copy of the topic's
data. It reaches devices that are never online together. In DXOS it is EDGE.
### Channel
A channel is one named stream of bytes inside a [Teleport](#teleport) session. Each [extension](#extension) gets
channels of its own, so protocols share a [direct link](#direct-link) without blocking each other.
### Direct link
A direct link is a connection between two devices, opened by a [swarm](#swarm) over a [transport](#transport) such as
WebRTC. The code calls it a connection. The other link a device has is its WebSocket to EDGE.
### [Extension](/docs/mesh/concepts/teleport/)
An extension is a named protocol that runs over a [Teleport](#teleport) session, such as replication or gossip. Both
sides must add it before it opens.
### Gossip
Gossip is passing a message on from one device to the next, so that it reaches devices its sender has no
[direct link](#direct-link) to. [Presence](#presence) announcements travel this way.
### ICE
ICE, short for Interactive Connectivity Establishment, is how WebRTC finds a route between two devices from candidate
addresses. You configure ICE servers with `runtime.services.ice` and `runtime.services.iceProviders`.
### [MMST](/docs/mesh/concepts/swarms/)
MMST, short for mostly minimal spanning tree, is the [topology](#topology) that space swarms use. Each device links to
a few peers nearest its own key, so the swarm usually stays connected without linking every pair. A connected swarm
is not guaranteed, and EDGE covers the gaps.
### [Network status](/docs/mesh/concepts/presence/)
Network status is a device's own connection state, read from `client.mesh.networkStatus`. It says whether the device
is in its swarms, and the state of its signaling connections.
### Peer
A peer is anything a device exchanges a [topic](#topic)'s data with. Other devices on the topic are peers, and so is
EDGE, the [always-online peer](#always-online-peer).
### Presence
Presence is how a device learns which members and devices are online, from the announcements each device gossips to
its swarm.
### Signal manager
A signal manager is the part of the client that talks to the signaling server. It joins and leaves topics, lists the
peers on a topic and carries the messages that open a [direct link](#direct-link). See
[Signaling and discovery](/docs/mesh/concepts/signaling/).
### [Signaling](/docs/mesh/concepts/signaling/)
Signaling introduces the peers on a [topic](#topic) and relays the offers, answers and WebRTC signals that open a
direct link. EDGE is the signaling server.
### Swarm
A swarm is the set of [direct links](#direct-link) a device keeps for one [topic](#topic). Each open space has one.
### Teleport
Teleport is the session two devices run over one [direct link](#direct-link). It multiplexes named
[channels](#channel) and runs [extensions](#extension) on them.
### Topic
A topic is the key that names a [swarm](#swarm). A space's topic is its space ID, the first 20 bytes of the SHA-256
of its space key. An invitation carries its own.
### Topology
A topology is the rule a [swarm](#swarm) follows to choose which peers to link to: [MMST](#mmst), invitation,
fully connected or star.
### [Transport](/docs/mesh/concepts/transports/)
A transport is what moves bytes between a device and a [peer](#peer): WebRTC, TCP, memory, or the WebSocket to EDGE.
### TURN
TURN, short for Traversal Using Relays around NAT, is the kind of server that relays a WebRTC link's encrypted bytes
when no direct route between two devices exists.
---
# llms.txt
The MESH site map and full text for agents, in the llms.txt format.
Point an agent at these files before asking it to work with MESH. They follow the [llms.txt](https://llmstxt.org/) format and cover every written page of this section.
| File | Contents |
| -------------------------------------------- | ---------------------------------------------------------- |
| [`/mesh/llms.txt`](/mesh/llms.txt) | Each MESH page with its summary and a link to its Markdown |
| [`/mesh/llms-full.txt`](/mesh/llms-full.txt) | Every MESH page in one file |
Any page is also served as Markdown at its URL with `.md` in place of the trailing slash.