NTP (Network Time Protocol) / PTP (Precision Time Protocol)
The hard part is not asking the time
★★★ Asking the time is easy. The hard part is how long the answer spent in transit.
★★★★ When "three o'clock exactly" reaches you it is already a few milliseconds past three -- and you do not know how many.
★★★ So a time protocol's whole job is to estimate the one-way delay and add it back. NTP and PTP merely estimate it differently.
★★★ The fundamental difference
★★★★ · NTP: four timestamps measure a round trip, assuming symmetry, with timestamps taken by the operating system in software -> millisecond precision;
★★★★ · PTP: timestamps taken by NIC hardware, and every switch participates, reporting how long it held the packet -> nanosecond precision.
★★★★ Visible in the diagrams: NTP has three grey layers (Ethernet, IP, UDP) while PTP has one -- it rides Ethernet directly.
★ Common misconceptions
★★★ "A closer NTP server is more accurate" -- symmetry matters more than distance. If the two directions differ in length (fibre one way, microwave the other) the error is half that difference.
★★★ "Switch to PTP and get nanoseconds" -- not so. Every switch in the path must support PTP; one that does not drops you back to milliseconds.
★★ "A small time jump is harmless" -- databases and logs disagree, which is why NTP prefers to slew slowly.