











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
A set of lecture notes from a university course on distributed systems, focusing on the topics of time and synchronization. It covers concepts such as processes and events, physical clocks and synchronization, synchronizing physical clocks, and clock synchronization using a time server. It also introduces algorithms like cristian's algorithm and the berkeley algorithm, and discusses the network time protocol (ntp).
Typology: Study notes
1 / 19
This page cannot be seen from the preview
Don't miss anything!












♣ (^) Uses a time server to synchronize clocks
♣ (^) Time server keeps the reference time
♣ (^) Clients ask the time server for time & adjust their
clock, based on the response
For links with symmetrical latency:
adjusted-local-time = server-timestamp + (RTT / 2) or = server- timestamp + (RTT – server-latency) /2 local-clock-error = adjusted- local-time – local-time
RTT = response-received-time – request-sent-time
♣ (^) For positive clock errors, clock is advanced forward
accordingly. For negative clock errors, the clock
should be slowed down, not immediately adjusted.
♣For unusually long RTTs, repeat the time request
♣ (^) For non uniform RTTs, use adaptive, weighted average
avg-clock-error 0 = local-clock-error
avg-clock-errorn = (Wn * local-clock-error) +
(1 – Wn) * local-clock-errorn-
♣ (^) Uses a designated server to synchronize
♣The designated server pools or broadcasts
to all machines for their time, adjusts times received for
RTT & latency, averages times, and tells each machine
how to adjust.
♣In some systems multiple time servers are used.
♣Avg. time is more accurate, but still drifts
Ti
Ti 2 Ti 1
Ti 3
Server B
Server A
Time
m m'
Time
Each message bears timestamps of recent message events: the local time when the previous NTP message was sent and received, and the local time when the current message was transmitted.
Ti
Ti 2 Ti 1
Ti 3
Server B
Server A
Time
m m'
Time
- oi : estimate of the actual offset between the two clocks - o : true offset of the clock at B relative to that at A - t and t’: actual transmission times for m and m’ - di : total transmission times for^ m and m’ ; d=t+t’
p 1
p 2
p 3
a b
c d
e f
m (^1)
m (^2)
Physical time
a (^) b
c d
e f
m (^1)
m (^2)
1 2
3 4
1 5
p 1
p 2
p 3
Physical time
e precedes f ⇒ timestamp(e) < timestamp (f), but timestamp(e) < timestamp (f) ~ ⇒ e precedes f
(^) All hosts use a vector of counters (logical clocks), ith^ element is the clock value for host i, initially all zero. (^) Each host i, increments the ith^ element of its vector upon an event, and assigns the vector to the event. (^) A send(message) event carries its vector timestamp (counter vector) (^) For a receive(message) event,
Max(Vreceiver[j] , Vmessag[j]), if j is not self Vreceiver[j] = Vreceiver[j] + 1 otherwise
a (^) b
c d
e f
m (^1)
m (^2)
(1,0,0) (2,0,0)
(2,1,0) (2,2,0)
(0,0,1) (2,2,2)
p 1
p 2
p 3
Physical time
(^) VT 1 = VT 2 ,
iff VT 1 [i] = VT 2 [i], i = 1, … , n
VT 1 < VT 2 ,
iff VT 1 [i] < VT 2 [i], i = 1, … , n
(^) VT 1 < VT 2 ,
iff VT 1 < VT 2 &
∃ j (1 < j < n & VT 1 [j] < VT 2 [j])
iff not (VT 1 < VT 2 OR VT 2 < VT 1 )