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

Alexander Shyrokov sj at sjcomp.com
Tue Mar 2 14:41:51 PST 2010


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.

To simplify, let's take an example: Client A sends a packet to the 
server, server then sends this packet to the Client B. Client B needs to 
know who many seconds ago Client A sent the packet.

There are two stages: first the server needs to know how many seconds 
ago Client A sent the packet, let's call it DelayA; second Client B 
needs to know how many seconds ago the server sent the packet (DelayB), 
as well, as DelayA.

I assume I can use round trip delay to get both delays. The only issue 
is that I am using unreliable packets, meaning that I do not get 
acknowledgments. This means I do not get round trip delays. Is there a 
way around it?

What I plan to do is, to open the communications on three channels. 
Channel 0 will be used to send unreliable packets (the actual data). 
Channel 1 will be used to estimate round trip delays by sending reliable 
packets from the server to every client every N seconds. Server then 
sends information about round trip delays about every client to every 
other client on Channel 2, so that every client could estimate the delay 
for messages that are received. Of course, I could load the server by 
modifying actual packets that are transmitted to the clients to include 
DelayA, and DelayB will be measured directly by the clients.

Any suggestions are welcome. Maybe there is already existing 
implementation to this situation?

Thanks a lot,
Alexander


More information about the ENet-discuss mailing list