Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Can the time it takes for a packet to be transmitted from a client to the server fluctuate?

share|improve this question
up vote 9 down vote accepted

The IP protocol, atop which TCP and UDP are constructed, specifies that datagrams are neither guaranteed to arrive in order, nor via the same route, nor, for that matter, at all (thanks Trevor for the reminder). So, irrespective of whether TCP or UDP is used, latency will fluctuate. Latency is partly due to distance travelled, which changes if the path changes, and partly due to protocol stack translation on the routing devices along the chosen path -- which also change if the path changes.

This is part of the self-repairing nature of the internet, enabling it to do what it does every day: if one route becomes less suitable according to heuristics programmed into various routing devices along the way, another route will be chosen instead. This can be either momentary, or long-term. Remember that before it was the internet, it was the ARPANET -- a defense network designed to deal with eg. the instant removal of vast sections of the network (think nuclear warfare), without the network as a whole going down. By routing around damaged or otherwise non-ideal areas, the greater network continues to function (albeit, perhaps, suboptimally).

share|improve this answer
Worth adding that datagrams aren't guaranteed to arrive at all. They can just silently be dropped at any point along their journey. It's only TCP's transport built on top of IP that adds an illusion of reliability to network communications. – Trevor Powell Dec 23 '11 at 3:23
Also see Danny Pflughoeft's answer, he rightly adds that TCP will suffer additional delays due to the way it operates -- if packets are lost, they'll be re-requested and resent, adding an additional full round trip time onto the message latency. And that can happen arbitrarily many times. UDP overcomes this by sending a continual stream of updates, and where the simulation can move ahead in spite of packet loss (much more to think about and plan for in this sort of system, however). – Arcane Engineer Feb 10 '12 at 17:02

This is probably not game development question, but yes. In normal IP connection, each packets may go through different intermediary "hops", and each different "hops" may have different latency.

If you're using TCP to transfer your data, the protocol abstracts that for you and will reorder packets to deliver the packets in the order they were originally sent; however if you're using UDP, the packets can and do arrive out of order, depending on the latency of each individual packets.

share|improve this answer
In particular, if the UDP and TCP packets are being routed the same way and the UDP packets are routinely arriving out-of-order, this translates to "lag spikes" over the same connection using TCP instead. – Martin Sojka Dec 22 '11 at 14:39

Absolutely everything about an IP network can change at any time.

The following article discusses how things like latency, packet loss, and throughput can vary and why: DEI Tech Note 0021: Loss, Latency, and Speed

share|improve this answer

Aside from what's already been said, don't forget that routers are allowed to arbitrarily drop packets, meaning in TCP a packet could theoretically take arbitrarily long to reach its destination (and in UDP, it might never reach its destination!).

share|improve this answer
+1, Very important this. – Arcane Engineer Feb 10 '12 at 17:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.