Network synchronization of Online Games Li, Zetan.
-
Upload
marjorie-sanders -
Category
Documents
-
view
213 -
download
0
Transcript of Network synchronization of Online Games Li, Zetan.
![Page 1: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/1.jpg)
Network synchronization of
Online Games
Li , Zetan
![Page 2: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/2.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/3.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/4.jpg)
Synchronization
• Peer-to-peer lockstep
• Client/server
![Page 5: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/5.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/6.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/7.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/8.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/9.jpg)
msgmsg
Client
Client
Server
![Page 10: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/10.jpg)
Problems for Client/Server model
• Latency makes game sucksSolution
• Client-Side Prediction • Latency Compensation
![Page 11: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/11.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/12.jpg)
Networked Physics
• What is physics engine
• Game with physics simulation
![Page 13: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/13.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/14.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/15.jpg)
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.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/16.jpg)
Why Not TCP?
• Games have a real time requirement on packet delivery. Packet loss will make game stop and wait for packet resent.
![Page 17: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/17.jpg)
References• http://gafferongames.com/networking-for-game-programmers/what-ev
ery-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/udp-vs-tcp/
• http://gafferongames.com/game-physics/networked-physics/
• http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php
![Page 18: Network synchronization of Online Games Li, Zetan.](https://reader036.fdocuments.in/reader036/viewer/2022062713/56649cf45503460f949c293b/html5/thumbnails/18.jpg)
Thank You!
Questions??