NTP (Network Time Protocol) / PTP (Precision Time Protocol)
One-way delay
When a client receives the time reported by a server, the answer has already spent some time in the network, and the client does not know how long. For example, when "three o'clock exactly" arrives, the actual time is already a few milliseconds past three.
A time protocol's job is to estimate the one-way delay and add it to the received time. NTP and PTP differ in how they estimate it.
NTP and PTP compared
· NTP: four timestamps measure the round trip, assuming equal delay in both directions, with timestamps taken by the operating system in software -> millisecond precision;
· PTP: timestamps taken by NIC hardware, and every switch on the path participates by reporting how long the message stayed inside it -> nanosecond precision.
NTP is carried in UDP (port 123); PTP can run directly over Ethernet (EtherType 0x88F7) or in UDP (ports 319 / 320).
Common misconceptions
NTP's accuracy depends on whether the two directions are symmetric; a closer server is not necessarily more accurate. If the two directions have different delays (fibre one way, microwave the other), the error is half the difference.
PTP reaches nanosecond precision only if the switches on the path support PTP; one that does not leaves its queueing time unreported, and the error is back to tens or hundreds of microseconds.
A time jump puts database and log ordering out of order, which is why NTP prefers to adjust the clock gradually.