]> git.ipfire.org Git - thirdparty/chrony.git/blame - sourcestats.h
test: use env shebang in all bash scripts
[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,
22e5ed44
ML
72 double *offset_lo_limit,
73 double *offset_hi_limit,
74 double *root_distance,
8f062454
ML
75 double *variance,
76 double *first_sample_ago,
77 double *last_sample_ago,
78 int *select_ok);
88840341
RC
79
80/* Get data needed when setting up tracking on this source */
81extern void
d0dfa1de 82SST_GetTrackingData(SST_Stats inst, struct timespec *ref_time,
88840341 83 double *average_offset, double *offset_sd,
cca2ef46 84 double *frequency, double *frequency_sd, double *skew,
c5587b60 85 double *root_delay, double *root_dispersion);
88840341 86
88840341
RC
87/* This routine is called when the local machine clock parameters are
88 changed. It adjusts all existing samples that we are holding for
89 each peer so that it looks like they were made under the new clock
90 regime rather than the old one.
91
92 when = cooked local time when the change occurs
93
94 dfreq = delta frequency. positive means the clock has been adjusted
95 because it was previously gaining time relative to the external
96 reference(s).
97
98 doffset = offset slewed onto local clock. positive => local clock
99 has been made fast by that amount.
100
101*/
102
d0dfa1de 103extern void SST_SlewSamples(SST_Stats inst, struct timespec *when, double dfreq, double doffset);
88840341 104
0f70959d
ML
105/* This routine is called when an indeterminate offset is introduced
106 into the local time. */
107extern void SST_AddDispersion(SST_Stats inst, double dispersion);
88840341
RC
108
109/* Predict the offset of the local clock relative to a given source at
110 a given local cooked time. Positive indicates local clock is FAST
111 relative to reference. */
d0dfa1de 112extern double SST_PredictOffset(SST_Stats inst, struct timespec *when);
88840341
RC
113
114/* Find the minimum round trip delay in the register */
115extern double SST_MinRoundTripDelay(SST_Stats inst);
116
51fe80ad
ML
117/* Get data needed for testing NTP delay */
118extern int SST_GetDelayTestData(SST_Stats inst, struct timespec *sample_time,
119 double *last_sample_ago, double *predicted_offset,
120 double *min_delay, double *skew, double *std_dev);
b977c95b 121
f8610d69 122extern int SST_SaveToFile(SST_Stats inst, FILE *out);
88840341
RC
123
124extern int SST_LoadFromFile(SST_Stats inst, FILE *in);
125
d0dfa1de 126extern void SST_DoSourceReport(SST_Stats inst, RPT_SourceReport *report, struct timespec *now);
88840341 127
d0dfa1de 128extern void SST_DoSourcestatsReport(SST_Stats inst, RPT_SourcestatsReport *report, struct timespec *now);
88840341 129
7a6ee1d7
ML
130extern int SST_Samples(SST_Stats inst);
131
535ca64b
ML
132extern double SST_GetJitterAsymmetry(SST_Stats inst);
133
88840341
RC
134#endif /* GOT_SOURCESTATS_H */
135