skew = (source_freq_hi - source_freq_lo) / 2.0;
/* and then calculate peer dispersion */
- epsilon = LCL_GetSysPrecisionAsQuantum() + now_err + skew * local_interval;
+ epsilon = LCL_GetSysPrecisionAsQuantum() + now_err + skew * fabs(local_interval);
} else {
/* If test3 failed, we probably can't calculate these quantities
the standard deviation of the offsets in the register is less than an
administrator-defined value or the difference between measured offset
and predicted offset is larger than the increase in delay */
- if (!SRC_IsGoodSample(inst->source, -theta, delta, inst->max_delay_dev_ratio,
- LCL_GetMaxClockError(), &sample_time)) {
+ if (!SRC_IsGoodSample(inst->source, -theta, fabs(delta),
+ inst->max_delay_dev_ratio, LCL_GetMaxClockError(), &sample_time)) {
test4c = 0; /* Failed */
} else {
test4c = 1; /* Success */
/* Test 8 checks that the root delay and dispersion quoted in
the packet are appropriate */
- if ((fabs(pkt_root_delay) >= NTP_MAX_DISPERSION) ||
+ if ((pkt_root_delay >= NTP_MAX_DISPERSION) ||
(pkt_root_dispersion >= NTP_MAX_DISPERSION)) {
test8 = 0; /* Failed */
} else {
valid_header = test5 && test6 && test7i && test8;
good_header = valid_header && test7ii;
- root_delay = pkt_root_delay + delta;
+ root_delay = pkt_root_delay + fabs(delta);
root_dispersion = pkt_root_dispersion + epsilon;
#ifdef TRACEON
SRC_AccumulateSample(inst->source,
&sample_time,
- theta, delta, epsilon,
+ theta, fabs(delta), epsilon,
root_delay, root_dispersion,
message->stratum, (NTP_Leap) pkt_leap);
inst->sample_times[n] = *sample_time;
inst->offsets[n] = offset;
inst->orig_offsets[m] = offset;
- inst->peer_delays[m] = fabs(peer_delay);
+ inst->peer_delays[m] = peer_delay;
inst->peer_dispersions[m] = peer_dispersion;
inst->root_delays[m] = root_delay;
inst->root_dispersions[m] = root_dispersion;
elapsed = -times_back[i];
assert(elapsed >= 0.0);
- root_distance = inst->root_dispersions[j] + elapsed * inst->skew + 0.5 * fabs(inst->root_delays[j]);
+ root_distance = inst->root_dispersions[j] + elapsed * inst->skew + 0.5 * inst->root_delays[j];
if (root_distance < best_root_distance) {
best_root_distance = root_distance;
best_index = i;