Hi Sir,
I tried to verify the leap seconds by using CLOCK_TAI.
However, it didn't work.
Is there anyone try the leap seconds in OpenWRT?
The kernel is 3.10.14.
ntpd version is 4.2.8p8@1.3265-o
Please advise. Thanks a lot.
The output of nptq:
root@InDoor:/mnt/data# ntpq -crv -cas -cpe
associd=0 status=0614 leap_none, sync_ntp, 1 event, freq_mode,
version="ntpd 4.2.8p8@1.3265-o Mon May 22 11:13:21 UTC 2017 (1)",
processor="mips", system="Linux/3.10.14", leap=00, stratum=3,
precision=-16, rootdelay=43.232, rootdisp=3963.399, refid=59.126.126.125,
reftime=dccf7f13.27fede9a Wed, May 24 2017 11:40:03.156,
clock=dccf7f1c.e2d79889 Wed, May 24 2017 11:40:12.886, peer=57758, tc=6,
mintc=3, offset=-0.715585, frequency=0.000, sys_jitter=0.000000,
clk_jitter=0.256, clk_wander=0.000, tai=37, leapsec=201701010000,
expire=201706010000
ind assid status conf reach auth condition last_event cnt
===========================================================
1 57757 8011 yes no none reject mobilize 1
2 57758 963a yes yes none sys.peer sys_peer 3
3 57759 8011 yes no none reject mobilize 1
4 57760 9024 yes yes none reject reachable 2
remote refid st t when poll reach delay offset jitter
==============================================================================
zimbra.alqualon .INIT. 16 u - 64 0 0.000 0.000 0.000
*59-126-126-125. 141.32.131.246 2 u 9 64 1 20.756 -0.446 0.270
2001:4420:d053: .INIT. 16 u - 64 0 0.000 0.000 0.000
61-216-153-105. 62.161.56.158 3 u 1 64 1 8.223 0.890 1.160
The code I used:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#ifndef CLOCK_TAI
#define CLOCK_TAI 11
//# error CLOCK_TAI is not defined. Your C library is too old.
#endif
#ifndef CLOCK_UTC
# warning CLOCK_UTC is not defined, no surprise. Using CLOCK_REALTIME instead.
# define CLOCK_UTC CLOCK_REALTIME
#endif
int main()
{
struct timespec ts_utc1, ts_tai, ts_utc2;
long long diff1, diff2;
if (clock_gettime(CLOCK_UTC, &ts_utc1)) {
printf("clock_gettime(CLOCK_UTC, ...) failed\n");
exit(1);
}
if (clock_gettime(CLOCK_TAI, &ts_tai)) {
printf("clock_gettime(CLOCK_TAI, ...) failed\n");
exit(1);
}
if (clock_gettime(CLOCK_UTC, &ts_utc2)) {
printf("clock_gettime(CLOCK_UTC, ...) failed\n");
exit(1);
}
diff1 = ((ts_tai.tv_nsec - ts_utc1.tv_nsec) +
(ts_tai.tv_sec - ts_utc1.tv_sec ) * 1000000000LL);
diff2 = ((ts_tai.tv_nsec - ts_utc2.tv_nsec) +
(ts_tai.tv_sec - ts_utc2.tv_sec ) * 1000000000LL);
printf("Expected (TAI - UTC) in 2017:\n");
printf("%16lld\n", 37 * 1000000000LL);
printf("Difference between CLOCK_TAI and CLOCK_UTC is in range:\n");
printf("%16lld\n", diff2);
printf("%16lld\n", diff1);
return 0;
}
The output:
Expected (TAI - UTC) in 2017:
37000000000
Difference between CLOCK_TAI and CLOCK_UTC is in range:
-1487
4379