How NTP Works
Client A sends its time
T1 to server B
B replies with its times
T2, T3 and client's
original T1
A computes offset θ and
delay δ relative to B
NTP Daemon Architecture
NTP daemon implements peer
and poll processes for each
server
Peer process handles time
request replies and calculates
time offset and delay
Poll process periodically sends
time requests based on network
conditions
Offset and delay values are
saved per association and
groomed by clock filter
Timestamp Representation
NTP uses 64-bit short format
and
128-bit
long
format
timestamps
Short format has 32 bits for
whole seconds since 1900 and
32 bits for fraction of second
Long format has 64 bits for
seconds and 64 bits for fraction
- extremely high precision
Short format mapped from bits
32-63 of long format. Can
represent unambiguous years
1900-2036
Long format can represent
dates from the dawn of the
universe to the far future
Computations use differences
between
timestamps
to
preserve precision
Reckoning Time
Basic NTP time reckoning:
Offset and delay values filtered
and processed by:
Selection algorithm
discards falsetickers
-
Clustering algorithm selects most accurate
candidates
Combining
averages
survivors
algorithm offsets
of
Result is best offset estimate
relative to server population
Clock Discipline
NTP adjusts system clock time
and frequency to minimize offset
Hardware clock ticks regularly
to advance software clock
But
clocks
have intrinsic
frequency
errors
and
temperature dependence
NTP
discipline
algorithm
corrects for these errors about
once per second
Can
reduce
errors
to
microseconds
with
kernel
timekeeping support
Association Modes
Client/server:
Client
stateless server
polls
Symmetric: Peers sync each
other
Broadcast: Server pushes time
to many clients
Each NTP host can operate in
any combination of modes
Modes determine time flow
direction and configuration
Highlights
NTP calculates offset/delay
relative
to
servers
with
timestamp exchanges
Short and long timestamp
formats represent time to high
precision
Engineered algorithms filter
noise to produce best offset
estimate
Clock discipline compensates
for intrinsic clock errors
Major modes define time flow
and configuration methods