Channels ▼


Testing and Verifying Time Synchronization


I used TimeKeeper version 2.12 was used for these tests. TimeKeeper does not save calibration data between runs so there was no calibration data to delete before these tests to get a "cold" start.

Figure 8 shows a 24-hour run of TimeKeeper synchronizing to the GPS and PPS signal.

[Click image to view at full size]
Figure 8: TimeKeeper server offset; 24 hours.

TimeKeeper very quickly begins to adjust the offset and asymptotically approaching 0. Within 2 minutes the TimeKeeper has adjust the offset from 0.5 seconds to 10 milliseconds and within 3 minutes to below 1 millisecond. Figure 9 shows a detailed view of the correction that TimeKeeper applies on startup and gives a good view of how quickly and predictably TimeKeeper corrects offsets.

[Click image to view at full size]
Figure 9: TimeKeeper server offset; first 3 minutes .

Figure 10 shows the last hour of the TimeKeeper server running. Offset from the PPS signal is staying below 1 microsecond.

[Click image to view at full size]
Figure 10: TimeKeeper server offset; hour 23 to 24.

TimeKeeper Client

Figure 11 shows a TimeKeeper client offset for 24 hours.

[Click image to view at full size]
Figure 11: TimeKeeper client offset; 24 hours .

Figure 12 shows the offset for the last hour of a 24-hour run. The client system time offset from the PPS is staying below 1 microsecond.

[Click image to view at full size]
Figure 12: TimeKeeper client offset; hour 23 to hour 24.

The offset is so small it is difficult to see so Figure 13 shows the last data points for more detail. The measured offset from the PPS on the client is within a few microseconds of 0. This is very near the precision of the server itself shown in the previous section.

[Click image to view at full size]
Figure 13: TimeKeeper client offset; ending detail .

There are no abrupt jumps or discontinuities in this graph that would show if TimeKeeper were applying instantaneous corrections to the clock as NTP did in the NTP client graphs. Figure 14 shows how TimeKeeper applies correction on the client. Offset from the correct time asymptotically approaches 0 just as on the server and within a few minutes is below a millisecond with a very predictable curve.

[Click image to view at full size]
Figure 14: TimeKeeper client offset; first 5 minutes .


Our tests show that TimeKeeper keeps clients synchronized to a server and an optional external time reference to within a few microseconds. It also does not create large time jumps that may create inconsistent application behavior.

Our tests suggest that the NTP server provides current system time to clients rather than its best estimate of correct time. During startup this means clients are chasing a moving target during synchronization rather than a stable source time that is available to the server. This is not the case in the TimeKeeper server which provides a common time reference to clients that it attempts to synchronize with. This means a much faster startup and that there is no moving target during initialization.

NTP uses Linux system calls to adjust and to provide time to applications. It is limited by the flexibility and capability of Linux. TimeKeeper replaces the family of time query system calls (gettimeofday() for example) in Linux with its own so a separate software clock can be maintained rather than relying on Linux to maintain and correct time accurately. For example, Linux will use the APIC clock, HPET clock or other low-resolution devices for timekeeping. TimeKeeper uses the processor-clock frequency TSC instead and overcomes problems with the TSC that normally prohibits software from using it. It does this by monitoring and controlling processor C-state transitions and accounting for clock-speed changes on each CPU core independently and correcting for them internally rather than assuming and requiring that all processors maintain synchronized clocks though hardware.

Imagine a scenario where a server and client are rebooted by an administrator on a Monday morning after an upgrade or crash from the weekend. The system needs to be up and reliable by the time the trading or business day begins since the applications being used require very accurate system time for regulatory compliance, customer service agreements and correct functioning. NTP would not work in this scenario but TimeKeeper would by providing consistent, stable and quick time synchronization.

Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.