NTP maxerror patch for 2.x

Ulrich Windl (ulrich.windl@rz.uni-regensburg.de)
Tue, 29 Apr 1997 11:19:43 +0200


--Message-Boundary-26798
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Mail message body

Hello,

I have an unimportant patch for the Linux 2.0 kernel, thus it can be
included in the next versions of 2.0 and 2.1. I haven't checked 2.1,
but I guess a appropriate patch is not there.

The patch just increases the largest accepted value for "maxerror", a
kernel variable used for NTP time synchronization. As the previous
value was according to Dave Mills reference implementation (512ms),
the new value is much larger (about 16s). The value is the maximum
acceptable value and the initial value after booting.

Experience has shown that for a typical Linux NTP client served by
a typical NTP server (i.e. stratum 2 over the Internet) the estimated
error is around 20ms. Also with the typical polling interval of
1024s, the maximum error exceeds 512ms from time to time, thus
declaring the clock as unsynchronized.

Another sitiuation is initial synchronization where the first
estimated error is usually about 1s.

The value itself is a matter of discussion, with only two
restrictions: It may never overflow (into negative or back to zero),
and it should be reasonably large. I have made an estimation which
should really be acceptable (stratum 3, rather poor reference clock,
high network delay).

For those people not concearned with NTP the patch does change
nothing.

Ulrich Windl

--Message-Boundary-26798
Content-type: text/plain; charset=US-ASCII
Content-transfer-encoding: 7BIT
Content-description: Text from file 'maxerr~1.pat'

--- sched.c 1996/05/27 14:54:01 1.6
+++ sched.c 1997/04/28 20:04:36
@@ -61,10 +61,10 @@
long time_constant = 2; /* pll time constant */
long time_tolerance = MAXFREQ; /* frequency tolerance (ppm) */
long time_precision = 1; /* clock precision (us) */
-long time_maxerror = MAXPHASE; /* maximum error (us) */
-long time_esterror = MAXPHASE; /* estimated error (us) */
+long time_maxerror = MAX_ERROR_PHASE; /* maximum error (us) */
+long time_esterror = MAX_ERROR_PHASE; /* estimated error (us) */
long time_phase = 0; /* phase offset (scaled us) */
long time_freq = ((1000000 + HZ/2) % HZ - HZ/2) << SHIFT_USEC; /* frequency offset (scaled ppm) */
long time_adj = 0; /* tick adjust (scaled 1 / HZ) */
@@ -667,6 +746,12 @@
* All the kudos should go to Dave for this stuff.
*
*/
+
+/* The maximum error is set to root_dispersion * 16 + root_distance * 4.
+ * We assume worst-case dispersion (MAXPHASE) and distance (4 seconds).
+ */
+#define MAX_ERROR_PHASE (MAXPHASE << 5) /* maximum error limit (us): 16s */
+
static void second_overflow(void)
{
long ltemp;
@@ -675,7 +760,7 @@
* revert to unsynchronized state. That will prevent updates of the
* CMOS clock.
*/
- if ( time_maxerror < MAXPHASE )
+ if ( time_maxerror < MAX_ERROR_PHASE )
time_maxerror += time_tolerance >> SHIFT_USEC;
else
time_status |= STA_UNSYNC;

--Message-Boundary-26798--