Presentation is loading. Please wait.

Presentation is loading. Please wait.

Network synchronization of Online Games Li, Zetan.

Similar presentations


Presentation on theme: "Network synchronization of Online Games Li, Zetan."— Presentation transcript:

1 Network synchronization of Online Games Li, Zetan

2 What is cyber game? Players share the same scenery and interact with each other. Compare to traditional single games. Usually require access to internet.(Or at least local area network)

3 How does cyber game work Sharing one virtual world? It's an illusion. :P What is actually going on underneath is quite different from what you see. What you perceive as a shared reality is only an approximation unique to your own point of view and place in time. Message exchange Two different games running on two different machines, and try to maintain same scenery through massage exchange.

4 Synchronization Peer-to-peer lockstep Client/server

5 Synchronization Peer-to-peer lockstep In the beginning games were networked peer-to-peer, with each other computer exchanging information with each other in a fully connected mesh topology.

6 Synchronization —— peer-to-peer lock step Abstract the game into a series of turns and a set of command messages when processed at the beginning of each turn direct the evolution of the game state. Advantage – Simple to implement Drawback & Limitation -- Cannot guarantee 100% deterministic of a game. One tiny difference will results in complete desynchronization over time -- Have to wait until all the players’ messages are collected --- Impossible to join in the middle of game. Still using in RTS game today

7 Synchronization Client/Server model Most lagged player makes game slow? Using client/server model! First appear in Quake,1996 Using widely in games today, especially action games.

8 Synchronization —— Client/Server Each player was now a “client” and they all communicated with just one computer called the “server”. Game only exist on the server, client act like a terminal Each player send their input to server. Server response with their new states. Possible for players to come and go in the middle of the game

9 msg Client Server

10 Problems for Client/Server model Latency makes game sucks Solution Client-Side Prediction Latency Compensation

11 Client-Side Prediction Client immediately in response to player’s input Using server’s response to correct player’s state ——Why not let client manipulate the state of itself: prevent cheating ——Circular buffer of past character state *Brief introduction on Latency Compensation

12 Networked Physics What is physics engine Game with physics simulation

13 How to synchronize physics performance Send state of all objects? You are challenging bandwidth Simple illustration: FPS 1.Character physics are completely driven from input data 2.Physics state is known and can be fully encapsulated in a state structure 3.The physics simulation is reasonably deterministic given the same initial state and inputs

14 Example: FPS Arrange input and state information: Physics is run on the server according to a stream of input from clients Clients approximate server physics locally Deal with latency 1.Client prediction 2.Packet loss struct Input { bool left; bool right; bool forward; bool back; bool jump; }; struct State { Vector position; Vector velocity; };

15 Protocol TCP v.s UDP TCP Connection based Guaranteed reliable and ordered Automatically breaks up your data into packets for you Makes sure it doesn’t send data too fast for the internet connection to handle (flow control) Easy to use, you just read and write data like its a file UDP No concept of connection, you have to code this yourself No guarantee of reliability or ordering of packets, they may arrive out of order, be duplicated, or not arrive at all! You have to manually break your data up into packets and send them You have to make sure you don’t send data too fast for your internet connection to handle If a packet is lost, you need to devise some way to detect this, and resend that data if necessary

16 Why Not TCP? Games have a real time requirement on packet delivery. Packet loss will make game stop and wait for packet resent.

17 References http://gafferongames.com/networking-for-game-programmers/what- every-programmer-needs-to-know-about-game-networking/ http://gafferongames.com/networking-for-game-programmers/what- every-programmer-needs-to-know-about-game-networking/ http://gafferongames.com/networking-for-game-programmers/sending- and-receiving-packets/ http://gafferongames.com/networking-for-game-programmers/sending- and-receiving-packets/ http://gafferongames.com/networking-for-game-programmers/udp-vs- tcp/ http://gafferongames.com/networking-for-game-programmers/udp-vs- tcp/ http://gafferongames.com/game-physics/networked-physics/ http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_28 8_network_.php

18 Thank You! Questions??


Download ppt "Network synchronization of Online Games Li, Zetan."

Similar presentations


Ads by Google