Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

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.

share|improve this question
    
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? –  Archagon Feb 27 '12 at 18:50

1 Answer 1

up vote 5 down vote accepted

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

share|improve this answer
    
Thank you! In retrospect, this seems really obvious, but I'm really new to all this. :) –  Archagon Feb 27 '12 at 19:00

Your Answer

 
discard

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.