How online-game clients are able to exchange data through internet so fast?
Asked Answered
T

3

25

Let's imagine really simple game... We have a labirinth and two players trying to find out exit in real time through internet.

On every move game client should send player's coordinates to server and accept current coordinates of another client. How is it possible to make this exchange so fast (as all modern games do).

Ok, we can use memcache or similar technology to reduce data mining operations on server side. We can also use fastest webserver etc., but we still will have problems with timings.

So, the questions are...

  1. What protocol game clients are usually using for exchanging information with server?
  2. What server technologies are coming to solve this problem?
  3. What algorithms are applied for fighting with delays during game etc.
Tod answered 17/5, 2010 at 9:34 Comment(0)
W
9

Usually with Network Interpolation and prediction. Gamedev is a good resource: http://www.gamedev.net/reference/list.asp?categoryid=30

Also check out this one: http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

Weiser answered 17/5, 2010 at 9:39 Comment(1)
Valve still does it the way that paper describes.Trella
W
9
  • use UDP, not TCP
  • use a custom protocol, usually a single byte defining a "command", and as few subsequent bytes as possible containing the command arguments
  • prediction is used to make the other players' movements appear smooth without having to get an update for every single frame

hint: prediction is used anyway to smooth the fast screen update (~60fps) since the actual game speed is usually slower (~25fps).

Woodrowwoodruff answered 17/5, 2010 at 9:37 Comment(2)
It isn't as simple as use UDP over TCP. TCP gives you a lot of really helpful functionality that you will have to build yourself if you use UDP. TCP only has problems if you have packet loss which is fairly uncommon nowadays. Many big MMO's use TCP. UDP is only needed if your game will fail if there are occasional long delays between packets (due to resends of lost packets.) Think long and hard before deciding on UDP.Abiotic
Robert: UDP is used amongst many, many online FPS games-- it's simply the fastest available network protocol because you don't want to wait for TCP to resend packets and check for queue-integrity. I think the answer is valid if the game in question does not need a sort of full integrity check and needs the fastest response times available.Drudgery
W
9

Usually with Network Interpolation and prediction. Gamedev is a good resource: http://www.gamedev.net/reference/list.asp?categoryid=30

Also check out this one: http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking

Weiser answered 17/5, 2010 at 9:39 Comment(1)
Valve still does it the way that paper describes.Trella
N
8

The other answers haven't spelled out a couple of important misconceptions in the original post, which is that these games aren't websites and operate quite differently. In particular:

  • There is no or little "data-mining" that needs to be speeded up. The fastest online games (eg. first person shooters) typically are not saving anything to disk during a match. Slower online games, such as MMOs, may use a database, primarily for storing player information, but for the most part they hold their player and world data in memory, not on disk.
  • They don't use webservers. HTTP is a relatively slow protocol, and even TCP alone can be too slow for some games. Instead they have bespoke servers that are written just for that particular game. Often these servers are tuned for low latency rather than throughput, because they typically don't serve up big documents like a web server would, but many tiny messages (eg. measured in bytes rather than kilobytes).

With those two issues covered, your speed problem largely goes away. You can send a message to a server and get a reply in under 100ms and can do that several times per second.

Nynorsk answered 23/5, 2010 at 10:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.