Upload
magnus-walsh
View
216
Download
2
Embed Size (px)
Citation preview
Time Synchronization in a Collaboration Environment
By Ahmet Uyar
Synchronization of Client times
We would like to put a timestamp on every event fired during a collaboration meeting. So that we could replay the recorded events in the order they occurred.
There may be some other usage of timestamps but replaying is the primary goal.
So we need to synchronize the times of clients, since the computer clocks can vary by minutes or even by hours.
At the beginning of each collaboration meeting, each client synchronizes its own time with the server time while exchanging some number of messages with the server.
Definitions
We define these terms:delta: time difference between a client and the server
delta = t_server – t_client
t_server: server clock time.t_client: client clock timesession_time: is equal to server time in theory and it will be the same for all clients, and will be put on each message as a timestamp.
session_time = t_client + delta = t_server
So our goal is to calculate delta for each client, since then we can calculate the session_time easily.
How we calculate the time difference (delta)-1
Client exchanges one message with the server like following:Client sends a message to the server requesting server’s current time and saves its own time (t_depart)Server receives the request message from the client and sends its current time (t_server) Client receives the reply message from the server and saves its current time (t_arrival)Assuming that travel times from client-to-server and from server-to-client are equals, we can determine the one way travel timet_travel = (t_arrival – t_depart)/2Then delta is:delta = t_server + t_travel – t_arrival
How we calculate the time difference (delta)-2
We need to repeat this process many times.
Some message exchanges take much longer than others.
So we need to ignore those ones which take longer.
We sort the message exchanges in increasing order according to their travel times and take into account only those which take less time. Then we take the average of their delta values.
Currently we do 100 message exchanges and take 75 of them into account.
Problems – Solutions
There are a few problems with time synchronization:I have implemented both the server and the client in Java and java increments the time by 10 or 11ms not by 1ms on PC. It increments by 1ms on Unix.Also computer clocks do not go at the same speed. For example
• In every hour, my PC's clock goes 118ms faster than dirac's clock. • In every hour, my PC's clock goes 136ms faster than aspen's clock. • In every hour, my PC's clock goes 142ms faster than wkkxt13’s clock
(PC).• In every hour, my PC's clock goes 212ms faster than wkkxt15's clock
(PC).
Solution to second problem: Since the difference between the clock speeds is linear, we can run the synchronization program in every 10 minutes for 3 times at the beginning and then we can adjust the delta in every 10 minutes accordingly.
Test Runs
Server runs on dirac and client runs on apollo.ecs.syr.eduTravel time is around 33-34ms round trip and it can determine the time difference with an accuracy of 1-2ms.
Server runs on apollo.ecs.syr.edu and client runs on wkkxt12.csit.fsu.edu
Travel time is 30-40msAccuracy of time difference is 1-2ms
Server runs on dirac and client runs on a PC at Anabas in CA.
Travel time is 140-150msAccuracy is 2-3ms
Timeline
Almost done, I need to add threading to the client to run this program in every 10 minutes.