05 Clock Synchronization Slides
05 Clock Synchronization Slides
Paul Krzyzanowski
Rutgers University
Fall 2018
Data store
x=4
P0 x=1
x=4
x=8
x=8 Replica data store
P1
x=1
Arrives first
Data store
x=4
P0 x=8
x=4
Inconsistent replicas!
x=8
x=8 Replica data store
P1
x=4
Arrives first
There are problems with this … but physical clocks help this work most of the time
If fast:
Make the clock run slower until it synchronizes
If slow:
Make the clock run faster until it synchronizes
or
Computer’s time, C
Clock synchronized
offset
Linear compensation
function applied
e
ti m
ct
rfe
pe
UTC time, t
Computer’s time, C
UTC time, t
Tserver
server
request reply
client
time
T0 T1
request reply
client
time
T0 T1
!" − !$
= estimated overhead
2 in each direction
T1 −T0
T new =Tserver +
2
request reply
client
T0 T1 time
Tmin Tmin
Earliest time message
Latest time message
arrives
leaves
range = T1 - T0 - 2Tmin
T1 −T0
accuracy of result = ± −T min
2
request reply
client
time
T0 T1
200 200
800
master
3:00
9:
:25 2:50
10
3
master
3:00
9:
:25 2:50
10
3
Suppose
2. Compute fault-tolerant average: max ∂=0:45
3 : 25 + 2 : 50 + 3 : 00
= 3 : 05
3
master
3:00
-6
:20 +0:15
:0
-0 5
• June 2010
– Internet Standard, version 4: RFC 5905-5908
– IPv6 support
– Improve accuracy to tens of microseconds
– Dynamic server discovery
Synchronization Subnet
Symmetric mode
– Peer servers can synchronize with each other to provide mutual
backup
• Usually used with stratum 1 & 2 servers
• Pair of servers retain data to improve synchronization over time
• Accuracy
– How close is the clock to UTC?
• NTP calculates:
– Offset for each pair of messages (θ)
• Estimate of time offset between two clocks
– Delay (δ)
• Travel time: ½ of total delay minus remote processing time
– Dispersion
• Maximum offset error relative to reference clock
request reply
client
time
T1 T4
request reply
client
time
T1 T4
request reply
time
client
T1=1100 T4=1200
Offset =
((800 - 1100) + (850 - 1200)) / 2
= ((-300) + (-350)) / 2
= -650 / 2 = -325 Time offset:
($% −$' ) + ($* − $+ )
!=
2
Set time to T4 + t
= 1200 - 325 = 875
request reply
Ts time
client
T1 T4
!$ + !&
Just define !" =
2
master T1
syn time
c
slave
T2 time
Offset + Delay = T2 - T1
master T1 T4
time
st
ue
syn
req
c
lay
slave de
T2 T3 time
Slave needs to figure out the network delay. Send a delay request
master T1 T4
time
de
st
lay
ue
syn
res
req
c
po
lay
nse
slave de
T2 T3 time
master T1 T4
time
de
st
lay
ue
syn
res
req
c
po
lay
nse
slave de
T2 T3 time
• Accuracy
– NTP usually several milliseconds on WAN
– PTP usually sub-microsecond on LAN