The question of whether to use TCP or UDP for a networked game is generally the first network related question that needs to be answered. Each have advantages and disadvantages to them, and some games use one, while some use the other. Overall, it is probably safe to say, most networked games use UDP.

None the less, there are some games, and certain genres of games in particular, that often rely on TCP for the guarantee that packets will arrive, even if they do take longer. Often MMO games, such as WoW and Rift rely on the reliability of the TCP protocol.

Why TCP?

There are certain aspects of the game that developers want to have much more control over, in regard to server-client interactions. In particular, Chat will often use TCP as when a player sends a message, they expect it to arrive properly and in full. Similarly, when a player uses an ability in any game, they have a certain expectation that it will be executed in the game world. These are places where the reliability of TCP trumps the potential loss in speed, in many cases.

What should use UDP?

Similarly to the uses of TCP in MMOs, they also rely on the speed of UDP for interactions such as movement between the client and the server. This is often done through the client sending its direction and speed to the server, which will respond with where the player should be located based on that information. The client, while waiting for the server’s response, will do what is called Client Side Prediction, where it will use the data it sent to the server to predict where the server will tell it to be. In these cases, a missing packet will often have a much less noticeable impact on the player than the loss of a packet related to the use of an ability, for instance.

If movement used TCP, rather than UDP, it would likely increase the latency between when a player changed their input and when their character responded to that change, which would impact the sense of immersion in the world. As above, the reliability of a single movement packet isn’t nearly as important as a chat message or a ability, but requires more speed.

Leave a Reply

Your email address will not be published. Required fields are marked *