---
title: "Physical/logical clocks; NTP and Berkeley"
subject: "Distributed System"
chapter: 5
key: "semester_7/distributed_system:physical-logical-ntp-berkeley"
source: https://www.bctengineer.com/q/semester_7/distributed_system/physical-logical-ntp-berkeley
site: BCT Engineering
---

# Physical/logical clocks; NTP and Berkeley

Distributed System · Chapter 5: Time and State in Distributed Systems

- Asked in: 2070 Chaitra, 2+4+2 marks
- Video: [Network Time Protocol Physical Clock Synchronization Distributed Systems](https://www.youtube.com/watch?v=af9hZMiEe5U) — Simplified Computer Science Concepts-Prof. Rutuja
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_7/distributed_system/physical-logical-ntp-berkeley
- Whole chapter: https://www.bctengineer.com/md/semester_7/distributed_system/chapter-5

## Question

What do you mean by physical and logical clocks? Explain Network Time Protocol and Berkeley Algorithm for physical clock synchronization.

## Short answer

Physical clocks track real time and need synchronization; logical clocks are counters that only order events. NTP uses a stratum hierarchy and four timestamps to compute delay and offset, choosing the smallest-delay sample. Berkeley elects a master, averages all slave clocks, and sends each machine the required adjustment.

## Answer

#### Physical and logical clocks
- A **physical clock** is a hardware clock that tracks real time. Each machine's clock drifts, so physical clocks must be synchronised with each other or with UTC.
- A **logical clock** is a software counter that only orders events (happened-before). It has no relation to real time. Examples: Lamport clock and vector clock.

#### Network Time Protocol
NTP synchronises clocks over the Internet to UTC. It uses a hierarchy of time servers in **strata** (stratum 0 = atomic/GPS reference, stratum 1 = servers attached to it, stratum 2 = clients of stratum 1, etc.). Clients query several servers over UDP and compute delay and offset from four timestamps:
- offset o = ((Ti−2 − Ti−3) + (Ti−1 − Ti)) / 2
- delay d = (Ti − Ti−3) − (Ti−1 − Ti−2)

Modes: multicast, procedure-call, symmetric. The sample with the smallest delay is chosen, and the clock is changed gradually. It tolerates server failure by using multiple servers, and is accurate to a few milliseconds on the Internet.

#### Berkeley algorithm
Internal synchronisation, used when no UTC receiver is available.
1. A master machine polls all others for their time.
2. Each replies; the master adjusts values for round-trip time.
3. It averages all times (discarding outliers).
4. It sends each machine the amount to adjust (plus or minus).

```text
 Master: 3:00   polls   A: 2:50   B: 3:25
 average = (3:00 + 2:50 + 3:25)/3 = 3:05
 adjustments: Master +5, A +15, B -20
```
All clocks agree on the average, not necessarily on true time. If the master fails, another is elected.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. What does a logical clock do?
   A. Measures UTC time
   B. Corrects drift of hardware
   C. Needs a time server
   D. Orders events using a counter, unrelated to real time
   Answer: D. Lamport and vector clocks only order events. (Key point: Logical clock)

2. Which NTP formula gives the delay d?
   A. (Ti - Ti-3) - (Ti-1 - Ti-2)
   B. ((Ti-2 - Ti-3) + (Ti-1 - Ti))/2
   C. Ti - Ti-3
   D. (Ti-1 - Ti-2)/2
   Answer: A. Delay is total round trip minus server processing time. (Key point: NTP delay)

3. Master 3:00, A 2:50, B 3:25. What adjustment does B get?
   A. +20 minutes
   B. -20 minutes
   C. +5 minutes
   D. -5 minutes
   Answer: B. Average is 3:05; B at 3:25 must go back 20 min. (Key point: Berkeley example)

4. When is Berkeley's algorithm used?
   A. When a UTC source is available on a server
   B. Only on one-machine systems
   C. When no machine has a UTC receiver (internal synchronisation)
   D. Only for logical clocks
   Answer: C. It synchronises machines with each other, not with true time. (Key point: Berkeley use)

## Related in Distributed System

- [Physical clock synchronization algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aphysical-clock-sync-algorithm) — Distributed System, chapter 5
- [Lamport's logical clock algorithm](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-clock) — Distributed System, chapter 5, asked 5×
- [Physical vs logical clocks; Lamport](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alamport-physical-compare) — Distributed System, chapter 5
- [NTP; Berkeley vs Cristian](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Antp-berkeley-cristian) — Distributed System, chapter 5
- [Need of logical clock synchronization](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Alogical-clock-sync-need) — Distributed System, chapter 5
- [Physical vs logical clock; sync method](https://www.bctengineer.com/question.md?key=semester_7%2Fdistributed_system%3Aphysical-clock-sync-difficulty) — Distributed System, chapter 5, asked 2×

## Related in other subjects

- [Clock synchronization in DFS](https://www.bctengineer.com/question.md?key=semester_8%2Fbig_data_technologies%3Aclock-synchronization-dfs) — Big Data Technologies, chapter 1
- [Logical and physical address bits](https://www.bctengineer.com/question.md?key=semester_6%2Foperating_system%3Aresidence-monitor-address-bits) — Operating System, chapter 4
