Lecture notes.


Published on

  • Be the first to comment

  • Be the first to like this

No Downloads
Total Views
On Slideshare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Lecture notes.

  1. 1. Last Time <ul><li>More collision detection packages </li></ul><ul><li>Time critical collision detection </li></ul><ul><li>Introduction to networking for games </li></ul>
  2. 2. Today <ul><li>Networking protocols </li></ul><ul><li>Cheating and Security </li></ul><ul><ul><li>Great article: Evaluations </li></ul></ul>
  3. 3. Internet Protocols <ul><li>There are only two internet protocols that are widely deployed and useful for games: UDP and TCP/IP </li></ul><ul><ul><li>TCP/IP (Transmission Control Protocol/Internet Protocol) is most commonly used </li></ul></ul><ul><ul><li>UDP (User Datagram Protocol) is also widely deployed and used </li></ul></ul><ul><li>Other protocols exist: </li></ul><ul><ul><li>Proprietary standards </li></ul></ul><ul><ul><li>Broadcast and Multicast are standard protocols with some useful properties, but they are not widely deployed </li></ul></ul><ul><ul><li>If the ISPs don’t provide it, you can’t use it </li></ul></ul>
  4. 4. TCP/IP Overview <ul><li>Advantages: </li></ul><ul><ul><li>Guaranteed packet delivery </li></ul></ul><ul><ul><li>Ordered packet delivery </li></ul></ul><ul><ul><li>Packet checksum checking (some error checking) </li></ul></ul><ul><ul><li>Transmission flow control </li></ul></ul><ul><li>Disadvantages: </li></ul><ul><ul><li>Point-to-point transport </li></ul></ul><ul><ul><li>Bandwidth and latency overhead </li></ul></ul><ul><ul><li>Packets may be delayed to preserve order </li></ul></ul><ul><li>Uses: </li></ul><ul><ul><li>Data that must be reliably sent, or requires one of the other properties </li></ul></ul><ul><ul><li>Games that can tolerate latency </li></ul></ul>
  5. 5. UDP Overview <ul><li>Advantages: </li></ul><ul><ul><li>Low overhead in bandwidth and latency </li></ul></ul><ul><ul><li>Immediate delivery - as soon as it arrives it goes to the client </li></ul></ul><ul><li>Disadvantages: </li></ul><ul><ul><li>Point to point connectivity </li></ul></ul><ul><ul><li>No reliability guarantees </li></ul></ul><ul><ul><li>No ordering guarantees </li></ul></ul><ul><ul><li>Packets can be corrupted </li></ul></ul><ul><ul><li>Can cause problems with some firewalls </li></ul></ul><ul><li>Uses: </li></ul><ul><ul><li>Data that is sent frequently and goes out of date quickly </li></ul></ul>
  6. 6. Choosing a Protocol <ul><li>The best way to do it is decide on the requirements and find the protocol to match </li></ul><ul><ul><li>In most cases, that means TCP/IP </li></ul></ul><ul><li>You can also design your own “protocol” by designing the contents of packets </li></ul><ul><ul><li>A protocol is simply a set of rules for putting data in the packets and acting upon it </li></ul></ul><ul><ul><li>Add cheat detection or error correction, for instance </li></ul></ul><ul><ul><li>You then wrap you protocol inside TCP/IP or UDP – just send your “packet” as a regular chunk of data </li></ul></ul>
  7. 7. Reducing Bandwidth Demands <ul><li>Bandwidth is plentiful on the internet today, so it only becomes an issue with large environments </li></ul><ul><ul><li>Even “slow” modems have more impact through high latency than low bandwidth (due to compression, error checking and analogue/digital conversion) </li></ul></ul><ul><li>Regardless, smaller packets reduce both bandwidth and latency </li></ul><ul><ul><li>Latency is measured from the time the first bit leaves to the time the last bit arrives - so fewer bits have lower latency </li></ul></ul><ul><li>There are two primary ways to reduce bandwidth demands: </li></ul><ul><ul><li>Dead reckoning allows you to send state less frequently </li></ul></ul><ul><ul><li>Area of interest management avoids sending irrelevant data </li></ul></ul>
  8. 8. Area of Interest Management <ul><li>Area of interest management is the networking equivalent of visibility - only send data to the people who need it </li></ul><ul><li>There is a catch, however: In a network you may not know where everyone is, so you don’t know what they can see </li></ul><ul><ul><li>A chicken-and-egg problem </li></ul></ul><ul><li>Hence, area-of-interest schemes are typically employed in client-server environments: </li></ul><ul><ul><li>The server has complete information </li></ul></ul><ul><ul><li>It decides who needs to receive what information, and only sends information to those who need it </li></ul></ul><ul><li>Two approaches: grid methods and aura methods </li></ul><ul><ul><li>Sound familiar? (replace aura with bounding box) </li></ul></ul>
  9. 9. Grid and Aura Methods <ul><li>Grid methods break the world into a grid </li></ul><ul><ul><li>Associate information with cells </li></ul></ul><ul><ul><li>Associate players with cells </li></ul></ul><ul><ul><li>Only send information to players in the same, or neighboring, cells </li></ul></ul><ul><ul><li>This has all the same issues as grid based visibility and collision detection </li></ul></ul><ul><li>Aura methods associate an aura with each piece of information </li></ul><ul><ul><li>Only send information to players that intersect the aura </li></ul></ul><ul><ul><li>Just like broad-phase collision detection with bounding volumes </li></ul></ul><ul><li>Players need to find out all the information about a space when they enter it, regardless how long ago that information last changed </li></ul><ul><ul><li>In other words, have to be careful with “state” information that is infrequently sent </li></ul></ul>
  10. 10. Building for Networking <ul><li>It is generally agreed that networking must be a consideration from the start of development </li></ul><ul><li>There are many good practices – see game programming web sites for tips (and descriptions of past mistakes) </li></ul><ul><li>One good practice: Access all data through a consistent interface, which both the networking and local code uses </li></ul><ul><ul><li>Avoids different side effects from different access points </li></ul></ul><ul><ul><li>Can check for validity of data in one place, which makes checking for network errors easier </li></ul></ul><ul><ul><li>Can decrypt/encrypt in one place </li></ul></ul><ul><ul><li>Can automatically propagate data onto network </li></ul></ul>
  11. 11. Cheating <ul><li>It’s an arms race… </li></ul><ul><ul><li>http://www.gamasutra.com/features/20000724/pritchard_01.htm </li></ul></ul>
  12. 12. Why Care About Cheats? <ul><li>Online gaming is big business </li></ul><ul><li>Cheats can achieve financial advantage: </li></ul><ul><ul><li>Competitive games with prizes are the obvious example (casinos) </li></ul></ul><ul><ul><li>Also consider EverQuest: People play the game, build good characters, and then auction them on ebay. If they can cheat to obtain good characters, they are achieving unfair financial advantage </li></ul></ul><ul><li>Cheats can ruin the game for everyone: </li></ul><ul><ul><li>Players tend to have a strong sense of fairness </li></ul></ul><ul><ul><li>If they believe they are being cheated, they will not play, and you will not make any money </li></ul></ul><ul><li>Single player cheaters typically only affect themselves, so you don’t care </li></ul>
  13. 13. Sources of Cheats <ul><li>Reflex augmentation : Use a cheat to improve some aspect of physical performance, such as the firing rate or aiming </li></ul><ul><li>Authoritative clients : Clients issue commands that are inconsistent with the game-play, or mimic the server </li></ul><ul><li>Information Exposure : Clients obtain information that should be hidden </li></ul><ul><li>Compromised servers : A hacked server biases game-play toward the group that knows of the hacks </li></ul><ul><li>Bugs and Design Loopholes : Bugs are found and exploited, or parts of the program intended for one purpose are used for another </li></ul><ul><li>Environmental Weakness : Differences or problems with the OS or network environment are exploited </li></ul>
  14. 14. Observations About Cheating <ul><li>The only way to make a system 100% secure is to completely isolate it (Eric Brewer, 1996) </li></ul><ul><li>Pritchard’s Rules (Gamasutra article): </li></ul><ul><ul><li>If you build it, they will come - to hack and cheat </li></ul></ul><ul><ul><li>Hacking attempts increase as a game becomes more successful </li></ul></ul><ul><ul><li>Cheaters actively try to control knowledge of their cheats </li></ul></ul><ul><ul><li>Your game, along with everything on the cheater’s computer, in not secure - not memory, not files, not devices and networks </li></ul></ul><ul><ul><li>Obscurity is not security </li></ul></ul><ul><ul><li>Any communication over an open line is subject to interception, analysis and modification </li></ul></ul><ul><ul><li>There is no such thing as a harmless cheat </li></ul></ul><ul><ul><li>Trust in the server is everything in client-server games </li></ul></ul><ul><ul><li>Honest player would like the game to tip them off to cheater, hackers hate it </li></ul></ul>
  15. 15. Reflex Augmentation <ul><li>Aiming proxies intercept communications, build a map of where people are, and automatically shoot them </li></ul><ul><li>Rapid-fire proxies take each “shoot” packet and replicate it </li></ul><ul><li>Fix #1: The server validates player actions - if they are too good the player is considered a cheat and kicked out </li></ul><ul><ul><li>What’s hard about this? </li></ul></ul><ul><li>Fix #2: Make it difficult to insert non-valid packets </li></ul><ul><ul><li>Encrypt the packets, but your encryption must be cheap, and cheap encryption can be broken </li></ul></ul><ul><ul><li>Make the encryption depend on the game state or other time-dependent “random” value. Hard to do with UDP. Why? </li></ul></ul><ul><ul><li>If using guaranteed delivery (TCP) serialize packets with a unique sequence of numbers - cannot then replicate or insert extra packets </li></ul></ul>
  16. 16. A Word on Encryption <ul><li>Typically: A key – known only to intended users – is used to convert regular data into something that looks random </li></ul><ul><ul><li>Cannot go from random data back to key, or to the real data </li></ul></ul><ul><li>Many ways to come up with the key </li></ul><ul><ul><li>Agree on it ahead of time </li></ul></ul><ul><ul><li>Transmit it – key exchange algorithms </li></ul></ul><ul><ul><li>Derive it from somewhere else in such a way that all parties derive the same key (e.g. from game state) </li></ul></ul><ul><li>Most encryption algorithms work on blocks of a fixed size </li></ul><ul><ul><li>Split large amounts of data into smaller blocks </li></ul></ul><ul><ul><li>Pad blocks that are too small </li></ul></ul>
  17. 17. Authoritative Clients <ul><li>Occurs when one player’s game informs everyone else that a definitive event has occurred: e.g. I just got a power-up </li></ul><ul><li>Hacked clients can be created in many ways: change the executable, change game data in other files, hack packets </li></ul><ul><li>Fix is to insert command request steps: </li></ul><ul><ul><li>Player request an action, its validity is checked, it is sent out on the network, and added to the player’s pending event queue </li></ul></ul><ul><ul><li>Incoming actions also go on the pending queue </li></ul></ul><ul><ul><li>Actions come off the pending queue, are validated again, and then are implemented </li></ul></ul><ul><li>Sometimes validation is hard to get right, so try synchronization </li></ul><ul><ul><li>Occasionally send complete game state around, and compare it </li></ul></ul><ul><ul><li>Actually, send something derived from complete game state </li></ul></ul>
  18. 18. Information Exposure <ul><li>Some classics: Modify the renderer to make walls transparent, modify maps to remove the fog of war </li></ul><ul><li>Basically, display variables must be modified in memory, or read out and displayed elsewhere </li></ul><ul><ul><li>Hackers are very good at finding the locations of key data in memory, and modifying them transparently </li></ul></ul><ul><li>Fixes: </li></ul><ul><ul><li>Check that players agree on the value of certain variables, and the validity of actions - synchronization again </li></ul></ul><ul><ul><ul><li>Note that you can look for actions that cannot be valid with the correct display </li></ul></ul></ul><ul><ul><li>Compile statistics on drawing, and see of they look off (eg # polygons drawn) </li></ul></ul><ul><ul><li>Encrypt data in memory to avoid passive attacks </li></ul></ul>
  19. 19. Compromised Servers <ul><li>Many servers have customization options, and the community is encouraged to modify the server </li></ul><ul><ul><li>This is completely legal </li></ul></ul><ul><li>However, as a game becomes popular, naïve people start to play the game </li></ul><ul><ul><li>They do not have the skills or knowledge to check that the server they are playing on is “pure” </li></ul></ul><ul><ul><li>They will grow frustrated, blame the developer, and complain to their friends </li></ul></ul><ul><li>Some modifications can be very insidious, and may not be legal. For example, hack the server to do different damage for opponents </li></ul><ul><li>Solution is to warn people when they connect to the server, and about any other non standard properties (found through validation) </li></ul>
  20. 20. Bugs and Design Issues <ul><li>Some bugs enable cheating, such as a bug that enables fast reloading, or one that incorrectly validates commands </li></ul><ul><li>Some design decisions make cheating easier: </li></ul><ul><ul><li>Embedding cheats codes in single player mode makes it easy for a hacker to track down the variables that control cheats </li></ul></ul><ul><ul><li>Poor networking or event handling can allow repeat commands or other exploitations </li></ul></ul><ul><ul><ul><li>Age of Empires and Starcraft example: all resource management is done after all events for a turn are processed. Poor networking allowed multiple cancel events on the queue, which restored multiple resources </li></ul></ul></ul><ul><li>Solution is to avoid bugs and think carefully about the implications of design decisions on hacking </li></ul>
  21. 21. Environmental Weaknesses <ul><li>Facilities to deal with the OS or network may leave you vulnerable to some forms of attack </li></ul><ul><ul><li>Interaction with the clipboard can introduce non-printable characters </li></ul></ul><ul><ul><li>Interaction with almost any scripting language may leave you open to hacks not related to the game itself (ie your game could be a way in) </li></ul></ul><ul><ul><li>Network connection drops or overloading can cause problems </li></ul></ul><ul><li>Some cheats destroy the game for every player (tip the board) which can be useful if you are losing </li></ul><ul><li>Others knock off a specific player (your worst enemy, one assumes) </li></ul>
  22. 22. The Moral of the Story <ul><li>You can’t win, you just try to make cheating as hard as possible and contain the damage </li></ul>
  23. 23. Todo <ul><li>By Thursday, Dec 11, Midday, Final Demo </li></ul><ul><li>Monday, Dec 15, Final Exam, 2:45 P.M, RM 1221 CS </li></ul>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.