Clocks and Time

In Distributed Systems, time is important for purposes including time stamping in transactions and synchronization in algorithms.

Clock Skew and Drift Rate

Each process has an internal clock. Clocks between processes on different computers differ.

Synchronization

External Synchronization: Synchronize time with an authoritative clock, when accurate timestamps are required

Internal Synchronization: Synchronize time internally between all processes in a distributed system, when internally comparable timestamps are required

If all clocks in a system are externally synchronized, they are also internally synchronized.
Clocks that are internally synchronized are not necessarily externally synchronized (since they may drift collectively from an external source of time).

If all clocks in a system are externally synchronized within a bound of D, the bound on their skew relative to one another is 2D.

Synchronization in Synchronous Systems

What time Tc should client adjust its local clock to after receiving ms ?

Pasted image 20230125142728.png|300
Let max and min be maximum and minimum network delay.

Synchronization in Asynchronous Systems

What time Tc should client adjust its local clock to after receiving ms ?

Cristian Algorithm

The use of a time server, connected to a device that receives signals from a source of UTC, to synchronize computers externally. Upon request, the server process S supplies the time according to its clock.

Improve accuracy by sending multiple spaced requests and using response with smallest Tround.

Handling Failure:

Handling Faulty Processes:

Berkeley Algorithm

Only supports Internal #Synchronization. An coordinator computer is chosen as leader

  1. Server periodically polls clients "what time do you think it is?"
  2. Each client responds with its local time
  3. Server uses #Cristian Algorithm to estimate local time at each client
  4. Average all local times (including its own) -- use as updated time
  5. Send the offset (amount by which each clock needs adjustment)

Pasted image 20230128135807.png|180 Pasted image 20230128135836.png|180

Handling Faulty Processes:

Handling Server Failure:

Network Time Protocol

NTP defines an architecture for time service over the Internet for synchronizing to UTC, it has:

The structure:

  1. Primary servers are connected directly to a time source such as a radio clock receiving UTC
  2. Secondary servers are synchronized with primary servers, third with second, etc.
  3. Each level is a strata
  4. The leaf servers execute in users' workstations

Pasted image 20230128140950.png|300

Ways that NTP servers synchronize with one another:

  1. Servers multicast timestamps within a LAN, clients adjust time assuming a small delay
    (Low accuracy)
  2. Procedure Call (#Cristian Algorithm)
    (Higher accuracy)
  3. Symmetric Mode used to synchronize lower strata servers
    (Highest accuracy)

Symmetric Mode

Takes into consideration of non-consecutive messages.

Suppose:

We want to estimate:

Pasted image 20230128141418.png|350

We have:

Assuming symmetric t and t: