Clock Fundamentals
- Real-time clock (RTC)
- Battery-powered CMOS chip with quartz oscillator that keeps time when computer is powered off, providing approximate time on boot.
- System clock
- Software clock maintained by the operating system using interval timers, more accurate than RTC during system operation.
- Epoch
- The fixed reference point from which elapsed time is measured; Unix uses January 1, 1970, 00:00:00 UTC, while Windows uses January 1, 1601, 00:00:00 UTC.
- Unix epoch
- The reference point for Unix timestamps, defined as January 1, 1970, 00:00:00 UTC.
- Coordinated Universal Time (UTC)
- The primary time standard based on International Atomic Time with occasional leap seconds added to account for Earth’s irregular rotation.
- Leap second
- An occasional one-second adjustment to UTC to keep it aligned with Earth’s rotation, announced months in advance.
- Wall clock
- The system clock representing current date and time that clock synchronization protocols adjust; can jump forward or backward due to NTP corrections, manual adjustments, or DST transitions.
- Monotonic clock
- A clock that always moves forward, unaffected by wall clock adjustments, used for measuring durations and timeouts.
- Elapsed seconds representation
- Representing time as the number of seconds (and fractions) since a fixed epoch, avoiding timezone, DST, and leap second complications.
Clock Properties and Measurements
- Clock model
- Mathematical representation \(C(t) = \alpha t + \beta\) where \(C(t)\) is clock reading at true time \(t\), \(\alpha\) is clock rate (rate error from drift), and \(\beta\) is offset from true time.
- Clock rate (\(\alpha\))
- The multiplicative factor in the clock model representing how fast or slow a clock runs; ideally 1.0, but drift causes deviation (rate error).
- Clock offset (\(\beta\))
- The additive factor in the clock model representing how far ahead or behind a clock is from true time (the instantaneous time difference).
- Accuracy
- How close a clock measurement is to the true value; if a clock shows 12:00:00.005 and true UTC is 12:00:00.000, the clock has 5ms of error.
- Precision
- The consistency of repeated measurements; a clock consistently 5ms fast is precise but not accurate.
- Resolution
- The shortest time increment a clock can represent; a nanosecond-resolution clock can distinguish events 1 nanosecond apart, independent of accuracy.
- Clock drift
- The rate at which a clock’s frequency deviates from its nominal frequency, typically measured in parts per million (ppm).
- Clock offset
- The instantaneous difference in time between two clocks or between a clock and true time.
- Parts per million (ppm)
- A measure of clock drift representing the fractional frequency error; 100 ppm means 100 microseconds error per second.
- Quartz oscillator
- A piezoelectric crystal that vibrates at a precise frequency when voltage is applied, used as the timekeeping element in computer clocks.
- Temperature-Compensated Crystal Oscillator (TCXO)
- A quartz oscillator with circuitry to compensate for temperature-induced frequency variations, achieving 1-5 ppm drift.
- Oven-Controlled Crystal Oscillator (OCXO)
- A quartz oscillator maintained at constant temperature in a miniature oven, achieving drift below 0.01 ppm.
Clock Adjustment Mechanisms
- Slewing
- Gradually adjusting a clock by changing its rate, making each tick slightly longer or shorter to correct offset while maintaining monotonic behavior.
- Stepping
- Instantly jumping a clock to the correct time, used for large offsets but can break applications measuring durations.
- Periodic resynchronization
- Regular synchronization measurements needed because drift rate changes with temperature and aging.
Synchronization Algorithms
- Cristian’s algorithm
- A client-server clock synchronization algorithm that estimates network delay using round-trip time and adjusts the client clock based on the server’s timestamp plus estimated one-way delay.
- Round-trip time (RTT)
- The total time for a message to travel from sender to receiver and back, used in synchronization algorithms to estimate network delay.
- Network Time Protocol (NTP)
- A hierarchical protocol for synchronizing clocks over networks using stratified time servers and sophisticated filtering algorithms.
- Stratum
- In NTP, the hierarchical level of a time server representing its distance from authoritative time sources (stratum 0 is direct reference, stratum 1 synchronizes from stratum 0, etc.).
- Clock discipline
- The algorithm used to gradually adjust a system clock toward a reference time by modifying tick frequency rather than making discontinuous jumps.
- Simple Network Time Protocol (SNTP)
- A simplified subset of NTP suitable for client devices that synchronize time but do not serve time to other systems.
- Precision Time Protocol (PTP)
- IEEE 1588 standard for sub-microsecond clock synchronization in LANs using hardware timestamping in network interface cards.
- Hardware timestamping
- Capturing packet transmission and receipt timestamps at the network physical layer in specialized hardware, bypassing software stack delays to achieve nanosecond-level timing accuracy.
- Grandmaster clock
- The authoritative time source in a PTP domain from which all other clocks synchronize.
- Best Master Clock Algorithm (BMCA)
- The PTP algorithm that selects the most suitable grandmaster based on priority, clock quality, accuracy, and stability.
Network and Error Concepts
- Symmetric delay assumption
- The assumption that network transmission time is equal in both directions, which simplifies synchronization but may not hold in real networks.
- Error bounds
- Mathematical limits on synchronization error computed from minimum network transmission time and measured RTT.
- Additive errors
- The accumulation of synchronization errors in chains where machine A synchronizes from B which synchronized from C, requiring hierarchy depth limits.
- Fault-tolerant averaging
- Technique of querying multiple time sources, discarding outliers, and averaging the remaining values to reduce impact of faulty clocks.
- Jitter
- Variation in network latency that makes message transmission times unpredictable, affecting the accuracy of clock synchronization.
- Asymmetric delay
- Network condition where transmission times differ significantly in forward and reverse directions, introducing error in clock synchronization algorithms.
- Clock synchronization uncertainty
- The maximum possible error in synchronized time, determined by network jitter, asymmetric delays, and algorithm limitations.
- Outlier rejection
- Statistical filtering technique used in NTP and fault-tolerant averaging to discard time samples from faulty or unreliable sources before computing adjustments.
Logical Clocks
- Happened-before relationship
- Lamport’s partial ordering (\(\rightarrow\)) on events where \(a \rightarrow b\) if they occur on the same process in sequence, if a sends a message received at b, or transitively through these relationships.
- Concurrent events
- Events where neither happened-before nor happened-after relationship exists, meaning neither could have causally influenced the other through system communication.
- Causality
- The potential for one event to influence another through the system’s communication channels, captured by the happened-before relationship.
- Lamport timestamp
- A logical clock that assigns integer timestamps to events such that if event a happened-before event b, then timestamp(a) < timestamp(b).
- Logical clock
- A mechanism for ordering events in a distributed system based on causality rather than physical time, using counters that increment with events and message exchanges.
- Total ordering
- An ordering that provides a definite sequence for all events, achieved by combining Lamport timestamps with process IDs to break ties.
- Vector clock
- A logical clock where each process maintains a vector of counters (one per process) that fully captures causal relationships and enables detection of concurrent events.
- Causal ordering
- An ordering of events that respects the happened-before relationship, ensuring causally related events are ordered correctly.
- Version vector
- A variant of vector clocks that tracks versions of data objects rather than process events, used in systems like Dynamo and Riak.
- Matrix clock
- A logical clock using a two-dimensional array where each process tracks its knowledge of all other processes’ logical times, enabling garbage collection through knowledge of global progress.
- Hybrid Logical Clock (HLC)
- A timestamp combining physical time and logical components that preserves causal ordering while maintaining closeness to wall-clock time for time-based queries.
- Partial ordering
- An ordering relation (like happened-before) that does not necessarily order all pairs of elements, only those with a causal relationship.