]> git.ipfire.org Git - thirdparty/chrony.git/blame - sourcestats.h
cmdmon: save NTS cookies and server keys on dump command
[thirdparty/chrony.git] / sourcestats.h
CommitLineData
88840341 1/*
88840341
RC
2 chronyd/chronyc - Programs for keeping computer clocks accurate.
3
4 **********************************************************************
5 * Copyright (C) Richard P. Curnow 1997-2002
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of version 2 of the GNU General Public License as
9 * published by the Free Software Foundation.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program; if not, write to the Free Software Foundation, Inc.,
8e23110a 18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
88840341
RC
19 *
20 **********************************************************************
21
22 =======================================================================
23
24 Header file for module that deals with the measurements and statistics of
25 each of the sources. */
26
27#ifndef GOT_SOURCESTATS_H
28#define GOT_SOURCESTATS_H
29
30#include "sysincl.h"
31
32#include "reports.h"
33
34typedef struct SST_Stats_Record *SST_Stats;
35
36/* Init and fini functions */
37extern void SST_Initialise(void);
38extern void SST_Finalise(void);
39
40/* This function creates a new instance of the statistics handler */
d0964ffa 41extern SST_Stats SST_CreateInstance(uint32_t refid, IPAddr *addr,
b06d74ab
ML
42 int min_samples, int max_samples,
43 double min_delay, double asymmetry);
88840341
RC
44
45/* This function deletes an instance of the statistics handler. */
46extern void SST_DeleteInstance(SST_Stats inst);
47
13d734c8
ML
48/* This function resets an instance */
49extern void SST_ResetInstance(SST_Stats inst);
50
42dd5caa
ML
51/* This function changes the reference ID and IP address */
52extern void SST_SetRefid(SST_Stats inst, uint32_t refid, IPAddr *addr);
53
6bef8aa0
ML
54/* This function accumulates a single sample into the statistics handler */
55extern void SST_AccumulateSample(SST_Stats inst, NTP_Sample *sample);
88840341
RC
56
57/* This function runs the linear regression operation on the data. It
58 finds the set of most recent samples that give the tightest
59 confidence interval for the frequency, and truncates the register
60 down to that number of samples. */
61extern void SST_DoNewRegression(SST_Stats inst);
62
88840341
RC
63/* Return the assumed worst case range of values that this source's
64 frequency lies within. Frequency is defined as the amount of time
65 the local clock gains relative to the source per unit local clock
66 time. */
67extern void SST_GetFrequencyRange(SST_Stats inst, double *lo, double *hi);
68
69/* Get data needed for selection */
70extern void
d0dfa1de 71SST_GetSelectionData(SST_Stats inst, struct timespec *now,
ff930156 72 int *stratum,
22e5ed44
ML
73 double *offset_lo_limit,
74 double *offset_hi_limit,
75 double *root_distance,
8f062454
ML
76 double *variance,
77 double *first_sample_ago,
78 double *last_sample_ago,
79 int *select_ok);
88840341
RC
80
81/* Get data needed when setting up tracking on this source */
82extern void
d0dfa1de 83SST_GetTrackingData(SST_Stats inst, struct timespec *ref_time,
88840341 84 double *average_offset, double *offset_sd,
cca2ef46 85 double *frequency, double *frequency_sd, double *skew,
c5587b60 86 double *root_delay, double *root_dispersion);
88840341 87
88840341
RC
88/* This routine is called when the local machine clock parameters are
89 changed. It adjusts all existing samples that we are holding for
90 each peer so that it looks like they were made under the new clock
91 regime rather than the old one.
92
93 when = cooked local time when the change occurs
94
95 dfreq = delta frequency. positive means the clock has been adjusted
96 because it was previously gaining time relative to the external
97 reference(s).
98
99 doffset = offset slewed onto local clock. positive => local clock
100 has been made fast by that amount.
101
102*/
103
d0dfa1de 104extern void SST_SlewSamples(SST_Stats inst, struct timespec *when, double dfreq, double doffset);
88840341 105
0f70959d
ML
106/* This routine is called when an indeterminate offset is introduced
107 into the local time. */
108extern void SST_AddDispersion(SST_Stats inst, double dispersion);
88840341
RC
109
110/* Predict the offset of the local clock relative to a given source at
111 a given local cooked time. Positive indicates local clock is FAST
112 relative to reference. */
d0dfa1de 113extern double SST_PredictOffset(SST_Stats inst, struct timespec *when);
88840341
RC
114
115/* Find the minimum round trip delay in the register */
116extern double SST_MinRoundTripDelay(SST_Stats inst);
117
51fe80ad
ML
118/* Get data needed for testing NTP delay */
119extern int SST_GetDelayTestData(SST_Stats inst, struct timespec *sample_time,
120 double *last_sample_ago, double *predicted_offset,
121 double *min_delay, double *skew, double *std_dev);
b977c95b 122
88840341
RC
123extern void SST_SaveToFile(SST_Stats inst, FILE *out);
124
125extern int SST_LoadFromFile(SST_Stats inst, FILE *in);
126
d0dfa1de 127extern void SST_DoSourceReport(SST_Stats inst, RPT_SourceReport *report, struct timespec *now);
88840341 128
d0dfa1de 129extern void SST_DoSourcestatsReport(SST_Stats inst, RPT_SourcestatsReport *report, struct timespec *now);
88840341 130
7a6ee1d7
ML
131extern int SST_Samples(SST_Stats inst);
132
535ca64b
ML
133extern double SST_GetJitterAsymmetry(SST_Stats inst);
134
88840341
RC
135#endif /* GOT_SOURCESTATS_H */
136