NTP Client Stage

This stage creates and transmits a global time estimate and the current time model in use. This stage will try to connect to an NTP server for time information.

Configuration

Use the NtpClientStageConfig to configure the NTP client:

/// URLs of the NTP time servers
arraylist<string> time_server_urls;
    
/// Flag indicating if the stage should fallback to the local system time for it's source
bool fallback_system_time;

/// Flag to indicate if the system clock should be adjusted to match the synchronized
/// time on first sync. This can be useful to keep system times/files in sync with reality,
/// especially for things like certificates.
bool sync_system_time_on_startup;

/// Flag to indicate if we should constantly adjust the system clock to be in
/// sync with our time model. As with setting it on startup, this can be useful
/// to keep the system clock in sync with reality.
bool sync_system_time_always;

/// Flag to indicate if we should try to set the hardware clock if we make a large
/// jump (such as when we first synchronize time).
bool sync_hardware_clock_on_jump;

/// Flag to indicate if we should try to set the fake hardware clock if we make
/// a large jump. Similar to sync_hardware_clock_on_jump, but for the fake clock.
/// Both flags can be set at the same time.
bool sync_fake_hardware_clock_on_jump;

/// Amount of time to spend without hearing a reply before
/// we try the next server.
uint32 receive_timeout_s;

Interacting

The stage creates an NTPClient to continuously poll the server for data. The data is fed into a TimeEstimator to build the current time model. The time model and the Global Time estimate are transmitted at a rate of ~1hz.

If the system is unable to communicate with a valid NTP Server, then the local system clock is used for the best estimate for global time.

Metrics

The stage publishes statistics at 1Hz, which include both the time model and information on the quality of the sync.