Professional Documents
Culture Documents
05 Clock Synchronization Slides
05 Clock Synchronization Slides
Paul Krzyzanowski
Rutgers University
Spring 2020
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
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
Drift compensation
function applied
e
im
tt
c
rfe
pe
UTC time, t
Computer’s time, C
e
im
tt
c
rfe
pe
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
900−100 800
Error = ± − 200 = ± − 200 = ±200 ms
2 2
master
3:00
9:
:25 2:50
10
3
master
3:00
9:
:25 2:50
10
3
3 : 25 + 2 : 50 + 3 : 00
= 3 : 05
3
master
3:00
-6
:20 +0:15
:0
5
-0
• June 2010
– Internet Standard, version 4: RFC 5905-5908
– IPv6 support
– Improve accuracy to tens of microseconds
– Dynamic server discovery
Synchronization Subnet
31
NTP Synchronization Modes
Multicast mode
– for high speed LANs
– Lower accuracy but efficient
• Jitter
– Difference in successive measurements
– Due to network delays, OS delays, and clock oscillator instability
• 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
• Use this data to find preferred server:
– Probe multiple servers – each several times
– Pick lowest dispersion … at the lowest stratum if tied
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
req
res
c
p
lay
on
de
se
slave
T2 T3 time
master T1 T4
time
de
st
lay
ue
syn
req
res
c
p
lay
on
de
se
slave
T2 T3 time
• Accuracy
– NTP usually several milliseconds on WAN
– PTP usually sub-microsecond on LAN