[ENet-discuss] Time synchronization client/server/client communication.

Syed Setia Pernama syedhs at yahoo.com
Tue Mar 2 22:58:34 PST 2010


Yes this is a common 'challenge' in network game. The best link I have so far is this: http://www.mine-control.com/zack/timesync/timesync.html

The algorithm from the article:-

	1. Client stamps current local time on a "time request" packet and 
sends to server
	2. Upon receipt by server, server stamps server-time and returns
	3. Upon receipt by client, client subtracts current time from sent time and divides by two to compute latency.  It subtracts current time from 
server time to determine client-server time delta and adds in the 
half-latency to get the correct clock delta.
(So far this algothim is very similar to SNTP)
	4. The first result should immediately be used to update the clock 
since it will get the local clock into at least the right ballpark (at 
least the right timezone!)
	5. The client repeats steps 1 through 3 five or more times, pausing a 
few seconds each time.  Other traffic may be allowed in the interim, but should be minimized for best results
	6. The results of the packet receipts are accumulated and sorted in 
lowest-latency to highest-latency order.  The median latency is 
determined by picking the mid-point sample from this ordered list.
	7. All samples above approximately 1 standard-deviation from the median are discarded and the remaining samples are averaged using an 
arithmetic mean.

 
----- Original Message ----
From: Alexander Shyrokov <sj at sjcomp.com>
To: enet-discuss at cubik.org
Sent: Wed, March 3, 2010 6:41:51 AM
Subject: [ENet-discuss] Time synchronization client/server/client communication.

Hello,

I have multiple clients connected to the server. The server echos the received data from any single client to the rest of the clients. I would like to know the time when a packet is sent by the original client. How do I do that? It is clearly a very common situation in games. I get position of a player with the velocity. Given that some time elapsed since the packet was sent I can estimate current position by using elapsed time and the velocity to get the offset.


      


More information about the ENet-discuss mailing list