typedef struct {
uint32_t ref_id;
IPAddr ip_addr;
- uint32_t stratum;
+ uint16_t stratum;
+ uint16_t leap_status;
Timeval ref_time;
Float current_correction;
Float last_offset;
from the tracking log file is shown below.
@example
-1998-07-22 05:40:50 158.152.1.76 3 340.529 1.606 1.046e-03
+2012-02-23 05:40:50 158.152.1.76 3 340.529 1.606 1.046e-03 N
@end example
The columns are as follows (the quantities in square brackets are the
@enumerate 1
@item
-Date [1998-07-22]
+Date [2012-02-03]
@item
Hour:Minute:Second [05:40:50]. Note that the date/time pair is
expressed in UTC, not the local time zone.
The estimated local offset at the epoch (which is rapidly corrected by
slewing the local clock. (In seconds, positive indicates the local
system is fast of UTC). [1.046e-3]
+@item
+Leap status (@code{N} means normal, @code{+} means that the last minute
+of this month has 61 seconds, @code{-} means that the last minute of the month
+has 59 seconds, @code{?} means the clock is not currently synchronised.) [N]
@end enumerate
A banner is periodically written to the log file to indicate the
@item Update interval
This is the interval between the last two clock updates.
+@item Leap status
+This is the leap status, which can be @code{Normal}, @code{Insert second},
+@code{Delete second} or @code{Not synchronised}.
+
@end table
@c }}}
@c {{{ trimrtc
double root_delay;
double root_dispersion;
double last_update_interval;
+ const char *leap_status;
request.command = htons(REQ_TRACKING);
if (request_reply(&request, &reply, RPY_TRACKING, 0)) {
ref_ip = host;
}
+ switch (ntohs(reply.data.tracking.leap_status)) {
+ case LEAP_Normal:
+ leap_status = "Normal";
+ break;
+ case LEAP_InsertSecond:
+ leap_status = "Insert second";
+ break;
+ case LEAP_DeleteSecond:
+ leap_status = "Delete second";
+ break;
+ case LEAP_Unsynchronised:
+ leap_status = "Not synchronised";
+ break;
+ default:
+ leap_status = "Unknown";
+ break;
+ }
+
printf("Reference ID : %lu.%lu.%lu.%lu (%s)\n", a, b, c, d, ref_ip);
- printf("Stratum : %lu\n", (unsigned long) ntohl(reply.data.tracking.stratum));
+ printf("Stratum : %lu\n", (unsigned long) ntohs(reply.data.tracking.stratum));
UTI_TimevalNetworkToHost(&reply.data.tracking.ref_time, &ref_time);
ref_time_tm = *gmtime((time_t *)&ref_time.tv_sec);
printf("Ref time (UTC) : %s", asctime(&ref_time_tm));
printf("Root delay : %.6f seconds\n", root_delay);
printf("Root dispersion : %.6f seconds\n", root_dispersion);
printf("Update interval : %.1f seconds\n", last_update_interval);
+ printf("Leap status : %s\n", leap_status);
return 1;
}
return 0;
tx_message->reply = htons(RPY_TRACKING);
tx_message->data.tracking.ref_id = htonl(rpt.ref_id);
UTI_IPHostToNetwork(&rpt.ip_addr, &tx_message->data.tracking.ip_addr);
- tx_message->data.tracking.stratum = htonl(rpt.stratum);
+ tx_message->data.tracking.stratum = htons(rpt.stratum);
+ tx_message->data.tracking.leap_status = htons(rpt.leap_status);
UTI_TimevalHostToNetwork(&rpt.ref_time, &tx_message->data.tracking.ref_time);
tx_message->data.tracking.current_correction = UTI_FloatHostToNetwork(rpt.current_correction);
tx_message->data.tracking.last_offset = UTI_FloatHostToNetwork(rpt.last_offset);
}
logfileid = CNF_GetLogTracking() ? LOG_FileOpen("tracking",
- " Date (UTC) Time IP Address St Freq ppm Skew ppm Offset")
+ " Date (UTC) Time IP Address St Freq ppm Skew ppm Offset L")
: -1;
max_update_skew = fabs(CNF_GetMaxUpdateSkew()) * 1.0e-6;
/* ================================================== */
static void
-write_log(struct timeval *ref_time, char *ref, int stratum, double freq, double skew, double offset)
+write_log(struct timeval *ref_time, char *ref, int stratum, NTP_Leap leap, double freq, double skew, double offset)
{
+ const char leap_codes[4] = {'N', '+', '-', '?'};
if (logfileid != -1) {
- LOG_FileWrite(logfileid, "%s %-15s %2d %10.3f %10.3f %10.3e",
- UTI_TimeToLogForm(ref_time->tv_sec), ref, stratum, freq, skew, offset);
+ LOG_FileWrite(logfileid, "%s %-15s %2d %10.3f %10.3f %10.3e %1c",
+ UTI_TimeToLogForm(ref_time->tv_sec), ref, stratum, freq, skew, offset, leap_codes[leap]);
}
}
write_log(&now,
our_ref_ip.family != IPADDR_UNSPEC ? UTI_IPToString(&our_ref_ip) : UTI_RefidToString(our_ref_id),
our_stratum,
+ our_leap_status,
abs_freq_ppm,
1.0e6*our_skew,
our_offset);
write_log(ref_time,
"127.127.1.1",
our_stratum,
+ our_leap_status,
abs_freq_ppm,
1.0e6*our_skew,
offset);
schedule_fb_drift(&now);
}
+ update_leap_status(LEAP_Unsynchronised, 0);
+ are_we_synchronised = 0;
+
write_log(&now,
"0.0.0.0",
0,
+ our_leap_status,
LCL_ReadAbsoluteFrequency(),
1.0e6*our_skew,
0.0);
-
- are_we_synchronised = 0;
-
- update_leap_status(LEAP_Unsynchronised, 0);
}
/* ================================================== */
rep->ref_id = 0;
rep->ip_addr.family = IPADDR_UNSPEC;
rep->stratum = 0;
+ rep->leap_status = our_leap_status;
rep->ref_time.tv_sec = 0;
rep->ref_time.tv_usec = 0;
rep->current_correction = correction;
uint32_t ref_id;
IPAddr ip_addr;
unsigned long stratum;
+ unsigned long leap_status;
struct timeval ref_time;
double current_correction;
double last_offset;