Académique Documents
Professionnel Documents
Culture Documents
Clock Synchronization:
Physical Clocks
Paul Krzyzanowski
pxk@cs.rutgers.edu
Except as otherwise noted, the content of this presentation is licensed under the Creative Commons
Attribution 2.5 License.
Page 1
Whats it for?
Temporal ordering of events produced by
concurrent processes
Synchronization between senders and
receivers of messages
Coordination of joint activity
Serialization of concurrent access for shared
objects
Page 2
Physical clocks
Page 3
Page 4
Quartz clocks
1880: Piezoelectric effect
Curie brothers
Squeeze a quartz crystal & it generates an electric field
Apply an electric field and it bends
Page 5
Atomic clocks
Second is defined as 9,192,631,770 periods of
radiation corresponding to the transition
between two hyperfine levels of cesium-133
Accuracy:
better than 1 second in six million years
NIST standard since 1960
Page 6
UTC
UT0
Mean solar time on Greenwich meridian
Obtained from astronomical observation
UT1
UT0 corrected for polar motion
UT2
UT1 corrected for seasonal variations in Earths
rotation
UTC
Civil time measured on an atomic time scale
Page 7
UTC
Coordinated Universal Time
Temps Universel Coordonn
Kept within 0.9 seconds of UT1
Atomic clocks cannot keep mean time
Mean time is a measure of Earths rotation
Page 8
Page 9
Problem
Getting two systems to agree on time
Two clocks hardly ever agree
Quartz oscillators oscillate at slightly different
frequencies
Page 10
8:00:00
8:00:00
Sept 18, 2006
8:00:00
Page 11
8:01:24
Skew = +84 seconds
+84 seconds/35 days
Drift = +2.4 sec/day
8:01:48
Oct 23, 2006
8:00:00
Page 12
Computers time, C
Perfect clock
UTC time, t
Page 13
Computers time, C
skew
UTC time, t
Page 14
Computers time, C
skew
UTC time, t
Page 15
Page 16
If slow:
Make clock run faster until it synchronizes
Page 17
Page 18
Computers time, C
Clock synchronized
skew
Linear compensating
function applied
UTC time, t
Page 19
Computers time, C
UTC time, t
Page 20
Resynchronizing
After synchronization period is reached
Resynchronize periodically
Successive application of a second linear
compensating function can bring us closer to true
slope
Page 21
Page 22
Time server
Page 23
RPC
Simplest synchronization technique
Issue RPC to obtain time
Set time
client
server
3:42:19
Cristians algorithm
Compensate for delays
Note times:
request sent: T0
reply received: T1
Tserver
server
request
client
T0
reply
T1
time
Page 25
Cristians algorithm
Client sets time to:
server
request
client
T0
Tserver
reply
T1
time
= estimated overhead
in each direction
Page 26
Error bounds
If minimum message transit time (Tmin) is known:
Place bounds on accuracy of result
Page 27
Error bounds
Tserver
server
request
client
T0
Tmin
Earliest time
message arrives
reply
Tmin
T1
time
Latest time
message leaves
range = T1-T0-2Tmin
accuracy of result =
Page 28
Page 29
Tserver
server
request
client
T0 = 5:08:15.100
T1 = 5:08:15.900
Ts = 5:09:25:300
Tmin = 200msec
T0
reply
200
200
T1
time
800
Error =
Page 30
Berkeley Algorithm
Gusella & Zatti, 1989
Assumes no machine has an accurate time
source
Obtains average from participating computers
Synchronizes all clocks to average
Page 31
Berkeley Algorithm
Machines run time dmon
Process that implements protocol
Page 32
Berkeley Algorithm
Master polls each machine periodically
Ask each machine for time
Page 33
Berkeley Algorithm
Algorithm has provisions for ignoring readings
from clocks whose skew is too great
Compute a fault-tolerant average
If master fails
Any slave can take over
Page 34
3:25
2:50
9:10
Page 35
3:25
2:50
9:10
Page 36
+0.15
+0:15
3:25
2:50
9:10
Page 37
Page 38
NTP Goals
Enable clients across Internet to be accurately
synchronized to UTC despite message delays
Use statistical techniques to filter data and gauge quality of
results
Page 39
NTP servers
Arranged in strata
1st stratum: machines
connected directly to
accurate time source
2nd stratum: machines
synchronized from 1st
stratum machines
1
2
3
4
SYNCHRONIZATION SUBNET
Page 40
Symmetric mode
Intended for master servers
Pair of servers exchange messages and retain data
to improve synchronization over time
NTP messages
Procedure call and symmetric mode
Messages exchanged in pairs
NTP calculates:
Offset for each pair of messages
Delay
Filter Dispersion
Page 42
Version number
Mode (symmetric, unicast, broadcast)
Stratum (1=primary reference, 2-15)
Poll interval
Maximum interval between 2 successive messages,
nearest power of 2
Page 43
Root dispersion
Reference clock ID
Reference timestamp
Page 44
Page 45
Page 46
SNTP
Simple Network Time Protocol
Page 47
SNTP
T2
server
request
client
T1
Roundtrip delay:
T3
reply
T4
time
Time offset:
d = (T4-T1) - (T2-T3)
Page 48
SNTP example
T2=800
server
request
client
T1=1100
T3=850
reply
time
T4=1200
Offset =
((800 - 1100) + (850 - 1200))/2
=((-300) + (-350))/2
Time offset:
= -650/2 = -325
Set time to T4 + t
= 1200 - 325 = 875
Page 49
Cristians algorithm
T2=800
server
request
client
Ts=825
T1=1100
T3=850
reply
time
T4=1200
Page 50
Page 51
The end.
Page 52