Chapter 5 6 Network and Multiplayer Multiplayer Modes

  • Slides: 27
Download presentation
Chapter 5. 6 Network and Multiplayer

Chapter 5. 6 Network and Multiplayer

Multiplayer Modes: Event Timing Turn-Based Real-Time Difficult to implement Latency sensitive 2

Multiplayer Modes: Event Timing Turn-Based Real-Time Difficult to implement Latency sensitive 2

Multiplayer Modes: Shared I/O Input Devices Shared keyboard layout - yuck Multiple device mapping

Multiplayer Modes: Shared I/O Input Devices Shared keyboard layout - yuck Multiple device mapping Display Full Screen Funneling - everyone stays togetherish Screen Swap – turn based Split Screen – common on consoles 3

Multiplayer Modes: Connectivity Non Real-Time Direct Link Serial, USB, Ir. D, … (no hops)

Multiplayer Modes: Connectivity Non Real-Time Direct Link Serial, USB, Ir. D, … (no hops) Virtual Circuit (phones) Email, database, etc. Dedicated or bandwidth-reserved network Packet Switched Internet Shared pipe == highly variable 4

Protocols: Protocol Design Packet Length Acknowledgment Methodology Error Checking / Correcting Compression Encryption 5

Protocols: Protocol Design Packet Length Acknowledgment Methodology Error Checking / Correcting Compression Encryption 5

Protocols: Packets Header = Protocol Manifest Payload Gotchas (No) Pointers Large Data, Variable Size

Protocols: Packets Header = Protocol Manifest Payload Gotchas (No) Pointers Large Data, Variable Size Data ADTs Byte Alignment Endian Order Processor dependent Types and Sizes (int and long) Unicode vs. ASCII Strings 6

Protocols: Request for Comments RFC web site http: //www. rfc-editor. org/ Protocol Specifications Definitive

Protocols: Request for Comments RFC web site http: //www. rfc-editor. org/ Protocol Specifications Definitive Resource Public Criticism Future Protocols 7

Protocol Stack: Open System Interconnect 8

Protocol Stack: Open System Interconnect 8

Protocol Stack: Physical Layer Bandwidth Width of data pipe Measured in bps = bits

Protocol Stack: Physical Layer Bandwidth Width of data pipe Measured in bps = bits per second Latency Travel time from point A to B Measured in Milliseconds (<50 local, 150 typical, 1500+ common) Table: Max Bandwidth Specifications Speed (bps) Serial USB 1&2 ISDN DSL 20 K 12 M 480 M 128 k 1. 5 M down 896 K up Cable LAN 10/100/1 G Base. T Wireless 802. 11 a/b/g Power Line T 1 3 M down 256 K up 10 M 100 M 1 G b=11 M 9 a, g=54 M 1. 5 M

Protocol Stack: Network Layer Packet Routing Hops (check out traceroute) Routers, Hubs, Switches Internet

Protocol Stack: Network Layer Packet Routing Hops (check out traceroute) Routers, Hubs, Switches Internet Protocol (IP) Contains Source & Destination IP Address In practice, public vs. private internet IP# gets to your firewall/router NAT is ubiquitous Peer-to-peer and servers harder to write 10

Protocol Stack: Network Layer: IP Address Normal == Unicast Multicast Local Directed Loop Back

Protocol Stack: Network Layer: IP Address Normal == Unicast Multicast Local Directed Loop Back Requires multicast capable router Broadcast Send to one particular IP# Static vs. DHCP Send to self Addr. Any 0 = address before receiving an address 11

Protocol Stack: Network Layer: DNS Domain Name Service Converts text name to IP address

Protocol Stack: Network Layer: DNS Domain Name Service Converts text name to IP address Must contact one or more DNS servers to resolve Local cache resolution possible Game Tips Store local game cache to use when DNS “out of order”. <-- DNS often out of order DNS resolution often very slow, use cache for same day resolution. 12

Protocol Stack: Transport Layer Manage data delivery between endpoints TCP and UDP sit atop

Protocol Stack: Transport Layer Manage data delivery between endpoints TCP and UDP sit atop IP Error recovery - retransmit Data “flow” - reorder Contains Source and Destination Port + IP = Net Address Port Range = 0 -64 k Well known Ports 0 -1 k 13

Protocol Stack: Transport Layer: TCP Guaranteed Correct In Order Delivery Acknowledgement system Checksum Out

Protocol Stack: Transport Layer: TCP Guaranteed Correct In Order Delivery Acknowledgement system Checksum Out of Band Connection Required-kinda slow to setup Ack, Nack, Auto Resend Packet Window Packet Coalescence Keep Alive Streamed Data A byte sequence. User must serialize data 14

Protocol Stack: Transport Layer: UDP Non Guaranteed Delivery Not Connected No Acknowledgement system May

Protocol Stack: Transport Layer: UDP Non Guaranteed Delivery Not Connected No Acknowledgement system May arrive out of order Checksum Source not verified Hop Count Limit = TTL (time to live) Required for Broadcasting Datagram Sent in packets exactly as user sends them 15

Protocol Stack: Session Layer Manages Connections between Apps Connect Terminate Data Exchange Socket API

Protocol Stack: Session Layer Manages Connections between Apps Connect Terminate Data Exchange Socket API live at this layer Cross platform Cross language 16

Protocol Stack: Session Layer: Sockets Based on File I/O File Descriptors Open/Close Read/Write Winsock

Protocol Stack: Session Layer: Sockets Based on File I/O File Descriptors Open/Close Read/Write Winsock Provides standard specification implementation plus more Extension to spec prefixed with “WSA” Requires call to WSAStartup() before use Cleanup with WSAShutdown() 17

Protocol Stack: Session Layer: Socket Design Modes Blocking – requires dedicated thread, single connection

Protocol Stack: Session Layer: Socket Design Modes Blocking – requires dedicated thread, single connection Non-Blocking Standard Models Standard “select” - multiple net connections, e. g. X 11, VE server, and DB server if all serviced by same thread 18

Protocol Stack: Presentation Layer Prepares App Data for Transmission Compression Encryption Endean Order Consider

Protocol Stack: Presentation Layer Prepares App Data for Transmission Compression Encryption Endean Order Consider using “Pascal strings”. String Tables – JSON vs. XML, reduction to ints Float to Fixed Matrix to Quaternion When used cross platform or cross language Serialize Pointers --> transmit via deep copy or proxy Variable Length Arrays 19

Protocol Stack: Presentation Layer: Buffering Packet Coalescence Induced Latency Dead Data Large Packets 20

Protocol Stack: Presentation Layer: Buffering Packet Coalescence Induced Latency Dead Data Large Packets 20

Protocol Stack: Application Layer Handles Game Logic Update Models Input Reflection State Reflection Synchronization

Protocol Stack: Application Layer Handles Game Logic Update Models Input Reflection State Reflection Synchronization Dead Reckoning AI Assist Arbitration 21

Real-Time Communications: Connection Models Broadcast Peer to Peer Mostly obsolete, except for player discovery

Real-Time Communications: Connection Models Broadcast Peer to Peer Mostly obsolete, except for player discovery on LANs Good for 2 player games, beware NAT Client / Server Good for 2++ player games Dedicated lobby server great for player discovery 22

Real-Time Communications: Peer to Peer vs. Client/Server N = Number of players Broadcast Connections

Real-Time Communications: Peer to Peer vs. Client/Server N = Number of players Broadcast Connections Send Receive Peer/Peer Client/Server Client = 1 Server = N 0 Broadcast Peer/Peer Client/Server 1 N-1 Client = 1 Server = N N-1 23 Client = 1 Server = N

Real-Time Communications: Asynchronous Environments Thread Priority Suspension Pooling Synchronization Critical Section & Mutex Communication

Real-Time Communications: Asynchronous Environments Thread Priority Suspension Pooling Synchronization Critical Section & Mutex Communication Signal & Event Shared Memory pitfalls 24

Firewalls Packet Filter Packet Shaping Proxies 25

Firewalls Packet Filter Packet Shaping Proxies 25

Firewalls: Network Address Translation 26

Firewalls: Network Address Translation 26

Firewalls: NAT Traversal Specifics configured on router Determining WAN IP Hole punching 27

Firewalls: NAT Traversal Specifics configured on router Determining WAN IP Hole punching 27