Docsity

Networking in Games - Computer Networks - Class Notes | EECS 489, Study notes of Electrical and Electronics Engineering

Toggle sidebar
bg1
Networking in Games
In-game networking:
•networking topology: client-server vs. peer-to-peer
•computing model: distributed object vs. message passing
•which protocol to use? tcp, udp, reliable udp
•bandwidth limitation
•latency limitation
•consistency
•cheat proofing
•socket programming WinSocks
Machine 1 Machine 2
in library/kernel
(EECS 489)
in game
(more in EECS 591/491)
Network: LAN or Internet
Distributed
Systems
Networking
Distributed
Systems
Networking
Sugih Jamin ([email protected])
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34
pf35
pf36
pf37
pf38

Partial preview of the text

Download Networking in Games - Computer Networks - Class Notes | EECS 489 and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Networking in Games

In-game networking:

  • networking topology: client-server vs. peer-to-peer
  • computing model: distributed object vs. message passing
  • which protocol to use? tcp, udp, reliable udp
  • bandwidth limitation
  • latency limitation
  • consistency
  • cheat proofing
  • socket programming (^) WinSocks

Machine 1 (^) Machine 2

in library/kernel (EECS 489)

in game (more in EECS 591/491)

Network: LAN or Internet

Distributed Systems

Networking

Distributed Systems

Networking

Consistency

Problem statement:

time

player1 (^) player

fire^ move

fire move

How do you differentiate the two cases, at both player1 and player2?

When to Render a Move?

How long do you have to wait for the other players’ moves before rendering them?

time

player1 (^) player

fire^ move

fire^ move

fire^ move

X

Lock-step Protocol

  • each player receives all other players’ moves before rendering next frame

Problems:

  • long Internet latency
  • variable latencies
  • speed determined by the slowest player

time

Player1 Player

synchronize moves and render scene

Pessimistic Consistency

Every player must see the EXACT same world

AoE/AoK/AoM:

  • each player simulates its own copy of the world
  • all the worlds must be in sync.
  • uses bucket synchronization
  • each player sends moves to all other players
  • dropped packets retransmitted
  • a designated host collect measured rtts from all players and set future bucket sizes

Problems:

  • variable latencies
  • speed determined by the slowest player

Dead Reckoning

  • a.k.a. client-side prediction
  • extrapolate next move based on prior moves
  • compute the velocity and ac- celeration of objects to dead reckon - players can help by sending this info along - obviously, only works if ve- locity and acceleration haven’t changed

v

move lost or late, dead reckoned

Optimistic Consistency with Roll-back

Observation: dead reckoning doesn’t have to be limited to lost packets!

Half-Life:

  • each client plays back its own moves immediately and send the moves to server
  • each client also dead reckons the other players’ moves
  • server computes world and sends its authoritative version to all clients
  • clients reconcile dead reckoned world with server’s version
  • can result in some jerkiness and perception of “shooting around corner”
  • only need to synchronize important events, but must be careful that dead reckoning error doesn’t get compounded over time

Consistency: Correctness

For consistency ALL user input MUST pass through the synchro- nization module

Be careful with random number generators. Isolate the one used for game-state updating from other uses (ambient noise etc.)

Design for multiplayer from the start. Single-player becomes a special case of single-client multiplayer game

Initialization Overall GameControl Game SessionControl

Local PlayerInput

Receive RemotePlayer(s) Input Main Logic:

    • game AI consistency
  • physics- collision

Local Input^ Send

Render sceneto buffer

Copy buffer todisplay

Time sync

Reducing Consistency Check

Do area-of-interest management (a.k.a. relevance filtering):

  • aura : how far you can be sensed (cloaked ships have 0 aura)
  • nimbus : how far you can sense (use quantum-sensor to detect cloaked ships)

Aura and nimbus are defined for a given set of “technology” (e.g., cloaking device, quantum sensor, etc.)

Perform consistency check only when B is within A’s nimbus and A is within B’s aura

Cheating

AoE doesn’t need cheat-proofing because each player simulates each move in lock step All moves are simulated, not just collisions

Half-Life synchronizes only collisions, higher probability for cheating

Cheats (more at megagames.com):

  • superhuman cheat: auto-aim, auto-position
  • game-state editing: boost player’s profile
  • rule bending: see/walk through walls
  • sixth-sense cheat
  • lookahead cheat: claim to be behind slow link
  • suppress-correct cheat: exploit dead-reckoning, claim moves were lost, then “reconstruct” advantageous moves based on others’ moves

Suppress-correct Cheat

At time 150, C sends out a move consistent with fake moves at time 0, 50, 100 that were actually computed upon receiving packets from Player H

Player C Player H 0 50 100

200

150

250

0 50 100

200

150

250

t= t= t=

X

X

X

Distributed Computing Model

Message passing:

  • player inputs (either button pushes or higher-level move- ments) are sent to other players (or server)
  • all players update their own game state
  • or server updates the global game state and send it out to all players

Initialization Overall GameControl Game SessionControl

Local PlayerInput Receive RemotePlayer(s) Input Main Logic:- update states

  • game AI- physics
  • collision

Local Input^ Send

Render sceneto buffer

Copy buffer todisplay

Time sync

Player inputs sent/received using sockets

Socket Programming

What is a socket?

How to use socket for client-server computing?

Socket Programming

socket : a data structure containing connection information

Connection identifying information:

  • client IP (Internet Protocol) address
  • client port number
  • source IP address
  • source port number

Client-server connection:

  • server creates a socket and listens for connections on a well-known port number
  • client creates a socket and connects to the server address at the well-known port number