Sign in to follow this  
peter_b

Syncing clocks.

Recommended Posts

peter_b    200
Im intrested in calculating the roundtrip time as good as possible for my game, since alot of things are dependant on that the clock on both client and server are about the same. (for instance, extrapolation, that takes a send-time and a recv-time). Is it good enough to calculate the roundtrip over say 5 sec's with 10 packets or so at game start, or should this be done troughout whole game session?

Share this post


Link to post
Share on other sites
hplus0603    11347
The round trip time may change, so it's better to be able to re-estimate the clock. A simple way is to start with some estimate (say, 200 ms), and then use a running average (leaky integrator) with the time measured through packets.

Typically, the client will send to the server "this is the time for sample #n", and the server will send "I received sample #n at time Q; I sent this response at time T". The client will then receive a packet, and can calculate round-trip time as receive time - send time - (server send time - server receive time). This removes the dependency on the server processing time, to measure only actual network layer time.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this