reference: report same values in tracking command as in NTP
Use REF_GetReferenceParams() in the tracking command to simplify the code and report the same values as what NTP clients of the server see. When the local reference mode is active, this changes the leap status to synchronised and reference time to one second behind current time. When not synchronised, the root delay and root dispersion are now 1 second.
This commit is contained in:
parent
59938efd23
commit
10719d6d35
3 changed files with 13 additions and 30 deletions
36
reference.c
36
reference.c
|
@ -1367,52 +1367,34 @@ int REF_IsLeapSecondClose(void)
|
||||||
void
|
void
|
||||||
REF_GetTrackingReport(RPT_TrackingReport *rep)
|
REF_GetTrackingReport(RPT_TrackingReport *rep)
|
||||||
{
|
{
|
||||||
double elapsed;
|
|
||||||
double extra_dispersion;
|
|
||||||
struct timeval now_raw, now_cooked;
|
struct timeval now_raw, now_cooked;
|
||||||
double correction;
|
double correction;
|
||||||
|
int synchronised;
|
||||||
|
|
||||||
LCL_ReadRawTime(&now_raw);
|
LCL_ReadRawTime(&now_raw);
|
||||||
LCL_GetOffsetCorrection(&now_raw, &correction, NULL);
|
LCL_GetOffsetCorrection(&now_raw, &correction, NULL);
|
||||||
UTI_AddDoubleToTimeval(&now_raw, correction, &now_cooked);
|
UTI_AddDoubleToTimeval(&now_raw, correction, &now_cooked);
|
||||||
|
|
||||||
rep->ref_id = NTP_REFID_UNSYNC;
|
REF_GetReferenceParams(&now_cooked, &synchronised,
|
||||||
|
&rep->leap_status, &rep->stratum,
|
||||||
|
&rep->ref_id, &rep->ref_time,
|
||||||
|
&rep->root_delay, &rep->root_dispersion);
|
||||||
|
|
||||||
|
if (rep->stratum == NTP_MAX_STRATUM)
|
||||||
|
rep->stratum = 0;
|
||||||
|
|
||||||
rep->ip_addr.family = IPADDR_UNSPEC;
|
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;
|
rep->current_correction = correction;
|
||||||
rep->freq_ppm = LCL_ReadAbsoluteFrequency();
|
rep->freq_ppm = LCL_ReadAbsoluteFrequency();
|
||||||
rep->resid_freq_ppm = 0.0;
|
rep->resid_freq_ppm = 0.0;
|
||||||
rep->skew_ppm = 0.0;
|
rep->skew_ppm = 0.0;
|
||||||
rep->root_delay = 0.0;
|
|
||||||
rep->root_dispersion = 0.0;
|
|
||||||
rep->last_update_interval = last_ref_update_interval;
|
rep->last_update_interval = last_ref_update_interval;
|
||||||
rep->last_offset = last_offset;
|
rep->last_offset = last_offset;
|
||||||
rep->rms_offset = sqrt(avg2_offset);
|
rep->rms_offset = sqrt(avg2_offset);
|
||||||
|
|
||||||
if (are_we_synchronised) {
|
if (are_we_synchronised) {
|
||||||
|
|
||||||
UTI_DiffTimevalsToDouble(&elapsed, &now_cooked, &our_ref_time);
|
|
||||||
extra_dispersion = (our_skew + fabs(our_residual_freq) + LCL_GetMaxClockError()) * elapsed;
|
|
||||||
|
|
||||||
rep->ref_id = our_ref_id;
|
|
||||||
rep->ip_addr = our_ref_ip;
|
rep->ip_addr = our_ref_ip;
|
||||||
rep->stratum = our_stratum;
|
|
||||||
rep->ref_time = our_ref_time;
|
|
||||||
rep->resid_freq_ppm = 1.0e6 * our_residual_freq;
|
rep->resid_freq_ppm = 1.0e6 * our_residual_freq;
|
||||||
rep->skew_ppm = 1.0e6 * our_skew;
|
rep->skew_ppm = 1.0e6 * our_skew;
|
||||||
rep->root_delay = our_root_delay;
|
|
||||||
rep->root_dispersion = our_root_dispersion + extra_dispersion;
|
|
||||||
|
|
||||||
} else if (enable_local_stratum) {
|
|
||||||
|
|
||||||
rep->ref_id = NTP_REFID_LOCAL;
|
|
||||||
rep->ip_addr.family = IPADDR_UNSPEC;
|
|
||||||
rep->stratum = local_stratum;
|
|
||||||
rep->ref_time = now_cooked;
|
|
||||||
rep->root_dispersion = LCL_GetSysPrecisionAsQuantum();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
|
|
||||||
#include "sysincl.h"
|
#include "sysincl.h"
|
||||||
#include "addressing.h"
|
#include "addressing.h"
|
||||||
|
#include "ntp.h"
|
||||||
|
|
||||||
#define REPORT_INVALID_OFFSET 0x80000000
|
#define REPORT_INVALID_OFFSET 0x80000000
|
||||||
|
|
||||||
|
@ -50,8 +51,8 @@ typedef struct {
|
||||||
typedef struct {
|
typedef struct {
|
||||||
uint32_t ref_id;
|
uint32_t ref_id;
|
||||||
IPAddr ip_addr;
|
IPAddr ip_addr;
|
||||||
unsigned long stratum;
|
int stratum;
|
||||||
unsigned long leap_status;
|
NTP_Leap leap_status;
|
||||||
struct timeval ref_time;
|
struct timeval ref_time;
|
||||||
double current_correction;
|
double current_correction;
|
||||||
double last_offset;
|
double last_offset;
|
||||||
|
|
|
@ -10,7 +10,7 @@ grep -q 'HAVE_LONG_TIME_T 1' ../../config.h || test_skip
|
||||||
limit=2
|
limit=2
|
||||||
client_server_options="noselect"
|
client_server_options="noselect"
|
||||||
client_conf="local stratum 1"
|
client_conf="local stratum 1"
|
||||||
chronyc_start="0.5"
|
chronyc_start="1.5"
|
||||||
chronyc_conf="tracking"
|
chronyc_conf="tracking"
|
||||||
|
|
||||||
for year in `seq 1850 100 2300`; do
|
for year in `seq 1850 100 2300`; do
|
||||||
|
|
Loading…
Reference in a new issue