GPS: How NTP time injection works

后端 未结 3 1084
耶瑟儿~
耶瑟儿~ 2021-01-30 04:20

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 loca

3条回答
  •  醉话见心
    2021-01-30 05:08

    My answer will focus more on the NTP side of your question. For GPS, I have studied this PDF paper mentioned in a comment by mirabilos.

    According to that document, for warm start of GPS receiver, you need to know time within 20s, position within 100km, velocity within 25 m/s and almanac data at most few weeks old. You still need to download ephemiride data from each satellite, which takes between 30 seconds to 3 minutes based on the GPS receiver type.

    For hot start, you need also the ephemeride data (they are valid for 4 hours). They are also available via A-GPS (see below).

    NTP protocol uses a hierarchy of servers starting with the original time source - GPS, atomic clock, ... This is called stratum-0 source. NTP server directly connected to this source is called stratum-1. Server using this as its upstream server is stratum-2 and so on. You need special tuned hardware to achieve less than 1 ms error even for stratum-1 servers (due to CPU interrupt latencies, serial port latencies, temperature oscillator changes).

    With normal HW on normal network (not saturated DSL link for example) you can achieve about 10 ms accuracy. For example NTP pool considers its servers valid and good enough if they have time precise within 100 ms. The accuracy of time from NTP does not depend on geographical position between you and NTP server, but more on the stratum, quality of that server and how far the server is based on the network topology.

    Android phones usually know the time within at least 1 second accuracy. Either via periodic time synchronization via GSM network or if data connection (wifi or cellular) is available, also via NTP.

    For the mentioned application FasterGPS - changing your NTP server to better one will not help you to have faster TTFF. For that you would need to have time with precision within nanoseconds, which is not possible via NTP. Only the GPS chip itself is able to keep track of time with that precision. What helps on android to have faster TTFF is:

    • You already have good time within 20s on your android phone
    • Having approximate possition either via Wifi or from GSM network (within few km based on transmission towers)
    • Using A-GPS - it downloads fresh copy of almanac and ephemerides for all GPS satellites via internet, so you don't need to download it from the GPS satellites (which takes 30 sec for ephemerides and 15 minutes for almanac). With A-GPS, you can use hot start and have TTFF under 10 seconds.

提交回复
热议问题