Docsity

Time Synchronization in Distributed Systems: Clocks and Algorithms - Prof. Mehdi T. Harand, Study notes of Electrical and Electronics Engineering

Partial preview of the text

Download Time Synchronization in Distributed Systems: Clocks and Algorithms - Prof. Mehdi T. Harand and more Study notes Electrical and Electronics Engineering in PDF only on Docsity!

Lecture 2

time, clocks, and synchronization

distributed systems

CS425 / ECE 428 / CSE 424

acknowledgment

These slides are based on ideas and material from the following sources:

  • slides prepared by Professors M. T. Harandi and J. Hou and subsequently

modified by Professors Indranil Gupta, Nitin Vaidya, and Yih-Chun Hu at University of Illinois

  • slides from Professor S. Ghosh’s course at University of Iowa

plan for today

• sources of time

• how to synchronize clocks?

• can we define sequence of events without

using physical clocks?

time sources

  • primary standard = rotation of the earth
    • not a stable
  • de facto primary standard = International Atomic Time (TAI)
    • 1 atomic second = 9,192,631,770 orbital transitions of Cs^133
    • 86400 atomic seconds = 1 solar day – 3ms
  • Coordinated Universal Time (UTC) = international standard
    • derived from TAI by adding leap seconds to keep it close to solar time
    • UTC source signals are synchronized
    • UTC time is re-transmitted by GPS satellites (0.1-10 mS)
  • local clocks based on oscillators

definitions

  • skew:
    • s(t) = ci(t) – cj(t)
  • maximum drift rate ρ
    • |t – ci(t)|ρt
    • (1- ρ)tdci/dt(1+ρ)t
  • synchronization

interval R

  • |cj(t) – ci(t)|2 ρt
  • |cj(R) – ci(R)|2 ρRD
  • RD/ 2ρ
  • ignores propagation delays

real time

ρ for some real oscillators

PPM stability over

oscillator 0-70 C years

NCXO 5-100 1-

TCXO 0.1-5 0.1-

OCXO <0.001-1 0.02-

MCXO <0.05-2 0.02-

Source: http://www.isotemp.com/146-010.html

mr

mt pi Time server,S

external synchronization: Cristian’s

method

RTT = t 1 – t 2

 client sets its clock to T + RTT/

 assumptions:

 RTT measured accurately  transmission and computation delays are symmetric  server timestamped the message at the last possible instant before sending it back

external synchronization: Cristian’s method

t 1 t 2

Client pi

Server S

mr mt(T)

T

secondary servers, synched by the primary server

Primary server, direct synch.

Strata 3, synched by the secondary servers

 provides UTC synchronization service across the internet

 uses a network of time servers to synchronize all processes on a

network.

 time servers are connected by a synchronization subnet tree

 the root is adjusted directly

 each node synchronizes its children nodes.

1

2 2 2

3 3 3 3 3 3

Network Time Protocol (NTP)

messages exchanged between a pair of NTP

peers (connected servers)

Ti

Ti-2 Ti-

Ti- 3

Server B

Server A

Time

m m'

Time

each message bears timestamps of recent message events

  • local time when the previous NTP message was sent and received
  • local time when the current message was sent

summary

• several algorithms for internal and

external clock synchronization

• accuracy depends on uncertainty in

message delays

• we have not discussed failures

– there are algorithms for synchronization with

a fraction of failed clocks [e.g., Lamport,

Melliar-Smith algorithm]

• Next time: logical clocks

event ordering: logical clocks

happens-before relation on events

 define a relation on the events as follows

 on the same process: a b , iff time(a) < time(b)  if p 1 sends m to p 2 : send(m) receive(m)  (transitivity) if a b and b c then a c

 is called the Happens-Before relation

 events a and b are concurrent if not (a b or b a)

t 1 t 2 p 1

p 2

m m’

send(m)

recv(m) send(m’)

comp recv(m’)

real time

how to construct the happens

before relation in a distributed

system?

next time