Discover how Edgegap works

Discover how Edgegap works

Transport Layer

A transport layer is the part of a game’s networking stack that typically sends and receives the raw packets between players and the game server or host, over UDP or TCP (WebSocket, on top of TCP, for browser builds). In many libraries it is a swappable component beneath the netcode, such as KCP in Mirror or Unity Transport in Netcode for GameObjects.

Also called

transport, network transport, netcode transport

By

By

By

Philip Coté

Philip Coté

Philip Coté

,

CTO

CTO

CTO

Published

Published

Published

What Does a Transport Layer Do in a Multiplayer Game?

When applied to networking outside of games, the transport layer is layer 4 of the OSI model, where TCP and UDP sit. The network layer below it, IP, gets a packet to the right machine; the transport protocol gets it to the right program on that machine, using a port number. UDP vs TCP covers how those two protocols differ.

In game development, “transport” usually means something narrower: the part of a networking library that owns the socket. FishNet’s documentation describes it as the layer “responsible for sending and receiving raw data over the network” (FishNet documentation). The netcode above it decides what to send, such as which objects to replicate and which calls to run on the server. The transport decides how those bytes get there.

Depending on the library, a transport typically handles:

  • Connections: opening them, keeping idle ones alive with heartbeats, and timing them out.

  • Channels: a reliable, ordered channel for events that must arrive, and an unreliable one for state the next update replaces.

  • Message size: splitting messages too large for one packet and putting them back together.

  • The protocol underneath: UDP for most native builds, WebSocket for browser builds, or a platform’s own sockets.

Diagram over time of Player A, a game server and Player B, each a row of frames or ticks. Player A’s position update is lost and skipped while the next one arrives; a shot sent on the reliable channel is lost and resent. Player B sends its own position. The server applies the shot and sends the updated match state to both players.

Unity Transport, for example, offers a fragmentation stage for large messages and a reliable stage for ordered delivery (Unity Transport documentation), and sends a heartbeat when a connection goes quiet (Unity Transport changelog). Unity developers meet the term often for another reason too: Unity’s earlier networking system, UNet, called its low-level API the Transport Layer.

Article's key insights

In short: The best game server depends on who your players play with. Peer-to-peer and shared relay services cost nothing to host, but they can leave matches open to cheating and hacking.

Setups that run on a server come in three tiers, each with its own trade-off. An extensible relay fits players who trust each other, and the host’s game owns the match until you add game logic. A multi-room game server gives server authority to games that can share a process, with many matches side by side. A dedicated server gives each session its own server, sized from a light match to a full simulation, either session-based or persistent.

By genre and mode:

  • Extensible relay: Co-op and party games among friends.

  • Multi-room game server: Card, turn-based, RTS, MOBA, sports, racing, casual mobile and web games.

  • Dedicated server, session-based: Shooters, battle royales, realtime PvP, fighting games, VR and Web3.

  • Dedicated server, persistent: MMOs, survival and sandbox worlds.

See the full table by genre and mode below, with a runner-up for each.

  • Who owns the match decides most trade-offs: In peer-to-peer and currently available shared relay services, the host player’s game holds the match state. The host can still modify the binary to cheat and ends the match by leaving, and every other player syncs with the host’s game, so the farther a player is from the host, the worse their latency and the less fair their match.

  • A cheater ruins everyone’s fun, casual or ranked: A casual match may not have a rank to protect, but one player who edits the match still affects everyone in it: any progress, rewards or items at stake, and the fun of playing. Bloody Bastards, a mobile game with more than 40 million downloads, saw cheating its studio describes as rampant while it ran on peer-to-peer. Relays fit players who trust each other; matches with strangers need server authority.

  • Relays are a network fix: A relay gets players through NAT and hides their IP addresses, but it doesn’t stop cheating unless you add game logic, which only a relay you run lets you do.

  • Servers improve connection reliability and remove dependence on host availability: Every player connects to a server no player controls, which avoids most of the NAT issues common on mobile, and no match stops because one player left. Deployed nearest to all of a match’s players, a server also lowers latency and makes the match fairer.

  • A game server scales with the game: The same dedicated server can run a light match on 0.25 vCPU, a full simulation, or a persistent world on a 14.7 vCPU Private Fleet host, and multi-room servers fit many light matches in one process.

How Do Unity, Unreal and Godot Handle the Transport?

In most popular engines and libraries, the transport is a separate, replaceable piece. You pick one per project, and can often change it later without rewriting gameplay code.

Engine or library

Common starting point

Other options (examples)

Where you change it

Mirror (Unity)

KCP, over UDP

Telepathy (TCP), Simple Web Sockets, Steam and Epic transports

Transport field on the Network Manager

FishNet (Unity)

Tugboat, over UDP

Bayou (WebSocket), Unity Transport, Steam and Epic transports

Transport component on the NetworkManager

Netcode for GameObjects (Unity)

Unity Transport (UDP, or WebSocket in WebGL)

Community transports

Select Transport dropdown on the NetworkManager

Unreal Engine

IpNetDriver, the default net driver (UDP)

Steam Sockets net driver

Net driver definitions in the engine config

Godot 4

ENet

WebSocket and WebRTC peers

multiplayer.multiplayer_peer on the scene tree’s multiplayer API

Sources: Mirror, FishNet, Netcode for GameObjects, Unreal Engine, Godot. In Unreal, the net driver also manages connections and replication, so it covers more than a transport.

Mirror’s documentation says changing transports “only requires a few steps”. What changes with it is usually outside the gameplay code. A new transport can switch the protocol and port the server listens on, so firewall rules and port mapping need to follow. Third-party transports are maintained outside the library: Unity’s community repository notes it does not guarantee support in future Netcode for GameObjects versions, so check a transport’s activity before you build on it.

Can One Server Accept Players on Different Transports?

Yes, with most major libraries, but each player still connects with a single transport, and it has to be one their platform supports.

The most common case is a browser build. A player on a web build can only join a server that accepts a transport browsers support, typically WebSocket. If the server listens only on UDP, web players can’t connect at all, even while native players join the same match without trouble. The reason is that browsers can’t open raw UDP sockets. Unity Transport, for example, supports only WebSocket connections, in client mode, in WebGL builds (Unity Transport documentation).

Platform transports can split players the same way. On Unreal, a build using Steam Sockets “can only connect with other builds using Steam Sockets”, so those players can’t be matched with players on a build without it. Steam Sockets builds can support cross-platform play between Windows, Mac and Linux, but not other devices (Epic documentation).

For crossplay across these platforms, many libraries let the server listen on several transports at once:

  • Mirror’s Multiplex transport lets clients connect “via either one of them”, for example KCP on UDP port 7777 for desktop and mobile, and WebSocket on TCP port 7778 for WebGL (Mirror documentation).

  • FishNet’s Multipass lets a server use several transports at once, while each client keeps one active transport.

  • Unity Transport’s MultiNetworkDriver combines a UDP driver and a WebSocket driver on one server, at the transport’s API level, which its documentation describes as useful for cross-play (Unity Transport documentation).

Each extra transport usually means another port or protocol to open and map on the server, and another connection path to test before launch.

Does the Transport Change With the Type of Game Server?

Every multiplayer setup needs a transport, dedicated servers included. Whether matches run on a dedicated server, on a listen server hosted by a player, or through a relay, the bytes still pass through one. What changes is the destination: a server address, the hosting player, or a relay that forwards traffic. Platform relays such as Steam’s often ship as transports of their own, which is why switching to one can look like a transport change.

The transport decides how bytes move. The type of game server decides who runs the match and owns its state, which shapes cheating, host advantage and what happens when a player leaves. Edgegap’s Insights article Best Type of Game Server for Each Game Genre and Mode compares five setups, from peer-to-peer to dedicated servers, and which fits each genre.

A word from our sponsor (ourselves!)

A region is a guess about where your players will be. Edgegap's Edge Cloud is a distributed, multi-cloud network of 615+ locations across 17+ providers, available on demand. Each server launches at the best available location on the network when the match starts, not at the nearest of a handful of regions.

Frequently Asked Questions

What is the difference between the transport layer and the network layer?

Which transport protocols do multiplayer games use?

What is Unity Transport?

Get your Game Online Easily & in Minutes

Start Integrating Now!

Get your Game Online Easily
& in Minutes