The actual ordering matter, not the timestamp
Time Standards:
Universal Time (UT1, Greenwich Mean Time): astronomical observations
Temps Atomique International (TAI): radiation emitted by Cesium atom (diverged due to slowing earth rotation)
Temps Universal Coordonne (UTC): TAI + leap seconds (currently 27 leap seconds)
Cause of Imperfection
Skew: difference when time sync
Clock drift rate: quartz clocks drift 1 sec
in 7-11-12 days
.
Naive Synchronization:
Sender sends time T
(sending time) in a message
Receiver sets clock to T + D/2
(assuming transmission delay is bounded by D
)
Synchronization error is at most D/2
(but D
is not bounded itself)
Cristian's Time Sync:
The accuracy is \pm (RTT/2-\min) (where \min is an estimated minimum one way delay) because we can guarantee when the machine receive time from time server, the ground truth time is within range [t+\min, t+RTT-\min]. Suppose the minimum one way delay \min happens when message send from client to server, then the real-time when client received request is t + (RRT - \min) = t + (T_1 - T_0 - \min), but client's clock is set to t + \frac{T_1 - T_0}{2}. In this case, we overestimated the real-time by \frac{T_1 - T_0}{2} - \min. If the minimum one-way delay \min happens when the server replies back to the client, the real-time when the client received the request is t + \min. We underestimated the real-time by \frac{T_1 - T_0}{2} - \min.
Cristian's Time Sync only works if
RTT
(Round trip time) is short, since we need to have a low \min to bound the time. Centralized server might fail.
Berkeley Algorithm:
master can sync with UTC server (assume no RTT), not necessary
a group of servers are elected into 1 master and other slave servers.
master send its current time master
to all slaves.
slaves respond with time differences dx
s.
master receive 2 things: time difference, and calculated roundtrip time RTT
.
master average (median) the time difference and add RTT/2
, then broadcast the adjusted time to slaves.
Network Time Protocol (NTP): (using Cristian's one-way messages)
hierarchy of time servers
All messages use UDP
Each message is with
We don't care about actual time, we just need to know the event order. (Well, in fact, we don't have time, we have space-time)
Lamport Clock: using event order to sync clocks
observations
send
and receive
events is a timestampreceive
must happen after send
protocol
send
and receive
event, increment timestampEvent
e
happens beforee'
implies timestamp at evente
is smaller than timestamp at evente'
(e \to e') \implies L(e) < L(e') The converse is not true. L(e) < L(e') \;\not\!\!\!\implies (e \to e') Therefore, Lamport Clocks does not capture causality
We can break ties using process ID to give us a total order: L(e) = M * L_i(e) + i
Vector clock provides a total order, as contrast to Lamport Clock's partial order.
Vector Clocks:
each process initialize a vector who's length is the number of total processes n in the system (initialize to all zero)
process i only manage element i in vector (similar to lamport clock)
Time Synchronization is still active research field.
Hardware Support: [DTP, SIGCOMM 2016]
hop-hop synchronization
25.6 nanosecond accuracy (single hop)
Mostly Software: [HUYGENS, NSDI 2018]
NIC timestamp support
ML-based software filter
100 nanosecond accuracy
Clock Synchronization
rely on timestamp network messages
estimated delay for message transimission
can synchronize to UTC or local server source
clocks can never by exactly synchronized
not good for distributed system
Logical Clocks:
encode causality relationship
Lamport Clock: one-way encdoing
Vector Clocks: exact causality information
Table of Content