Game Development Reference
In-Depth Information
For a game, guaranteed ordering is usually an unnecessary bottleneck. What if
packets A, B, and C in the preceding example contain information regarding the
position of a specific player: that is, first the player was at position A, then at po-
sition B, and finally at position C. Once position C is received, the game really
does not care about position B, as the player is no longer there. But with TCP,
the game will be prevented from reading in position C until position B is received
first, which is definitely not a desirable scenario.
There is one other helpful aspect of TCP to consider. All networks have an MTU,
or maximum transmission unit , which determines the size limit for packets. If
you attempt to send a packet that's larger than the MTU, it will not go through.
Thankfully, TCP is designed such that the operating system will automatically
break up large blocks of data into the correct-sized packets. So if you need to
download a 1MB file from the Web, the process of breaking it down into the
appropriate-sized packets that must be received in the correct order is abstracted
away from the application programmer when TCP is utilized.
In most scenarios, it probably will not be necessary to transmit such large amounts
of data during gameplay. But there are some fringe uses where the automatic pack-
et creation is helpful—for example, if a game supports custom maps, one issue is
that new players may attempt to join a game session where they do not have the
custom map. Using TCP, it would be possible to painlessly send that custom map,
regardless of the size, to a new player trying to join the game.
That being said, for actual gameplay there are really only a few types of games
that consistently use TCP. For a turn-based game, it makes sense to use TCP be-
cause all of the information sent over the network is presumably relevant, because
it will define what actions a player performed on a particular turn. Another genre
where TCP might see some use is in MMOs; most notably World of Warcraft util-
izes TCP for all of its data transmission. That's because all of the actions in WoW
are strictly ordered, so it makes sense to use a protocol that has this ordering built
in. But games that have more real-time action, such as FPS or any action games,
typically do not use TCP/IP. This is because the forced guarantee of all packets
might be to the potential detriment of the game's performance.
Because TCP is a fairly complex protocol, the TCP header is as large as the IP
header (20 bytes). The overall layout of the header is shown in Figure 12.5 .
Search WWH ::




Custom Search