310 likes | 608 Views
Game Networking. CSE 191A: Seminar on Video Game Programming Lecture 9: Networking UCSD, Spring, 2003 Instructor: Steve Rotenberg Guest Lecturer: Mark Rotenberg. Maslow’s Hierarchy of Needs. Online Communities. Simple Online Games. Offline Games. Network Topology. Client-Server Topology.
E N D
Game Networking CSE 191A: Seminar on Video Game Programming Lecture 9: Networking UCSD, Spring, 2003 Instructor: Steve Rotenberg Guest Lecturer: Mark Rotenberg
Maslow’s Hierarchy of Needs Online Communities Simple Online Games Offline Games
Network Topology Client-Server Topology Peer-to-Peer Topology
Networking Evils • Security • Cheating • Latency (up to 100-300ms round-trip) • Bandwidth (64-128 kbps each direction) • Packet Loss (2% with 10% bursts) • Jitter
Lock-Step Simulations • Really easy to implement • Fully synchronize everything • Initial states • Inputs • Time steps • Simulation must be deterministic • Some turn-based games use this at a slower sampling rate (Age of Empires) • Not suitable for fast Internet games
Simulation with Lag Compensation • Server-side movement • Peer/Client-side movement with Host/Server verification • Varying frame rates and latencies • Position history with server-side time warping (Half-Life) • Interpolation - sliding and skipping • Extrapolation – problematic with physics • Syncing orientation, position, inputs
Networking Protocols • TCP (Transport Control Protocol) • Reliable, connection based protocol • Ideal for matchmaking and lobbies but not real-time game play • UDP (Unix Datagram Protocol) • Unreliable, unordered datagram oriented • Good for time-sensitive data but not
Networking Protocols, cont’d • Roll-your-own Protocol • Probably based on UDP • Prioritize and retransmit as necessary • Coalesce or reconstitute packets as necessary • Compression • Encryption • Piggyback Acknowledgements • Heartbeats / Pings / Keep Alive / Network Probes
Game-Specific Protocols • Positions, Inputs, Orientations • Spawning and Removing • Game Events • Match Configurations • State Transitions • Complaints, Connection Status • Heartbeats (pings) • Voice / Chat
Game Data • Most common transmission modes • Reliable • Piggyback ACKs where possible • Unreliable • Should be numbered, may arrive out of order • Other modes • Most recent only • Fastest / Reliable fastest • May transmit multiple times without waiting for ACKs
Network Security • Encryption and Digesting • RSA • Diffie-Hellman • MD5 • DES, triple-DES, AES • IPSec • References • http://www.rsasecurity.com/rsalabs/faq/ • “Applied Cryptography,” Schneier
Network Address Translation Peer 1 • Peer 1 sees: • Peer 2 at 219.3.16.49 : 1000 • Peer 3 at 219.3.16.49 : 49155 • Peer 2 sees: • Peer 1 at 198.214.72.29 : 1000 • Peer 3 at 10.0.0.3 : 1000 • Peer 3 sees: • Peer 1 at 198.214.72.29 : 1000 • Peer 2 at 10.0.0.2 : 1000 198.214.72.29 : 1000 Internet 219.3.16.49 : 1000 219.3.16.49 : 49155 NAT 10.0.0.3 : 1000 10.0.0.2 : 1000 Peer 2 Peer 3
General Programming Suggestions • Always assume networking • Separate cause from effect • Event-based networking code • Multiple levels of state machines • Message passing from network layer to game code • Monitor everything • WAN simulation hardware/software • Lots of asserts and debug messages • Lots of unit tests • Lots of product testing
Matchmaking and Community • Matchmaking • Competitions, Ladders, Leader Boards • Friends, Invitations • Feedback – both good and bad • Content Sharing
PS2 Strategy 5 networking stacks to choose from!? No built-in support for voice, security, authentication Various middleware vendors Publishers or users provide servers Xbox Strategy Very well designed networking stack and APIs Connect only through Microsoft’s servers Every packet, machine, user, hard drive, DVD, user can be authenticated Gamertags work across multiple titles Consistent billing interface Strict User Interface Guidelines Online Strategies – Sony vs. Microsoft
Deployment Issues • Patching • Maintenance • Who pays for bandwidth? • Billing • Scalability • Monitoring Usage and Statistics • Handling Cheaters • Detecting Piracy • Who “owns” users? • “Policing” the Community
Massively Multiplayer Online Games • Huge Development Costs • Virtual Economies • Community • Server Scalability • Keeping content new and interesting
Future Considerations • IPv6 • Handhelds and Cell phones • Cross-Title Integration • Server-side “Mods” • Peer-to-Peer MMOGs? • Sony “Cell” Processor
Questions? Contact me at mark [at] rockstarsandiego.com.