Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Multiplayer Game Synchronization

I've a server/client architecture implemented, where all state changes are sent to the function, validated and broadcasted to all clients connected. This works rather well, but the system does not maintain synchronization between the client instances of the game as of now.

If there happened to be a 5 second lag between the server and a particular client then he would receive the state change 5 seconds after the rest of the clients thus leaving him with game state out of sync. I've been searching for various ways to implement a synchronization system between the clients but haven't found much so far.

I'm new to network programming, and not so naive to think that I can invent a working system myself without dedicating a severe amount of time to it. The ideas I've been having, however, is to keep some kind of time system, so each state change would be connected to a specific timestamp in the game. That way when a client received a state change, it would know exactly in which period of the game the changed happened, and would in turn be able to correlate for the lag. The problem with this method is that in those n seconds lag the game would have had continued on the client side, and thus the client would have to rollback in time to update for the state change which definitely would get messy.

So I'm looking for papers discussion the subjects or algorithms that solves it. Perhaps my whole design of how the multiplayer system works is flawed, in the sense that a client's game instance shouldn't update unless notion is received from the server? Right now the clients just update themselves in their game loop assuming that any states haven't changed.

like image 642
Kasper Holdum Avatar asked Sep 11 '09 15:09

Kasper Holdum


People also ask

How do multiplayer games send data?

Packets and Protocols: Online games communicate through a packet-switched network, like the Internet, where communications are broken up into small data units, called packets, which are then transmitted through the network from the sender and reassembled on the other side by the receiver.

How do video games stay in sync?

The server is the “source of truth” for the system through which all communication must flow. Clients are only connected to each other through the server itself, which operates as a relay between them. Collections of data are sent in discrete chunks to and from each client to keep them updated as the game unfolds.

What is asynchronous multiplayer gameplay?

Asynchronous multiplayer is a form of multiplayer gameplay where players do not have to be playing at the same time.

What makes a game multiplayer?

Basically, a multiplayer game is a video game in which more than one person can play the same game together. More specifically, though, the same exact game area, not just the same game. The different players are all in the same match, server, or level experiencing everything in real-time at the same moment.


2 Answers

The basic approach to this is something called Dead Reckoning and a quite nice article about it can be found here. Basically it is a predication algorithm for where entities positions will be guessed at for the times between server updates.

There are more advanced methodologies that build on this concept, but it is a good starting point.


Also a description of how this is handled in the source engine (Valve's engine for the first Half Life game) can be found here, the principle is basically the same - until the server tells you otherwise use a prediction algorithm to move the entity along an expected path - but this article handles the effect this has on trying to shoot something in more depth.

like image 150
Martin Harris Avatar answered Oct 06 '22 11:10

Martin Harris


The best resources I've found in this area are these two articles from Valve Software:

  • Latency Compensating Methods in Client/Server In-game Protocol Design and Optimization
  • Source Multiplayer Networking
like image 35
Kevin Avatar answered Oct 06 '22 13:10

Kevin