GPS: How NTP time injection works

Mister Smith picture Mister Smith · Nov 29, 2011 · Viewed 34k times · Source

I've recently known about a gps.conf file in the /system/etc/ directory. Seems that tweaking NTP_SERVER values to NTP servers nearer to the usual location improves TTFF.

Reading the source code in the LocationProvider class, seems that at boot, time is retrieved from NTP server and "injected" in the calculations. AFAIK each GPS sat has a very accurate atomic clock, and every one in the constellation is synchronized to the so called "GPS time". Once the receiver has got 4 or more satellites, it solves (by some method) an equation where there are four unknowns: x,y,z,b; where (x,y,z) is the receiver location, and b is the time difference between the receiver internal clock and the (correct) GPS time. Once it has a a fix, the receiver clock is synced with the correct time. (Please correct me if I'm wrong).

So far, I've some questions regarding the way NTP time injection works:

  1. GPS Time is roughly TAI (International Atomic Time) plus an offset. Those two times do not depend on the Earth rotation, however UTC does. Given that NTP servers return UTC time, it is possible to infer GPS Time from UTC time?
  2. How does retrieving NTP time from a nearer server improve the "quality" of the GPS time approximation?
  3. Assuming that we have an initial GPS Time value (inferred from NTP time somehow), what is the injection about? Is this time value taken as correct to solve the equation with only x,y,z as unknowns? If so, then the first fix is also just an approximation, isn't it?
  4. How does a higher quality initial approximation for GPS time improve TTFF? Is it because with a lower quality NTP time the first fixes are considered not acceptable and discarded?
  5. Does having an approximate initial position help retrieving the next correct fix (like listening only to a subset of sats)?

Answer

Fox picture Fox · Dec 8, 2011

Well scouting a bit of wikipedia and some other sources, let me have a few guessses.

  1. Yes, you can infer GPS time from UTC time. You just have to know the offset, which is transmitted every 15 seconds and changes once in approximately 18 months. Source: Wikipedia

  2. NTP does not give you exact time. It measures the time message gets from client to server and the time the response gets from server to client. These times are then used to calculate the delay of the connection. Which is then applied as an offset to received time. This works for symmetrical routes. If the routes are assymetrical, there is an error. So closer the server, lower the the chance and level of assymetry, thus lower the error. Source: Wikipedia again

  3. NTP signal is not directly used to obtain the GPS fix. But for an accurate fix you need very accurate clocks. We're talking nanoseconds here. GPS satellites do transmit current GPS time, but even as it travels at speed of light, there is some delay. GPS receiver has no way to know what the delay is, so it has to approximate from several received signals. With every transmission received the clock get more precise. So the better time you have at the beginning, the less time signals you have to receive to have an accurate clock. Source: Wikipedia

  4. Well pretty much explained in 3. - the lower clock error the less signals needed to approximate the correct time.

  5. I'm little guessing here, but having approximate location can help you better approximate the distance from satellite and thus the delay. (Not sure if that is really used.)

I hope it makes at least a little sense ;-)