Skip to main content
Version: SDK-5.11.6

Dead-reckoning Technique

The ideal way for clients to communicate in a real-time game environment is to perform communication every frame(60 times in case of 60 frames).
In this case, accuracy is improved, but the network traffic will be increased drastically.

With the dead-reckoning technique, it is possible to reduce traffic as well as ensure the accuracy of data.

Algorithm

The dead-reckoning algorithm is an algorithm that updates the status by predicting actions during the absence from the client.

Suppose that Player A moves forward for 1 second and turns to the right after 1 second.

If the client communicates every frame

  • The client sends a message saying that the forward-moving key is pressed to the server 120 times(60 frames * 2) and 1 time when Player A turns. As a result, it will send a message 121 times in total.

  • The server must also send a message 120 times(60 frames * 2) + α by refreshing the location value of the client every frame, based on the message sent from the client.

If the dead-reckoning algorithm is applied

  • The client sends a message 1 time when the forward-moving key is pressed, sends another message when the player turns, and another message when the forward-moving key is released. As a result, it can process movement by sending only 3 messages to the server.

  • The server sends the location value and movement direction to the client when the player moves, sends them again once when the player turns, and sends the location value of the client once again when the player stops moving. As a result, it can also process movement by sending only 3 messages to the client.

  • If both the client and the server share the same movement speed value, the location of players can be calculated based on the speed and direction of movement.
    The client and the server can be synchronized because the server calculates and sends the current location value of the client whenever the client responds to a message of status change(e.g., movement direction is changed, movement is stopped, etc.).

  • In addition, even if the client is hacked and its movement speed value is modified, the risk is mitigated because the client sends a value whenever something is changed for synchronization.

In short, the server and the client calculate simultaneously but synchronization is performed regularly or whenever something is changed from the client.

Apply to BACKND Match

For the real-time game environment of BACKND Match, the server does not perform calculations and only functions as a relay server.
Therefore, it is recommended to create a game in a similar way to P2P.

Also, among P2P types, it is recommended to use Super peer to select a client that will act as the host(server).
This way, the host client will calculate its own key input value and overall game values and other clients will send key input values to the host, receive the calculation results from the host, and apply them to the client.

By applying the dead-reckoning technique, the traffic moved from the host to the client can be reduced.

Host client

A host client does not send its own key value and processes it by itself, and it processes the key values sent from other clients with a series of game logic.
Then, the value processed using game logic is sent to the server and broadcast to other clients.

Normal client

A normal client sends the key value to the server, and among messages broadcasted by the server, it ignores messages sent from the client.
It then deserializes messages sent from the host to apply them to the game and perform synchronization.

  • Messages sent from the host contain the status of clients and synchronization values.
  • Based on these status values, the client performs calculations by itself and synchronizes data whenever the host sends a message.
  • Any client can be the host, and therefore the client can perform calculation as it contains game logic.

Basic dead-reckoning technique is applied in BACKND Match Tutorial. Please refer to that tutorial.