# How do computers synchronize their clocks with the standard time

I'd like to know how clock synchronization is done on computers, I've read this wikipedia article however it didn't give me exactly what I was looking for, I'll outline the problem I'd like answered:

My computer has the current time stored inside it which is maintained by a clock however this clock is subject to clock drift so it is nessisary to synchronize my computers time occasionally. Say my computer would like to do such a synchronization, then it would need to make a request to some time keeping server. This server would then respond to my computer with the correct time however there would be an inaccuracy due to the fact that the servers response would not be received immediately. My computer could attempt to estimate the travel time for the response however this is bound to be inaccurate. For this reason I suspect that GPS is used to synchronize time on computers. I'd imagine this is done by having the computer receive the time directly from the satellite and synchronize based on that.

I'd like to know if this is correct, if not, how is time synchronization done? Thanks

• The title you have chosen is not well suited to representing your question. Please take some time to improve it; we have collected some advice here. Thank you! – Raphael Apr 25 '18 at 7:16

The Network Time Protocol (NTP) uses a rather simple basis, it assumes that the roundtrip time is divided equally between up and down delays after server processing is subtracted.

NTP keeps 4 timestamps per poll: client send $t_0$, server receive $t_1$, server send $t_2$ and client receive $t_3$. Server timestamps being in the server's clock and client timestamps being in the client's clock (that possibly needs adjusting).

Then the offset from one clock to the other is

$$\theta = \frac{(t_1-t_0)+(t_2-t_3)}{2}$$

The client will do statistical analysis to average out the delta and filter out outliers (filtering out excessive roundtrips for example) before adjusting the clock.

It is possible to use GPS to synchronize

• It would be possible to use GPS, and it would be very precise, but there are two problems: One, most desktop computers and laptops don't have GPS built in (although most phones and many tablets have). Two, current commercial GPS chips have very accurate time information (they need it or they wouldn't work), but no protocol to pass it to the computer. Which is very annoying. – gnasher729 Sep 23 '18 at 21:46
• @gnasher729 there is the nmea strings that include time info though. – ratchet freak Sep 24 '18 at 8:10