2
\$\begingroup\$

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.

\$\endgroup\$
1
  • \$\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, 2012 at 18:50

1 Answer 1

6
\$\begingroup\$

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

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .