1

CLOCK_TAI is basically designed as CLOCK_REALTIME(UTC) + tai_offset.

I use the code to test the difference between TAI and REALTIME.

But I got difference result on Raspberry pi and OpenWRT.

#include <stdio.h>
#include <time.h>

#ifndef CLOCK_TAI
#define CLOCK_TAI 11
#endif

int main()
{
    struct timespec ts;

    clock_gettime(CLOCK_REALTIME, &ts);
    printf("CLOCK_REALTIME: %d, %ld\n", ts.tv_sec, ts.tv_nsec);

    clock_gettime(CLOCK_TAI, &ts);
    printf("CLOCK_TAI: %d, %ld\n", ts.tv_sec, ts.tv_nsec);

    return 0;
}

I also download the leapfile from: https://www.ietf.org/timezones/data/leap-seconds.list and add leapfile "/path/to your/leap-file" on /etc/ntp.conf

In this time, the diff seconds should be 37 seconds (check leap-seconds.list)

Here is my expected result in Raspberry pi:

CLOCK_REALTIME  : 1497357750, 808013378
CLOCK_TAI       : 1497357787, 809035924

(1497357787-1497357750 = 37)


But when I do the same thing in OpenWRT. REALTIME and TAI are almost the same.

CLOCK_REALTIME  : 1497355658, 843078207
CLOCK_TAI       : 1497355658, 843287721

# ntpq -crv
associd=0 status=0614 leap_none, sync_ntp, 1 event, freq_mode,
version="ntpd 4.2.8p10@1.3728-o Tue Jun 13 11:54:10 UTC 2017 (1)",
processor="mips", system="Linux/3.10.14", leap=00, stratum=2,
precision=-17, rootdelay=5.275, rootdisp=192.843, refid=59.125.122.217,
reftime=dcea5404.21137eb8  Tue, Jun 13 2017 12:07:32.129,
clock=dcea542d.f1399189  Tue, Jun 13 2017 12:08:13.942, peer=28311, tc=6,
mintc=3, offset=-2.809440, frequency=0.000, sys_jitter=1.576573,
clk_jitter=0.936, clk_wander=0.000, tai=37, leapsec=201701010000,
expire=201712280000

The openWRT info:

  • openwrt: barrier_breaker 14.07
  • uClibc 0.9.33.2
  • gcc 4.8.x with Linaro enhancements
  • ntpd - NTP daemon program - Ver. 4.2.8p10
  • Linux kernel: 3.10.14 mips

Can someone give me some suggestion?

Andrew Lin
  • 45
  • 5
  • I did the same test on ubuntu 14.04. The result is same as in openWRT. CLOCK_TAI and CLOCK_REALTIME gets the same result. Ubntu 14.04 info: `ntpd 4.2.6p5`; `gcc (Ubuntu 4.8.4-2ubuntu1~14.04.3) 4.8.4`; `Linux kernel: 4.4.0-31-generic` – Andrew Lin Jun 13 '17 at 13:50

0 Answers0