Game Development Reference
In-Depth Information
June 6, 2012, and at some point in the future, IPv4 will be deprecated. For now,
most computers on the Internet are reachable via both IPv4 and IPv6 addresses.
However, if your platform and ISP support it, switching on IPv6 is recommended.
ICMP
ICMP,or Internet Control Messaging Protocol ,isnotreallydesignedtotransmit
large amounts of data over the network. Because of this, it cannot be used to send
game data. That being said, there is one aspect of ICMP that is relevant when pro-
gramming a multiplayer game: the ability to echo packets. Through ICMP, it is
possible to send a packet to a specific address and have that packet be directly re-
turned to the sender via the use of the echo request and echo reply ICMP modes.
This echo functionality can be leveraged in order to measure the amount of time it
takes for a packet to travel a round trip between two computers.
Knowing the round trip time, or latency , is useful in scenarios where there are
multiple servers that a player can connect to. If the game measures the latency to
all the possible servers, it will then be able to select the server with the lowest
latency. This process of measuring the latency to a particular address is known as
a ping .
When an echo request is sent, the recipient takes the packet's payload and sends
it all back in an appropriate echo reply packet. Because the ICMP header does not
have any timestamp information, prior to sending out the echo request, the sender
must determine the current timestamp and save it in the payload. When the pay-
load comes back via the echo reply, the difference between the timestamp upon
send and receipt can be computed, giving the round-trip time. This process is usu-
ally repeated a couple of times to get an average latency. The overall layout of an
echo request packet is shown in Figure 12.2 .
Search WWH ::




Custom Search