diff options
-rw-r--r-- | networking/ntpd.c | 32 |
1 files changed, 9 insertions, 23 deletions
diff --git a/networking/ntpd.c b/networking/ntpd.c index caf5cc299..0f350fa6f 100644 --- a/networking/ntpd.c +++ b/networking/ntpd.c | |||
@@ -127,24 +127,15 @@ | |||
127 | */ | 127 | */ |
128 | #define MAX_VERBOSE 3 | 128 | #define MAX_VERBOSE 3 |
129 | 129 | ||
130 | |||
131 | /* High-level description of the algorithm: | 130 | /* High-level description of the algorithm: |
132 | * | 131 | * |
133 | * We start running with very small poll_exp, BURSTPOLL, | 132 | * We start running with very small poll_exp, BURSTPOLL, |
134 | * in order to quickly accumulate INITIAL_SAMPLES datapoints | 133 | * in order to quickly accumulate INITIAL_SAMPLES datapoints |
135 | * for each peer. Then, time is stepped if the offset is larger | 134 | * for each peer. Then, time is stepped if the offset is larger |
136 | * than STEP_THRESHOLD, otherwise it isn't; anyway, we enlarge | 135 | * than STEP_THRESHOLD, otherwise it isn't stepped. |
137 | * poll_exp to MINPOLL and enter frequency measurement step: | ||
138 | * we collect new datapoints but ignore them for WATCH_THRESHOLD | ||
139 | * seconds. After WATCH_THRESHOLD seconds we look at accumulated | ||
140 | * offset and estimate frequency drift. | ||
141 | * | ||
142 | * (frequency measurement step seems to not be strictly needed, | ||
143 | * it is conditionally disabled with USING_INITIAL_FREQ_ESTIMATION | ||
144 | * define set to 0) | ||
145 | * | 136 | * |
146 | * After this, we enter "steady state": we collect a datapoint, | 137 | * Then poll_exp is set to MINPOLL, and we enter "steady state": we collect |
147 | * we select the best peer, if this datapoint is not a new one | 138 | * a datapoint, we select the best peer, if this datapoint is not a new one |
148 | * (IOW: if this datapoint isn't for selected peer), sleep | 139 | * (IOW: if this datapoint isn't for selected peer), sleep |
149 | * and collect another one; otherwise, use its offset to update | 140 | * and collect another one; otherwise, use its offset to update |
150 | * frequency drift, if offset is somewhat large, reduce poll_exp, | 141 | * frequency drift, if offset is somewhat large, reduce poll_exp, |
@@ -189,13 +180,10 @@ | |||
189 | // ^^^^ used to be 0.125. | 180 | // ^^^^ used to be 0.125. |
190 | // Since Linux 2.6.26 (circa 2006), kernel accepts (-0.5s, +0.5s) range | 181 | // Since Linux 2.6.26 (circa 2006), kernel accepts (-0.5s, +0.5s) range |
191 | 182 | ||
192 | /* Stepout threshold (sec). std ntpd uses 900 (11 mins (!)) */ | ||
193 | //UNUSED: #define WATCH_THRESHOLD 128 | ||
194 | /* NB: set WATCH_THRESHOLD to ~60 when debugging to save time) */ | ||
195 | //UNUSED: #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */ | ||
196 | 183 | ||
197 | /* | 184 | // #define PANIC_THRESHOLD 1000 /* panic threshold (sec) */ |
198 | * If we got |offset| > BIGOFF from a peer, cap next query interval | 185 | |
186 | /* If we got |offset| > BIGOFF from a peer, cap next query interval | ||
199 | * for this peer by this many seconds: | 187 | * for this peer by this many seconds: |
200 | */ | 188 | */ |
201 | #define BIGOFF STEP_THRESHOLD | 189 | #define BIGOFF STEP_THRESHOLD |
@@ -204,18 +192,16 @@ | |||
204 | #define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */ | 192 | #define FREQ_TOLERANCE 0.000015 /* frequency tolerance (15 PPM) */ |
205 | #define BURSTPOLL 0 /* initial poll */ | 193 | #define BURSTPOLL 0 /* initial poll */ |
206 | #define MINPOLL 5 /* minimum poll interval. std ntpd uses 6 (6: 64 sec) */ | 194 | #define MINPOLL 5 /* minimum poll interval. std ntpd uses 6 (6: 64 sec) */ |
207 | /* | 195 | /* If offset > discipline_jitter * POLLADJ_GATE, and poll interval is > 2^BIGPOLL, |
208 | * If offset > discipline_jitter * POLLADJ_GATE, and poll interval is > 2^BIGPOLL, | ||
209 | * then it is decreased _at once_. (If <= 2^BIGPOLL, it will be decreased _eventually_). | 196 | * then it is decreased _at once_. (If <= 2^BIGPOLL, it will be decreased _eventually_). |
210 | */ | 197 | */ |
211 | #define BIGPOLL 9 /* 2^9 sec ~= 8.5 min */ | 198 | #define BIGPOLL 9 /* 2^9 sec ~= 8.5 min */ |
212 | #define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */ | 199 | #define MAXPOLL 12 /* maximum poll interval (12: 1.1h, 17: 36.4h). std ntpd uses 17 */ |
213 | /* | 200 | /* Actively lower poll when we see such big offsets. |
214 | * Actively lower poll when we see such big offsets. | ||
215 | * With SLEW_THRESHOLD = 0.125, it means we try to sync more aggressively | 201 | * With SLEW_THRESHOLD = 0.125, it means we try to sync more aggressively |
216 | * if offset increases over ~0.04 sec | 202 | * if offset increases over ~0.04 sec |
217 | */ | 203 | */ |
218 | //#define POLLDOWN_OFFSET (SLEW_THRESHOLD / 3) | 204 | // #define POLLDOWN_OFFSET (SLEW_THRESHOLD / 3) |
219 | #define MINDISP 0.01 /* minimum dispersion (sec) */ | 205 | #define MINDISP 0.01 /* minimum dispersion (sec) */ |
220 | #define MAXDISP 16 /* maximum dispersion (sec) */ | 206 | #define MAXDISP 16 /* maximum dispersion (sec) */ |
221 | #define MAXSTRAT 16 /* maximum stratum (infinity metric) */ | 207 | #define MAXSTRAT 16 /* maximum stratum (infinity metric) */ |