1 / 30

Game Programming Algorithms and Techniques

Learn about the protocols for transmitting data over the internet, TCP vs UDP for game data, preventing cheating, and network basics such as packet headers and payload.

mbrady
Download Presentation

Game Programming Algorithms and Techniques

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Game Programming Algorithms and Techniques Chapter 12 Networked Games

  2. Chapter 12Objectives • Protocols • Learn the base protocols for transmission of data over the Internet (IP and ICMP) • TCP vs. UDP for game data • Network Topology • Server/client model • Peer-to-peer approaches • Cheating • Learn about the different types of cheats, and what can be done to prevent them, including: • Information cheats • Game state cheats • Man-in-the-middle

  3. Network Basics • Packet—Digital envelope sent over the network • Header— Contains information on where and how data should be sent • Payload— Actual data transmitted • Protocol—Rules that must be followed to transmit data over a network

  4. Internet Protocol (IP) • Base protocol that must be followed to send any data over the Internet. • Two versions: • IPv4 supports roughly ~4 billion addresses, but in today’s world that's not enough. • IPv6 supports 2128 addresses.

  5. IPv4 Header IPv4 header

  6. Internet Control Messaging Protocol (ICMP) Not intended to send large amounts of data over the network Not used to send game data Can be used to check for latency—the amount of time it takes for a round trip between two computers on the network Can be used to find optimal servers

  7. Transmission Control Protocol (TCP) • Connection based—Means two computers must connect with each other before transmission can begin. • Reliable—All data is guaranteed to arrive and in order. • This means that when a packet is received, an acknowledgement is sent. • If no acknowledgement is received after a timeout period elapses, the packet is re-sent. • Easy to transmit large amounts of data.

  8. Games That Use TCP Turn-based games Some MMOs such as World of Warcraft Not typically used for real-time action games (FPS, TPS, etc.)

  9. TCP: Acknowledgement (Ack) In TCP, the sender keeps sending a packet until it receives an acknowledgement.

  10. TCP: Guaranteed Ordering • Guaranteed ordering is unnecessary for a lot of game data. • For example, with position data we only care about the most recent position: • If position at time t + 2 is received, the position at time t + 1 is irrelevant. • The guarantees (both ordering and receipt) make TCP too slow for many real-time games.

  11. TCP: Guaranteed Ordering TCP packets received out of order

  12. TCP: Ports • TCP packets are sent/received on ports, which are like individual mailboxes for different processes on the machine. • Allows for different processes to receive their relevant packets. • Some ports are used commonly for certain services: • Port 80 is the standard port for HTTP web servers. • Game can choose to use any available port.

  13. TCP Header TCP header

  14. User Datagram Protocol (UDP) Unreliable—No acknowledgement that data was received Connectionless—Can just send data blindly Much simpler than TCP, but also much faster Preferred protocol for most real-time games (FPS and so on)

  15. UDP Header UDP header

  16. UDP, Additional Info • UDP ports are separate from TCP ports. • Some data is important (like whether or not a player fired a weapon). • To guarantee delivery of the important data, most games that use UDP add their own thin layer of reliability to it. • cf. Tribes networking model

  17. Network Topology • Determines how various computers in the networked game session connect to each other • Two most common are: • Server/client • Peer-to-peer

  18. Server/Client Server/client model

  19. Server/Client There is one central computer (the server) that all the other computers (the clients) connect to. The server needs more bandwidth/processing power than the clients. The server is authoritative, which means all actions performed by clients must be verified by the server.

  20. Server Authoritative • Because the server is the authority, a client can't just instantly perform actions. • For instance: • In single-player mode, the client might detect a button press and fire the weapon in the same code. • In server/client mode, the client has to send a fire request to the server; it can't just fire the weapon.

  21. Client Prediction • Problem: The client will receive data at a set interval (maybe four times per second). • This includes positional data. • If the client only updates the positions four times per second, everyone will teleport around. • Instead, use client prediction to predict the position for the frames in between the updates.

  22. Client Prediction, Cont'd Client prediction extrapolates the position of the opponents in between server updates.

  23. Host Advantage If a player in the game is also the server, he has a latency advantage over the other players because he is the authority over himself. This can be eliminated by requiring dedicated servers, meaning the server can't be a player in the game.

  24. Peer-to-Peer Each computer is connected to each other (peers). Requires equal amount of data and processing power for each peer in the game. No one authority—either each peer is an authority over another peer, or each peer does a full simulation of the game state. Behavior must be 100% deterministic in peer-to-peer.

  25. Peer-to-Peer, Cont'd Peer-to-peer model

  26. "Lockstep" P2P Used for RTS games. Network update is broken down into discrete turns of a specific duration. Rather than unit info being transmitted, inputs are transmitted. Each peer fully simulates the game state.

  27. Cheating • In multiplayer mode, some players will try to gain an advantage, even if it requires breaking the rules. • Not possible to completely eliminate cheating, but some countermeasures can be put into place. • Categories of cheats: • Information cheats • Game state cheats • Man-in-the-middle

  28. Information Cheats • Player acquires information he should not have. • For example, displaying a character that should be invisible. • Best way to combat this is to only send information when you have to. • For example, don't send position data for invisible players.

  29. Game State Cheats Alter the state of the game Can break the game entirely Especially a problem if the player can be a host

  30. Man-in-the-Middle Attack MITM attacks involve intercepting packets and operating on their data. The way to prevent this is to encrypt packets. This is why HTTPS exists. When login/password information is sent via HTTP, it can easily be intercepted.

More Related