There is a huge need in measuring time in distributed systems: schedulers, timeouts, failure detectors, log files and many other purposes. There are two types of clock: physical and logical.
Physical clocks are usually represented as a physical device that can produce signals at a purely constant rate. Examples of such devices are oscillators build with quartz (wide-range use) or cesium-133 atom (private atomic clocks).
If one clock runs slightly fast or slightly slow, it is said to drift. Drift measured in parts per million (ppm) = $1$ mcsec/sec = $86$ ms/day = $32$ s/year. Most computer clocks correct withing $\approx50$ ppm.
Since quartz clocks are not as much accurate, they need to be synchronized to provide a consistent time.
A common approach in many protocols and originally proposed by Cristian (Cristian’s Algorithm), is to let clients contact a time server and compute the time offset as following:
$$ \delta = \frac{(T_4-T_1)-(T_3-T_2)}{2} $$
$$ \theta=T_3+\frac{\delta}{2} $$
Another suitable algorithm is Berkeley algorithm. In opposite to previous algorithm, this one assumes a client to be passive. Server periodically request a current time from machines, computes the mean and sends a command to slow/accelerate clocks for a number of ticks.
The most widely used protocol for time synchronization is NTP (Network Time Protocol). It enables clients to be accurately synchronized to UTC despite message delays.
Servers and time sources are arrange in layers (strata):