====== Time Management ======
On board time management is done using NTP daemon (ntpd).
Time management is done using [[https://en.wikipedia.org/wiki/Coordinated_Universal_Time|UTC time]]. There are other times scales usually used:
* Local Time: an offset in hours (or sometimes half hours) depending on the country. Fixed by national laws.
* [[https://en.wikipedia.org/wiki/International_Atomic_Time|International atomic time (TAI)]]: Monotonic time aligned on UTC time in 1958. Since then, some seconds were sometimes inserted in UTC time resulting in an offset between current TAI time and UTC time (37 seconds in 2017). This feature is called leap seconds.
In Linux, the reference time is UTC time and that's the time scale used by NTP daemon and by GPS NMEA frames.
===== NTP configuration =====
File: ''/etc/ntp.conf'' \\
To set system time, NTP daemon can be configured to use multiple sources. It will select the most accurate source.
==== GPS source ====
To select GPS source, this should be written in ''/etc/ntp.conf'':
server 127.127.20.0 mode 65536 minpoll 4 prefer
fudge 127.127.20.0 flag1 1 flag2 0 flag3 1 time1 0.0
If this is configured, NTP daemon will try to:
* Read NMEA frames on ''/dev/gps0''. GPS NMEA frames give UTC time with a second precision.
* Get PPS signal on ''/dev/gpspps0''. Pulse Per Second signal is a very precise pulse received at beginning of each second.
This can only work on Wirnetâ„¢ gateways with a GPS device.
==== Network configuration ====
In this configuration, NTP daemon will try to receive time information from a pool of NTP servers. Information between servers and gateway is exchanged using NTP protocol.
pool pool.ntp.org iburst
==== Local configuration ====
Local hardware clock remains the last solution if all other sources are not available. It is usually less precise than network or GPS time.
server 127.127.1.0
fudge 127.127.1.0 stratum 14
==== TAI clock Feature ====
NTP daemon can also be configured to set TAI clock offset. To do that, it uses a leap file containing time of insertion of all seconds in UTC time. This file is usually downloaded from Internet ([[https://www.ietf.org/timezones/data/leap-seconds.list|here]] for example). Leap seconds insertion is announced at least one month in advance so a well maintained system will have this information before insertion really occurs. In NTP daemon configuration, leap file is configured by this line:
leapfile /user/leap-seconds.list
TAI offset is not set directly when NTP daemon starts, it can take time.