GPS:NTP时间注入的工作原理工作原理、时间、GPS、NTP

2023-09-07 04:55:15 作者:人间不值得

我最近知道 /system/etc/ 目录中有一个 gps.conf 文件.似乎将 NTP_SERVER 值调整为更靠近通常位置的 NTP 服务器可以提高 TTFF.

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.

阅读 LocationProvider 类中的源代码,似乎在启动时,时间是从 NTP 服务器检索并在计算中注入"的.AFAIK 每个 GPS 卫星都有一个非常精确的原子钟,并且星座中的每一个都与所谓的GPS 时间"同步.一旦接收器获得 4 颗或更多卫星,它就会(通过某种方法)求解一个方程,其中有四个未知数:x、y、z、b;其中 (x,y,z) 是接收器位置,b 是接收器内部时钟与(正确的)GPS 时间之间的时间差.一旦得到修复,接收器时钟就会与正确的时间同步.(如果我错了,请纠正我).

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).

到目前为止,我对 NTP 时间注入的工作方式有一些疑问:

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

GPS 时间大致是 TAI(国际原子时间)加上偏移量.这两个时间不取决于地球自转,但是 UTC 确实如此.鉴于 NTP 服务器返回 UTC 时间,是否可以从 UTC 时间推断 GPS 时间?从较近的服务器检索 NTP 时间如何提高 GPS 时间近似的质量"?假设我们有一个初始 GPS 时间值(以某种方式从 NTP 时间推断),那么注入是关于什么的?这个时间值是否被认为是正确求解只有 x,y,z 作为未知数的方程?如果是这样,那么第一个修复也只是一个近似值,不是吗?更高质量的 GPS 时间初始近似值如何提高 TTFF?是否因为 NTP 时间质量较低,第一次修复被认为是不可接受的并被丢弃?拥有一个近似的初始位置是否有助于检索下一个正确的修复(例如只收听卫星的一个子集)?

推荐答案

好吧,搜索一下 wikipedia 和其他一些资源,让我有一些猜测.

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

是的,您可以从 UTC 时间推断 GPS 时间.您只需要知道偏移量,它每 15 秒传输一次,并在大约 18 个月内更改一次.来源:维基百科

NTP 不会给你准确的时间.它测量消息从客户端到服务器的时间以及响应从服务器到客户端的时间.然后使用这些时间来计算连接的延迟.然后将其用作接收时间的偏移量.这适用于对称路线.如果路由不对称,则存在错误.所以离服务器越近,不对称的机会和水平就越低,从而降低错误.来源:再次维基百科

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

NTP 信号不直接用于获取 GPS 定位.但要获得准确的修复,您需要非常准确的时钟.我们在这里谈论的是纳秒.GPS 卫星确实传输当前 GPS 时间,但即使它以光速传播,也会有一些延迟.GPS接收器无法知道延迟是多少,因此它必须从几个接收到的信号中进行近似.每次接收到传输时,时钟都会变得更加精确.因此,您在开始时拥有的时间越好,您必须接收的时间信号就越少才能获得准确的时钟.来源:维基百科

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

在 3 中已经解释得很清楚了 - 时钟误差越低,近似正确时间所需的信号就越少.

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

我在这里猜测得很少,但大致位置可以帮助您更好地估计与卫星的距离,从而更好地估计延迟.(不确定是否真的使用过.)

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 ;-)