In real-time multiplayer games that use UDP for the actual game (CS:S, UT, etc.), how is network latency (ping) measured? More specifically, how do you find out how long ago a UDP packet was sent?

Sorry if this is a dumb question, but I'm very new to network programming.

  • \$\begingroup\$ Update: on the Quake 3 Networking Model page (web.archive.org/web/20110718080312/http://trac.bookofhook.com/…), there's a mention of unreliable acks. Would this be a good approach — send out a bunch of unreliable UDP packets, noting their sequence number, and then record (halve?) the round-trip time when an ack for a packet returns? \$\endgroup\$ – Archagon Feb 27 '12 at 18:50

Just send some 'ping', write timestamp of that packet/session, wait for 'pong' response and get timestamp 'now' and divide the difference by two.

  • \$\begingroup\$ Thank you! In retrospect, this seems really obvious, but I'm really new to all this. :) \$\endgroup\$ – Archagon Feb 27 '12 at 19:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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