# Clocks

Sometimes an exact time is needed, not just an order.

**UTC: Universal Coordinated Times**

* Based on the number of transitions of an atom of cesium 133 in one second (atomic clock).
* Currently, the UTC value is the average between 50 atomic clocks from all around the globe.
* It introduces a *leap second* to compensate for the fact that days get increasingly longer.

UTC values are radio-broadcasted in short-wave and satellite.

* Satellites have a precision of about 5ms.

## Synchronization

### Precision

The objective is to keep the **drift between two clocks under a limit** *π*.

* *∀t,∀p,q : |Cp(t)−Cq(t)| ≤ π*
* *C(p)* is the calculated time value for the *p* machine at *t* UTC time instant.

### Exactness

The objective is to keep the **drift between the clock and the UTC time**.

* *∀t,∀p : |Cp(t)−t| ≤ α*

### Synchronization

* **Internal:** precise clocks.
* **External:** exact clocks.

## Clock Drift

Specifications of a clock:

* Maximum clock drift rate - **ρ**
* **F(t)** is the oscillation frequency of a hardware clock at a given **t** moment.
* **F** is the ideal clock (constant) frequency.

<figure><img src="https://2387753953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVneYw7epWOEEPKsfCf%2Fuploads%2FWVM9xOVdDURV58DJdyn7%2Fa.png?alt=media&#x26;token=77d5c01a-20ac-4f93-87b2-068e83f35df9" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2387753953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVneYw7epWOEEPKsfCf%2Fuploads%2FizIB6iKTFVGouUGMMm8Y%2Fa.png?alt=media&#x26;token=784e1287-33ef-4618-8d20-257ac3d88b1a" alt=""><figcaption></figcaption></figure>

<figure><img src="https://2387753953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVneYw7epWOEEPKsfCf%2Fuploads%2FrxuqunvrE8EbGcF1mxmD%2Fa.png?alt=media&#x26;token=a9c54418-dd9f-4973-88b0-2c8b3701e30b" alt=""><figcaption><p>Obtaining the time of a server (NTP)</p></figcaption></figure>

<figure><img src="https://2387753953-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F9sVneYw7epWOEEPKsfCf%2Fuploads%2FP4WaGtyftNefnt0yhPt1%2Fa.png?alt=media&#x26;token=b2154504-3005-41fe-b926-a4a3eeb45ae0" alt=""><figcaption><p>Offset</p></figcaption></figure>
