Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

network time protocol (ntpd) sets the time on my system automatically from time servers on the net (or something like that. ;)

What I've always wondered was, how does that work? Everything that comes over the net is in packets that go through multiple hops and delays in a very asynchronous manner, so how does time information from one place get to another with compensation for travel time, etc.?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The process is quite involved, but note that an NTP sync is a conversation, and as you suspect, it needs to work out the round-trip time in order to effectively sync while taking into consideration how long packets take.

While the client may not know the time accurately when it requests a time update, it does know at least when it sent the packet. The server knows the exact time it receives a packet, plus the exact time it sends a reply. The client knows the intervening time between the time it sent a packet and the receipt of the reply.

So from these numbers it is straightforward to calculate the correct time, provided the delay is consistent across the conversation.

It isn't always consistent of course, which is why multiple servers are generally configured so that errors can be averaged out, along with the client keeping state tracking information so that it can ignore any crazy results.

Wikipedia is a good source for detail.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.