Game Network
Programming
@CoreyClarkPhD
@GameTheoryLabs
!
What I Did?
What I Do Now
Crowd
Sourced
Games
Distributed
ComputingMMOs
FoldIt
Crowd
Process
GTL
Determinism & Lock Step
Authoritative Server
Mid-Game Join
Floating point
Latency vs Lag
Fight Lag
!   What is the Cause?
!   Slower But Consistent Frame Rate
!   Animations
!   Client Side Prediction
!   Learning Algorithms
!   Markov Models
!   Artificial Neural Networks
Client Side Prediction
Linear Interpolation
Jitter / Wobble
The Internets …
Peer To Peer (P2P)
Client / Server
Mesh
Network Stack
Sockets
!   Extends Network Layer (Host to Host)
!   End – to – End (App to App)
!   APIs: WinSock & Berkley (BSD)
TCP vs UDP
TCP
!   Connection Based
!   Delivery Guarantee
!   Order Guarantee
!   Flow Control
!   Duplicates Deleted
UDP
!   Connectionless
!   No Delivery Guarantee
!   No Order Guarantee
!   No Flow Control
!   Duplicates
TCP/IP Network
Host
App
Socket
TCP
IP
Channel Channel
Host
App
Socket
TCP
IP
Ethernet,
WiFi,
Bluetooth
Addresses
External Address
Internal Address
MAC Address
ISP
Geo Referenced
Router
Hardware
IEEE Regulated
Ports
!   Communication End
Point
!   Port Forwarding
!   Internal Static IP
!   Stay above 1024
!   Common Ports
!   20: FTP
!   80: HTTP
!   443: HTTPS
!   Registered Ports
!   7778: Unreal
!   26000: Quake
!   27010: Half-Life
!   27960: Quake III
Programming Sockets
!   Blocking
!   Non-Blocking
!   Overlapped I/O
!   Event Handle
!   Completion Port
WinSock Procedure
Client
!   WinSock Init
!   Create Socket
!   Connect
!   Send/Recv
!   Close Socket
!   WinSock Clean Up
Server
!   WinSock Init
!   Create Socket
!   Bind
!   Listen
!   Accept (New Socket)
!   Send /Recv
!   Close Socket
!   WinSock Clean Up
TCP Procedure
Create
Socket
Bind Listen Accept
Create
Socket
Connect
Send
Recv
Send
Recv
Byte Order
Endianness
!   Big Endian
!   MSB in Smallest Addr
!   Intel
!   Little Endian
!   LSB in Smallest Addr
!   Motorola
Host vs Network
!   Host Byte Order (Intel
(Big-Endian)
!   Network Byte Order (Big-
Endian)
! htons, htonl
! ntohs, ntohl
SockAddr.sin_port = htons(nPort);
Startup & Cleanup
WSAStartup( MAKEWORD(2,2), &WSADATA)
WSACleanup()
Create Socket
socket(AF_INET,
SOCK_STREAM,
IPPROTO_TCP);
socket(AF_INET,
SOCK_DGRAM,
IPPROTO_UDP);
Connect
connect(SOCKET tcp,
const struct sockaddr* SockAddr,
sizeof(SockAddr))
Send
int send( SOCKET s,
const char *buf,
int len,
int flags);
Demo
NodeJS
Server
Web Viewer
C++ TCP Client WebSocket Client
Help Me Out
gametheorylabs.com/smuGo To:
Pick Color
Set Color
Questions?

Introduction to Game Network Programming