Multiplayer
How Mowo networks a game - a listen-server co-op model with an authoritative host, replication, RPCs, prediction and an optional dedicated server.
Mowo's networking is built for small co-op sessions: a handful of friends, one of whom hosts. The host runs the authoritative simulation, every other machine runs a client copy of the world, and the engine keeps those copies in step. This page explains the model and how a networked frame flows. The pages that follow cover each part in detail.
The network model
The engine is listen-server first. One player hosts and plays at the same time, and that machine is the authority over the world. The hosting player gets player id 1 and peer id 0, and receives a pawn like everyone else, so host and clients run the same code path FNetSession.
- The host is the authority. A client may send only input, RPCs that pass the authority gate, and acknowledgements. The host owns spawns, destroys and replicated state.
- There is no host migration. When the host leaves, the session ends and clients return to the menu (
HostEndedSessionor, after the automatic rejoin attempts fail,HostLost) ENetSessionFailure. - A headless dedicated server exists. The
MowoServertarget runs the same authoritative simulation with no window and no renderer, and hosts through the same session layer with no host pawn. See Dedicated server. - Sessions default to five players, host included (
FNetSessionSettings::maxPlayers = 5) FNetSessionSettings.
The GameNet module (WebSocket, REST, snapshot sync, match connection) is a separate client library for server-authoritative online titles that talk to a web backend. It registers no systems and is not part of the co-op netcode described here. Its API is listed under GameNet.
Two clocks: the server tick and the snapshot rate
The host runs two independent clocks inside ReplicationManager:
| Clock | Default | What it drives |
|---|---|---|
| Server tick | 30 Hz (kDefaultServerTickHz) | The tick number stamped on every packet, and the lag-compensation history |
| Snapshot rate | 20 Hz (kDefaultSnapshotHz) | How often the host builds and sends state updates to clients |
SetServerTickRateHz changes the tick and SetSnapshotRateHz changes the snapshot rate ReplicationManager::SetServerTickRateHz. Because they are separate, the lag-compensation window stays 15 ticks (about 500 ms at 30 Hz) no matter how often snapshots go out. A frame hitch advances at most four ticks, so a stall cannot flood the history with copies of one pose.
The dedicated server passes its --tickrate to SetServerTickRateHz, so on MowoServer the tick follows that flag rather than the 30 Hz default.
How a networked frame flows
ReplicationManager is an ECS system that the scene runs in its runtime and simulation system sets. Each frame, its Update first pumps the session state machine, then runs the host or client half depending on the machine's role.
- Transport poll
- Replication filter
- Session pump
- Gameplay systems
- Server tick
- Snapshot build
- Send
On the host:
- The transport delivers packets. The replication filter decodes replication packets, checks the protocol version and schema, and applies authority gates before anything reaches the simulation.
- The session pump runs first, so a pawn spawned for a joining player already has a network id when this frame's spawns and snapshots are built.
- Gameplay and physics systems simulate the authoritative world, including client moves applied to each player's pawn.
- The server tick advances the tick counter and captures a lag-compensation pose for every networked object.
- At the snapshot rate, the host builds field-level deltas per client and sends them: continuous fields on an unreliable channel, discrete fields on a reliable one.
- Receive snapshot
- Apply to ghost
- Interpolation buffer
- Reconcile own pawn
- Predict next input
- Send input
On a client, remote objects play back from an interpolation buffer 100 ms behind the newest snapshot (FNetSessionSettings::interpolationDelay). The locally controlled pawn is predicted immediately and reconciled when the server acknowledges input. See Prediction and lag compensation.
What replicates
The rule that runs through the design is replicate events and small authoritative state, not their consequences. A networked object is an ECS entity carrying a NetworkObjectComponent NetworkObjectComponent. Its transform replicates by default, and any reflected component field marked MREPLICATED replicates as well. Each player in the session also has a replicated player state record (name, score, team, ping, ready).
| Travels on the wire | Stays local |
|---|---|
| Transform pose and movement state (continuous, unreliable) | Rendering, audio and VFX state |
| Discrete state such as health, ammo, flags (reliable) | Anything a peer can recompute from replicated inputs |
| RPCs, gameplay events and fast-array deltas | Types without a wire codec (asset references, arrays of strings) |
Channels
Every transport exposes four channels NetworkChannel:
| Channel | Delivery | Used for |
|---|---|---|
Reliable | Reliable, ordered | Discrete state, join and leave, events |
Unreliable | Unreliable, sequenced | Transform snapshots |
BulkReliable | Reliable, unordered | Large batches, and the chunks of large RPCs |
Voice | Unreliable, unsequenced | Voice frames, so the jitter buffer can reorder them |
Layers at a glance
| Layer | Class | Role |
|---|---|---|
| Session | FNetSession | Host, join, leave, players, pawns, travel, gameplay events |
| Replication | ReplicationManager | Spawns, snapshots, relevancy, RPC gates, prediction bookkeeping, lag history |
| RPC marshalling | FRpcDispatcher | Serializes and invokes reflected MFUNCTION calls |
| Peers | NetworkManager | Peer events, send and broadcast |
| Transport | FCompositeTransport | ENet for IP addresses, Steam P2P for SteamID64 addresses FCompositeTransport |
Most games only call FNetSession (or the MNetSessionSubsystem wrapper) and annotate their components. The layers below it are the machinery it drives.
To try multiplayer in the editor, use multiplayer Play in Editor and the Network Debug panel, described in Play in Editor.
Where to go next
Engine sources
This page describes behavior implemented in these files of the engine repository, checked against commit 5922e6e5e.
- Engine/Source/Runtime/Networking/Public/Networking/Session/FNetSession.h
- Engine/Source/Runtime/Networking/Public/Networking/Session/NetSessionTypes.h
- Engine/Source/Runtime/Networking/Public/Networking/Replication/ReplicationManager.h
- Engine/Source/Runtime/Networking/Public/Networking/NetworkTypes.h
- Engine/Source/Runtime/Networking/Public/Networking/CompositeTransport.h
- Engine/Source/Runtime/Networking/Public/Networking/Components/NetworkObjectComponent.h
- Engine/Source/Runtime/Networking/Public/Networking/Components/PlayerStateComponent.h