Multiplayer tutorial 1: concepts

Favourite 220 favourites
Tutorial written by AshleyOriginally published on 3rd, March 2014 - 4 revisions

The chaos of the Internet

Suppose now that some peers have joined the same room, successfully connected to a host, and a multiplayer game has begun. We can now ignore the signalling server: it is no longer involved from this point.

As described earlier, the multiplayer game itself runs with the host acting as the server. Peers only send data to the host, whereas the host can send data to anyone. This means if two peers want to communicate, it must be relayed through the host.

Multiplayer games would be a lot simpler if all transmission over the Internet was near-instant. This is generally the case on local area networks (LAN), such as your home or office network. However the Internet is phenomenally complex. Between any two players on the Internet, there could be 10-20 network devices (such as routers). The devices along this route will be different for each pair of players. For every single message sent, each device along the route must receive an incoming packet of information, read and understand its destination, determine where to forward it on to, and then re-transmit it. On top of that if you connect to a player overseas, your data will most likely be travelling through undersea cables, which deal with extraordinary amounts of traffic over large distances.

Example connection route between two peers

Amazingly, each device on the route can often forward on an incoming packet within milliseconds. However with lots of devices along a route, this adds up. If any device along the way is experiencing high load, it could slow down resulting in longer transmission delays. These devices, like any computers, can also crash, run out of memory, shut down for maintenance, lose power, run in to bugs that affect service, and so on. Due to much impressive engineering, routers can often re-route data around devices that have gone offline, or even re-route data down faster alternative paths. All of this can add temporary or permanent changes to the time it takes a message to travel from A to B.

The laws of physics must also be taken in to account. If a player from London in the UK connects to Sydney in Australia, the data must travel approximately 17,000km. Travelling in a straight line at the speed of light, this would take around 57ms. It is physically impossible to get data there faster than that. Then the cables along the way probably aren't perfectly straight, and over such a long distance there are likely to be many more routing devices.

Share and Copy this Tutorial

You are free to copy, distribute, transmit and adapt this work with correct attribution. Click for more info.


stefanos 3,482 rep

Yeah that's nice :)

Monday, March 03, 2014 at 8:36:42 PM
Vallhalen 3,067 rep


Monday, March 03, 2014 at 8:43:51 PM
Leandrus 6,001 rep


Monday, March 03, 2014 at 8:55:27 PM
SgtConti 4,941 rep

Very interesting, hopefully the beta release comes tomorrow ;)

Monday, March 03, 2014 at 9:02:03 PM
DUTOIT 12.8k rep

Fantastic :)

Monday, March 03, 2014 at 9:05:34 PM
emoaeden 10.3k rep

I can't wait to try this !

Monday, March 03, 2014 at 9:07:53 PM
NeoBiel 4,639 rep

Meu sonho se realizando...

Monday, March 03, 2014 at 9:08:29 PM
albrektv 8,606 rep

Thank you for the lesson that you are waiting for him

Monday, March 03, 2014 at 9:11:31 PM
valdarko 6,357 rep

how it will handle data save, like itens and stuff?

Monday, March 03, 2014 at 9:33:35 PM
Joskin 6,129 rep

Yes ! Thanks a lot !

Monday, March 03, 2014 at 10:23:48 PM
jobel 17.2k rep

I'm very excited to go through this! thanks!

Monday, March 03, 2014 at 10:35:05 PM
DatapawWolf 30.9k rep

I notice this does not address the subject of host cheating. Preventing the clients is nice and all, but, for example, say the host hacks their client, they could now send whatever they want to the peers.

Now you could say that anti-cheating measures and checks could be implemented, but then you could apply that same logic to each client as well.

Thoughts, anyone?

Monday, March 03, 2014 at 11:17:34 PM
popyui 2,499 rep

Me gusta mucho esto y me da una mejor idea de como funcionan mis juegos de mis consolas

Monday, March 03, 2014 at 11:19:48 PM
DatapawWolf 30.9k rep

Also, not to spam, but addressing the "Lag Compensation" techniques. I'm sorry but if a player has a bad connection in a shooter game, too bad for them. Newer games in the Call of Duty series have notoriously infuriating lag comp which is responsible for all sorts of nonsense.

In my opinion it's a technique that is often overused and should not be looked as much as interpolation or other ways of synchronizing between peers.

Monday, March 03, 2014 at 11:29:12 PM
DatapawWolf 30.9k rep

"By default updates are sent 30 times a second"
We will be able to modify this, correct? Or send out updates only when needed? It'd be wasteful to constantly spew out that much data for something like a grid/turn based game, where movement may be as low as 1 grid square per 100ms, or not at all when a player is AFK.

Monday, March 03, 2014 at 11:32:42 PM

Leave a comment

Everyone is welcome to leave their thoughts! Register a new account or login.