Escolar Documentos
Profissional Documentos
Cultura Documentos
Networking
Overview
n
n
n
n
Multiplayer Modes
Networking Fundamentals
Networking for Games
Networking for Unity
Easier to implement
Puzzle / board game
Non-real time connection
n
n
Shared I/O
n
Input Devices
n
n
Display
n
Multiplayer Modes:
Connectivity
n
Non Real-Time
n
Direct Link
n
(turn based)
Packet Switched
n
n
Internet
Shared Pipe
5
Multiplayer Modes:
now with Networking!
n
Turn-Based
n
Real-Time
n
n
Networking:
When do we need it?
n
n
n
Downloadable content
DRM
Multiplayer
n
n
Portal 2 will
probably be Valve's
last game with an
isolated singleplayer experience *
Networking
At a glance
n
n
n
Protocol Stack:
Open System Interconnect
Sender
Receiver
Input Updates
State Updates
Application
Game Events
Application
Presentation
Game Packetization
Presentation
Session
Session
Transport
Transport
Network
Network
Network
Network
Data Link
Data Link
Data Link
Data Link
Physical
Physical
Physical
Physical
Router
Serialization
Buffering
Sockets
TCP
UDP
IP
Ethernet (MAC)
Wired (C5, Cable)
Fiber Optics
Wireless
Physical Layer
n
Bandwidth
n
n
Latency
n
n
The Medium
n
Speed
(bps)
Serial
USB
1&2
ISDN
DSL
20K
12M
480M
128k
1.5M down
896K up
Cable
LAN
10/100/1G
BaseT
Wireless
802.11
a/b/g
Power
Line
T1
3M down
256K up
10M
100M
1G
b=11M
a,g=54M
14M
1.5M
10
Ethernet
MAC Address
11
Network Layer
n
Packet Routing
n
Hops
n
n
n
n
No connection
Guarantees sending
Doesnt guarantee receiving
Non-deterministic path
12
Network Layer:
Domain Name Service
n
Game Tips
n
Transport Layer
n
Error recovery
Data flow
Contains Source and Destination Port
Transport Layer:
Connection based
n
n
n
n
n
n
Flow Control
Easy to use
n
Keep Alive
Handles breaking up data into correct size
Packet window
Packet Coalescense
Transport Layer:
User Datagram Protocol
n
n
No connection
No guarantees
n
n
n
n
Datagram
n
Capable of broadcasting
16
Transport Layer:
TCP vs UDP
n
Which to use?
n
TCP
n
UDP
n
n
n
17
Session Layer
n
Connect
Terminate
Data Exchange
Cross platform
Cross language
18
Session Layer:
Sockets
n
File Descriptors
Open/Close
Read/Write
Modes
n
Blocking
n
Non-blocking
n
19
Presentation Layer
n
Compression
Encryption
Endian Order
n
n
n
0b1000 vs 0b0001
Serialize
Buffering
n
n
n
Packet Coalescense
Increased Latency
Store local data and wait
20
Application Layer
n
n
n
n
n
21
Protocol Stack:
Open System Interconnect
Your Game Logic
Application Set
Sender
Receiver
Game Engine
Input Updates
State Updates
Application
Game Events
Application
Presentation
Game Packetization
Presentation
Session
Session
Transport
Transport
Network
Network
Network
Network
Data Link
Data Link
Data Link
Data Link
Physical
Physical
Physical
Physical
Router
Serialization
Buffering
Sockets
TCP
UDP
IP
Ethernet (MAC)
Wired (C5, Cable)
Fiber Optics
Wireless
22
23
Connection Models
n
Broadcast
n
Peer to Peer
n
Client / Server
Good for 2+ player games
n Dedicated lobby server great for player
discovery
n
24
P2
2 players
1 connection
P3
Peer/Peer
x
x =1
Receive
P3
4 players
6 connections
N 1
Send
P2
3 players
3 connections
Broadcast
Connections
P4
P2
P5
P2
P1
N = Number of players
P1
P3
P4
5 players
10 connections
Client/Server
Client = 1
Server = N
Broadcast
Peer/Peer
Client/Server
N-1
Client = 1
Server = N
N-1
N-1
Client = 1
Server = N
25
n
n
Packet loss
n
Inherent latency
n
n
26
Client / Server:
Authoritative
n
n
n
n
Non-Authoritative
n
n
n
Client / Server:
Communication Methods
n
Client to server
n Server to a client
n Server to a set (possibly all) clients
Used for infrequent actions and events
n
n
n
Loading levels
State of infrequently changed object
28
Client / Server:
Communication Methods
n
Update Models
n
Input Reflection
n
n
n
n
n
n
n
n
Client / Server:
Communication Methods
n
Update Models
n
State Reflection
n
n
n
Prioritize
30
Client / Server:
Relevance Sets
Object Views
n
always
Seldom
Housekeeping
n
never
31
Client / Server:
Synchronization
n
n
AI Assist
n
n
Arbitration
n
n
n
32
Client / Server:
Delta compression
Interpolation
Prediction
Lag compensation
33
Client / Server:
Delta compression
n
n
n
34
Client / Server:
Interpolation
n
n
35
Client / Server:
Prediction
n
n
n
Client / Server:
Sync Optimizations Techniques
n
Lag compensation
n
n
n
37
Cheating
n
Valves-Anti-Cheat
Blizzards Warden
38
Cheating
n
n
39
Security
n
provide additional
security functions
40
Security
n
Encryption
n
n
Execution Cryptopgraphy
n
Copy Protection
n
n
n
DRM
Code sheets
Active internet connection
41
n
n
Game Lobby
42
Network Views
n
n
n
n
n
n
n
Higher scalability
API for Unity
Re-implementing Object View structures
44
Overview
API for networking classes
Unitys networking tutorials
Others available online ($$$?)
References:
Networking Overview
n
http://developer.valvesoftware.com/wiki/
Source_Multiplayer_Networking
Overview, Delta Compression, Interpolation, etc.
http://www.gamasutra.com/resource_guide/20020916/
lambright_01.htm
http://gafferongames.com/networking-for-game-programmers/
Includes articles on cross-platforms low level implementation (stuff
that Unity already does for you)
46
References:
Unity
n
Documentation
n
http://unity3d.com/support/documentation/Manual/Networked
%20Multiplayer.html
http://forum.unity3d.com/threads/29015-UniKnowledge-entryUnity-Networking-the-Zero-to-Hero-guide
Example / Tutorials
n
n
http://www.palladiumgames.net/tutorials/unity-networking-tutorial/
http://answers.unity3d.com/storage/temp/13488-networking.zip
47
References:
NAT Punch-through
n
Overview
n
http://www.mindcontrol.org/~hplus/nat-punch.html
http://unity3d.com/support/documentation/Components/netMasterServer.html
48