Ch-5 Time Synchronization
Ch-5 Time Synchronization
Clock Synchronization:
Physical Clocks
UTC time, t
Drift with slow clock
skew
Computer’s time,
C
UTC time, t
Drift with fast clock
skew
Computer’s time,
C
UTC time, t
Dealing with drift
Assume we set computer to true time
If fast:
Make clock run slower until it synchronizes
If slow:
Make clock run faster until it synchronizes
Dealing with drift
OS can do this:
Change rate at which it requests interrupts
e.g.:
if system requests interrupts every
17 msec but clock is too slow:
request interrupts at (e.g.) 15 msec
Or software correction: redefine the interval
Clock synchronized
skew
Linear compensating
function applied
C
UTC time, t
Compensating for a fast clock
Computer’s time, C
UTC time, t
Resynchronizing
After synchronization period is reached
– Resynchronize periodically
– Successive application of a second linear
compensating function can bring us closer to true
slope
Time server
RPC
Simplest synchronization technique
– Issue RPC to obtain time
– Set time
Tserver
server
request reply
client
T0 T1 time
Cristian’s algorithm
Client sets time to:
Tserver
server
request reply
client
T0 T1 time
= estimated overhead
in each direction
Error bounds
If minimum message transit time (Tmin) is known:
range = T1-T0-2Tmin
accuracy of result =
Cristian’s algorithm: example
• Send request at 5:08:15.100 (T0)
• Receive response at 5:08:15.900 (T1)
– Response contains 5:09:25.300 (Tserver)
server
request reply
client
T0 T1 time
200 200
800
Error =
Berkeley Algorithm
• Gusella & Zatti, 1989
If master fails
– Any slave can take over
Berkeley Algorithm: example
3:00
2:50
3:00
2:50
+0:15
d = (T4-T1) - (T2-T3)
SNTP example
T2=800 T3=850
server
request reply
time
client
T1=1100 T4=1200
Offset =
((800 - 1100) + (850 - 1200))/2
=((-300) + (-350))/2
= -650/2 = -325 Time offset:
Set time to T4 + t
= 1200 - 325 = 875
Cristian’s algorithm
T2=800 T3=850
server
request reply
Ts=825 time
client
T1=1100 T4=1200