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

bill k billiumk at gmail.com
Tue Mar 9 13:45:14 PST 2010


Has anyone tried to do time sync over 3g?

I'm trying to synchronize an iphone game where one client is wifi and
another is over 3g. I think the problem is that one direction of travel is
faster than the other

ex.
client sends time-request packet to server
server stamps and responds
client takes the last send time, current time, figures out the
*average*latency and adjusts the time to predict where the server is
right now

the client seems to always be a little bit off though and I think it's
because the sending and receiving speed / packet delays are different. This
would mean the client is *always* over or under compensating.

Does anyone have any insights on this? It's for a real-time game so the
clock really does need to be sync'd to a high precision

thanks in advance,
--
Bill Kouretsos
tel \ 647.477.3817
littleguygames.com


On Wed, Mar 3, 2010 at 1:58 AM, Syed Setia Pernama <syedhs at yahoo.com> wrote:

> 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.
>
>
>
> _______________________________________________
> ENet-discuss mailing list
> ENet-discuss at cubik.org
> http://lists.cubik.org/mailman/listinfo/enet-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.cubik.org/pipermail/enet-discuss/attachments/20100309/714ed816/attachment.htm>


More information about the ENet-discuss mailing list