Clock Synchronization. Ronilda Lacson, MD, SM. Introduction. Accurate reliable time is necessary for financial and legal transactions, transportation and distribution systems and many other applications involving distributed resources
Ronilda Lacson, MD, SM
Clock synchronization requires processes to bring their clocks close together by using communication between them
For every algorithm that achieves -synchronized clocks, is at least (1-1/n) where is the uncertainty in the message delay
Code for process pi
Send HCi to all qp
if u=message V from process q then
DIFF := V + - HCi
SUM := SUM + DIFF
RESPONSES := RESPONSES + 1
if RESPONSES = n-1 then exit
adji := adji + SUM/n
Dpq = estimated difference between the physical clocks of p and q as estimated by q
pq = the actual difference between the physical clocks of p and q
Show |ACp(t)-ACq(t)| (1-1/n)
= |(HCp(t) + adjp) – (HCq(t) + adjq)|
= (1/n)|((rq - rp) – (Drq – Drp))|
(1/n) |((rq - rp) – (Drq – Drp))|
(1/n) (2/2 + (n-2)) = (1-1/n)
= |Cp(t) + - Cq(t’) - pq|
= |Cq(t) + pq + - Cq(t’) - pq|
= | + Cq(t) - Cq(t’)|
= | - (t’-t)|
Since - /2 (t’-t) + /2
HCq(t)- ACp(t) HCr(t)+
(1+)-1(t2-t1) HCi(t2) – HCi(t1) (1+)(t2-t1)
|ACi(t) – ACj(t)|
(1+)-1(HCi(t)–HCi(0) ) ACi(t) – ACi(0) (1+)(HCi(t)–HCi(0))
There is no algorithm that satisfies clock agreement and clock validity if n 3f.
Each process reads the value of every process’s clock and sets its own clock to the average of these values – except that if it reads a clock value differing from its own by more than , then it replaces that value by its own clock’s value when forming the average.
qp = qp if |qp|, 0 otherwise
Є = maximum error in reading the clock difference qp
= maximum error in the rates at which the clocks run
R = length of time between resynchronizations
f = number of faulty processes
= (6f+2) є + (3f+1)R
= maximum difference between 2 non-faulty clocks
= degree of synchronization maintained by this algorithm
Let p andq be 2 non-faulty processes. If another process r is non-faulty, cpr=cqr, where cpr and cqr are the values used by processes p and q for r’s clock when computing the average. If r is faulty, then cpr and cqr will differ by at most 3. cpr lies within of p’s value, cqr lies within of q’s value, and p and q lie within of each other. Thus, the averages computed by p and q will differ by at most 3(f)/n. Since n>3f, this value is less than . With repeated synchronizations, it appears that each one brings the clocks closer by a factor of 3f/n.
Instead of taking an average, this algorithm takes the median of all process’s clock values. The median will be approximately the same if the 2 conditions below hold:
If majority of the processes are non-faulty, this median would be approximately equal to the value of a good clock.
Process r sends its value to every other process, which in turn relays the value to the 2 remaining processes. Each process receives 3 copies of this value. The value obtained by a process is the median of these 3 copies.
Modify OM(f) into COM(f) similar to the way we modified OM(1) into COM(1).
This has the same assumptions as Algorithm CON. However, Algorithm COM keeps the clocks synchronized to within approximately (6f+4)є + R. In contrast, CON has =(6f+2)є + (3f+1)R If the degree of synchronization is much larger than 6mє, then it is necessary to synchronize 3f+1 times as often with algorithm CON than COM.