Network synchronization of Online Games Li, Zetan.

18
Network synchronization of Online Games Li , Zetan

Transcript of Network synchronization of Online Games Li, Zetan.

Page 1: Network synchronization of Online Games Li, Zetan.

Network synchronization of

Online Games

Li , Zetan

Page 2: Network synchronization of Online Games Li, Zetan.

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)

Page 3: Network synchronization of Online Games Li, Zetan.

How does cyber game work

• Sharing one virtual world? It's an illusion. :PWhat 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.

Page 4: Network synchronization of Online Games Li, Zetan.

Synchronization

• Peer-to-peer lockstep

• Client/server

Page 5: Network synchronization of Online Games Li, Zetan.

Synchronization

• Peer-to-peer lockstepIn the beginning games were networked peer-to-peer, with each other computer exchanging information with each other in a fully connected mesh topology.

Page 6: Network synchronization of Online Games Li, Zetan.

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

Page 7: Network synchronization of Online Games Li, Zetan.

Synchronization

• Client/Server modelMost lagged player makes game slow? Using client/server

model!• First appear in Quake ,1996• Using widely in games today, especially action games.

Page 8: Network synchronization of Online Games Li, Zetan.

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

Page 9: Network synchronization of Online Games Li, Zetan.

msgmsg

Client

Client

Server

Page 10: Network synchronization of Online Games Li, Zetan.

Problems for Client/Server model

• Latency makes game sucksSolution

• Client-Side Prediction • Latency Compensation

Page 11: Network synchronization of Online Games Li, Zetan.

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

Page 12: Network synchronization of Online Games Li, Zetan.

Networked Physics

• What is physics engine

• Game with physics simulation

Page 13: Network synchronization of Online Games Li, Zetan.

How to synchronize physics performance

• Send state of all objects? You are challenging bandwidth

• Simple illustration: FPS1. Character physics are completely driven from input data2. Physics state is known and can be fully encapsulated in a

state structure3. The physics simulation is reasonably deterministic given the

same initial state and inputs

Page 14: Network synchronization of Online Games Li, Zetan.

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 latency1. Client prediction2. Packet loss

struct Input { bool left; bool right; bool forward; bool back; bool jump; };

struct State { Vector position; Vector velocity; };

Page 15: Network synchronization of Online Games Li, Zetan.

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

Page 16: Network synchronization of Online Games Li, Zetan.

Why Not TCP?

• Games have a real time requirement on packet delivery. Packet loss will make game stop and wait for packet resent.

Page 18: Network synchronization of Online Games Li, Zetan.

Thank You!

Questions??