Time Synchronization - PowerPoint PPT Presentation

1 / 28
About This Presentation
Title:

Time Synchronization

Description:

Sequential processes have pre-defined precedence relationships ... The occur times of events needs to follow the specified precedence relationship. ... – PowerPoint PPT presentation

Number of Views:33
Avg rating:3.0/5.0
Slides: 29
Provided by: CIT788
Category:

less

Transcript and Presenter's Notes

Title: Time Synchronization


1
Time Synchronization
  • Process and Time Synchronization
  • Regulation of Local Clock
  • Global Clock Synchronization
  • Clock Synchronization Algorithms

2
Process and Timing Synchronization
  • Distributed systems gt cooperative processes
    connected by a network
  • Applications
  • A task may consist of multiple events (as
    specified in program logics) to be performed by
    multiple processes (or sample process) in a
    predefined sequence (ordered)
  • Execution of a process gt serving an event
  • Some events can be executed concurrently and some
    may be performed sequentially gt concurrent
    processes and sequential processes
  • Sequential processes have pre-defined precedence
    relationships
  • Step 1 input x step 2 input y step 3 z x
    3y
  • Can step 1 performs before step 2?
  • Note in here, we use the term process which can
    be implemented as a process or a thread

3
Process and Timing Synchronization
  • Process state gt the current status of the
    process (i.e., active or blocked, program counter
    value) together with the values of its accessed
    variables
  • An event transforms a process from state S to
    state S
  • State transition State(active) gt State(wait)
  • I.e., The event of sending a message by process P
    changes the state of P from Not yet send to
    sent
  • Definition e -gt e event e is occurred before
    event e (precedence relationship)
  • When all the events have completed, it is
    expected that the system arrives the expected
    (correct) state gt output
  • History the history of a process Pi is a series
    of events that have happened within it until the
    current time
  • History(Pi) hi lt ei,1, ei,2, , gt
  • How to order the events in a distributed
    environment to ensure that the events occurred
    (served) following the requirements of the
    application/specifications?
  • (1) based on the process state gt require IPC
  • (2) based on the real time (i.e., current time)gt
    require a global time (time synchronization)

4
Process Synchronization
Different sub-processes may be processed at
different sites The results from a sub-process
may need to return to its parents The sub-process
may be coordinated in processing
T1
T1,1
Precedence relationship
5
Process and Timing Synchronization
  • Local clock and global clock
  • Lack of a global clock in a distributed system
    although each computer has its own local clock
  • Ordering of events at a single site gt by a local
    clock
  • The local clock can also be used to time-stamp
    the occur/finish time of an event
  • How to order events occurring in different
    processes?
  • Process P1 sends a variable v1 message to Process
    P2 and asks P2 add its value v2 to v1, and then
    return the new value after 5 sec of the
    transmission from P1
  • So, at which the time P2 should return the
    updated value of v1 to P1?
  • The local clock of P1 and P2 may be different
  • The communication delay is totally unpredictable
  • Clock synchronization gt agree to the same
    absolute time
  • In addition, process management also requires an
    accurate global clock
  • I.e., concurrency control based on timestamp
    ordering
  • Real-time events need to respond to the real
    world event at a specific time. I.e., Once an
    intruder is detected, an action needs to be
    generated within 5 sec

6
Events and Timing
  • Relative time Vs. absolute time
  • Relative time mainly for event ordering. The
    occur times of events needs to follow the
    specified precedence relationship. I.e., One
    event has to be started only after the finish of
    another event
  • Get a Get b Calculate c a b
  • Absolute time an event has to be
    started/finished after/before a specific agreed
    global time. I.e., when you press the return
    key, a result needs to be generated within 5 sec
  • I.e., in a real-time system, the computer system
    is responding to real-time events (responsive).
    The start time and completion time of a task need
    to follow the real-time constraints of the
    requirements of the real world events
  • It could be a relative time constraint, i.e.,
    generate a response after 5 sec of finishing a
    the previous task
  • It could be an absolute time constraint, i.e.,
    generate a result on position of an air-craft
    every 5 sec
  • What will be the consequence of failing to meet
    the timing requirement of a real-time process???

7
Sources of Accurate Timing Signals
  • How to determine and meet the ordering
    requirements???
  • We (not just computers) need a highly accurate
    (reliable) global clock for references and
    coordination
  • International Atomic Time (TAI) is based on very
    accurate physical clocks (drift rate 10-13)
    (highly accurate quartz clock is 10-8)
  • What is draft rate? Clocks are normally not
    advanced in a constant speed
  • No perfect clock gt only a more accurate clock
  • Coordinated Universal Time (UTC) is an
    international standard for time keeping
  • How to define a second?
  • One year gt 365 x 24 x 3600sec
  • One day gt 24 x 3600 sec
  • It is broadcast from radio stations on land and
    satellite (e.g. GPS)
  • Computers with receivers can synchronize their
    clocks with these timing signals
  • Signals from land-based stations are accurate to
    about 0.1-10 millisecond (errors in estimating
    the delay in transmission)
  • Signals from GPS are accurate to about 1
    microsecond

8
Definition of Time
Fr. Tanenbaum
Computation of the mean solar day the interval
between two consecutive transits of the sun
(highest point in the sky) is called the solar day
9
Physical Clock
Fr. Tanenbaum
Solar second vs. TAI second
TAI seconds are of constant length, unlike solar
seconds. Leap seconds are introduced when
necessary to keep in phase with the sun.
10
Regulation of Local Clock
  • Each computer has a hardware clock Hi(t)
  • A computer timer is a precise quartz crystal that
    oscillates at a fixed frequency (i.e., n
    oscillations one TAI sec)
  • Timer generates a clock tick (an interrupt) after
    a fixed number of oscillates
  • Note the time interval between successive events
    must be larger than the clock resolution (the
    period of clock tick)
  • For process pi
  • Ci(t) software clock (local clock)
  • Hi(t) hardware clock, I.e., the time given by
    hardware clock
  • Ci(t) ?H(t) ? (a conversion of the hardware
    clock)
  • In real cases, Ci(t) cannot be the same as t (TAI
    value) all the times due to clock drift
    (imperfect)
  • Clock drift different clocks count time at a
    slightly different way (the oscillation is not
    perfect
  • It is common to define a hardware clock H to be
    correct if its drifts fall within a known bound ?
    gt 0 (e.g. for real-time t and t, tgtt)
  • (1- ? )(t-t) H(t) H(t) (1? )(t-t)
  • Monotonicity t gt t gt C(t) gt C(t)

11
Regulation of Local Clock
What is wrong with the figure?
The clock rate may not be a constant
Fr. Tanenbaum
The relation between clock time and UTC when
clocks tick at different rates.
12
Clock Synchronization
  • Clock synchronization to synchronize the clocks
    at different computers to agree at the same
    (similar) reading (i.e., close to the UTC time)
  • How to synchronize your watches?
  • Difficulties in clock synchronization in a
    distributed environment
  • Not all sites have direct access to accurate time
    source such as a GPS receivers due to the cost
  • Sites has to synchronize their local clocks with
    those have more accurate time (a common reference
    clock)
  • How to determine which one is more accurate?
    Where?
  • Synchronization needs to be done periodically due
    to clock drift rate is change in the offset
    (difference in readings) between the clock and a
    normal perfect reference clock per unit of time
    measured (about 10-6 or 1 sec. in 11.6 days)
  • How to determine the synchronization period?
    Based on the value of ?
  • If a sites clock is ahead of the reference (time
    server) to which it synchronizes to, it cannot
    be simply set back (why?)
  • This may have the effect that an event that has
    happened but its time-stamp is in the future
  • Slow it down until it reaches the desire value
    (UTC value)

13
Skew between Computer Clocks in a Distributed
System
Reliable clock
Periodically broadcast clock readings
Fr. Dollimore
Different clocks may have different oscillate
periods and advancement rate. This rate also
change slightly with the environmental conditions
14
External Internal Clock Synchronization
  • External synchronization
  • A computers clock Ci is synchronized with an
    external authoritative time source S (a reliable
    source), so that
  • S(t) - Ci(t) lt D for i 1, 2, N over an
    interval, I of real time
  • The clocks Ci are accurate to within the bound D
  • Internal synchronization
  • The clocks of a pair (group) of computers are
    synchronized with other
  • Ci(t) - Cj(t) lt D for i 1, 2, N over an
    interval, I of real time
  • The clocks Ci and Cj agree within the bound D
  • Good for relative events synchronization (what?
    Relative clocks)
  • Internally synchronized clocks are not
    necessarily externally synchronized, as they may
    drift collectively (all are not accurate)
  • If the set of processes P is synchronized
    externally within a bound D, it is also
    internally synchronized within bound 2D ( D)
  • Synchronization problem estimation of the delay
    in communication
  • The delay is always quite vary in external
    synchronization (why?)
  • How about the case for internal synchronization?

15
Clock Synchronization Cristian Algorithm
  • No upper bound on message transmission delay but
    it has a lower bound
  • The Cristian algorithm for systems with short
    transmission delays
  • Client C requests time in Request message sent to
    time server S, then it receives time value t in
    message CUTC from S
  • S is connected to an accurate time reference
  • t is the current time in S before sending back
    CUTC to C
  • Let Ttrans be time taken for CUTC message from S
    to C, then C should set its time to t Ttrans
  • Ttrans can be variant. You may say Ttrans
    minx, x 0 and min time of message
    transmission if no interference of other process
    and no other messages, but x is unknown
  • Solution
  • (1) Record total round trip time as Tround
    (between sending Request and receiving CUTC,,
    i.e., T1-T0)
  • (2) If the time received the Request message is
    t, then C can estimate its time as t Tround/2
  • Counting multiple requests to get the average
  • What is the main assumption?

16
Clock synchronization using a time server
17
Cristian's Algorithm
t
t
Fr. Tanenbaum
  • Getting the current time from a time server

18
Clock Synchronization Cristian Algorithm
  • When C receives CUTC, Cs time is t Tround/2
  • Let the minimum transmission time be min, and min
    is known
  • Therefore, t (the time in S when C receives CUTC
    ) lies in the range tmin, tTround - min
  • t min the earliest time that S receives the
    request
  • t Tround min the latest time that S sends
    CUTC
  • Then, t Tround -min - (tmin) Tround - 2min
  • The accuracy for this time adjustment is
    ?(Tround/2 - min)
  • Problem single-server failure
  • Solution providing group synchronization time
    servers (tradeoffs?)

19
Clock Synchronization Berkeley Algorithm
  • Berkeley Algorithm for time (internal)
    synchronization
  • In Berkeley UNIX, one of a group sites
    (computers) is chosen as coordinator, (master or
    time server)
  • (1) The master (actually a time daemon in the
    master) periodically polls the other sites
    (slaves) to ask what time it is there, by telling
    its own time (the time in master) to these slaves
  • (2) The slaves response with how far ahead or
    behind the time daemon they are, that is, the
    difference between its time and the time in
    master
  • (3) Based on the replies from the slaves, the
    master averages the time obtained (including its
    own)
  • (4) The master sends time rate adjust value ( or
    -) to slaves, requesting them to adjust their
    time rate
  • Question How does the Cristians algorithm be
    applied to the above Berkeley algorithm?
  • How about if the master is failed? Find another
    master? How?

20
The Berkeley Algorithm An Example
Fr. Tanenbaum
  • The time daemon asks all the other machines for
    their clock values
  • The machines answer
  • The time daemon tells everyone how to adjust
    their clock

21
Clock Synchronization Network Time Protocol
(NTP)
  • NTP is used in the Internet (a widely distributed
    system with great variability in communication
    delays)
  • Why do we need NTP instead of using the Cristian
    algorithm? Can the Cristian algorithm be applied
    for the Internet?
  • A statistical techniques for filtering timing
    data with adaptation to connection
  • Time servers are arranged in levels called
    strata. NTP intends to
  • Provide a service enabling clients in Internet to
    be synchronized accurately to UTC
  • Provide reliable service to losses of
    connectivity
  • enable clients to resynchronize sufficiently and
    frequently
  • Provide protection against interference with the
    time service

22
Clock Synchronization Network Time Protocol
  • Synchronization clock Network Time Protocol
    (NTP)
  • Stratum 1 Primary server (PS) sync directly with
    UTC sources.
  • Stratum 2 Secondary servers (SS) sync directly
    to PS.
  • Stratum 3 Lowest servers (LS) execute in user
    sites sync with SS.
  • Accuracy the number of levels (strata)

Less accurate
23
Clock Synchronization Network Time Protocol
  • Multiple servers provide for redundancies and
    hence availability of time sources and
    fault-tolerance
  • NTP synchronizes with one another in one of three
    modes
  • Multicast Used on LAN. One or more servers
    periodically broadcast the time to servers
    running in workstations which set their clocks
    assuming a small delay. Accuracy is low
  • Procedure-call Similar to Cristians method.
    Workstations ask the server the time. Accuracy is
    higher than multicast
  • Symmetric mode Used by high level to achieve
    highest accuracy. A pair of servers exchange
    messages bearing timing information

24
Clock Synchronization Network Time Protocol
  • Messages are delivered unreliably using UDP (why
    not TCP?)
  • Each message bears the timestamps of recent NTP
    messages
  • The local time when the previous NTP message
    between the pair was sent and received
  • The local time when the current message was sent
  • For each pair of messages sent, calculate an
    offset oi to estimate the actual offset o between
    the two clocks, and a delay di the total
    transmission delay of the two messages
  • What is the difference between o and oi?
  • o tb - ta, where tb is the time at server B
    when ta is the time at server A
  • Taking the communication delay
  • Ti-2 Ti-3 t o and Ti Ti-1 t o
  • The total communication delay
  • di t t Ti-2 - Ti-3 Ti - Ti-1

25
Clock Synchronization Network Time Protocol
  • The estimated offset oi
  • Since oi is to estimate tb - ta, oi ((Ti-2 -
    Ti-3) - t (Ti-1 - Ti) t)/2
  • oi (Ti-2 - Ti-3 Ti-1 - Ti) /2 assuming that t
    is similar to t
  • o Ti-2 - Ti-3 - t
  • o Ti-1 - Ti t
  • Thus, o (Ti-2 - Ti-3 - t Ti-1 - Ti t) / 2
    (Ti-2 - Ti-3 Ti-1 - Ti t - t ) / 2
  • o oi (t t) /2
  • Since t, t gt 0, oi - di/2 lt o lt oi di/2
    (case 1 t 0, case 2 t 0)
  • Thus, oi is an estimate of the offset while di is
    the accuracy of the estimate
  • We can associate a pair lt oi, digt for each
    connection
  • Apply a data filtering algorithm to successive
    pairs lt oi, digt of to estimate the offset o and
    calculates the quality of this estimate called
    filter dispersion

26
Messages exchanged between a pair of NTP peers
t
t
27
Clock Synchronization Network Time Protocol
  • A relatively high dispersion of successive pairs
    represents relatively unreliable data. A
    reconfiguration may be needed
  • The eight most recent pair lt oi, digt are
    retained. The value oj that corresponding to the
    minimum value dj is chosen to estimate o

28
References
  • Dollimore ch 11.1 to 11.3
  • Tanenbaum ch 5.1
Write a Comment
User Comments (0)
About PowerShow.com