The NTP filtering and selection algorithms act upon a set of variables for clock offset theta ,THETA, roundtrip delay delta ,DELTA and dispersion epsilon , EPSILON. When necessary to distinguish between them, lower-case Greek letters are used for variables relative to a peer, while upper-case Greek letters are used for variables relative to the primary reference source(s), i.e., via the peer to the root of the synchronization subnet. Subscripts will be used to identify the particular peer when this is not clear from context. The algorithms are based on a quantity called the synchronization distance lambda ,LAMBDA, which is computed from the roundtrip delay and dispersion as described below.
As described in Appendix H, the peer dispersion epsilon includes contributions due to measurement error p=1<< sys.precision, skew-error accumulation phi tau, where phi = NTP.MAXSKEW over NTP.MAXAGE is the maximum skew rate and tau = sys.clock - peer.update is the interval since the last update, and filter (sample) dispersion epsilon sub sigma computed by the clock-filter algorithm. The root dispersion EPSILON includes contributions due to the selected peer dispersion epsilon and skew-error accumulation phi tau, together with the root dispersion for the peer itself. The system dispersion includes the select (sample) dispersion epsilon sub xi computed by the clock-select algorithm and the absolute initial clock offset | THETA | provided to the local-clock algorithm. Both epsilon and EPSILON are dynamic quantities, since they depend on the elapsed time tau since the last update, as well as the sample dispersions calculated by the algorithms.
Each time the relevant peer variables are updated, all dispersions associated with that peer are updated to reflect the skew-error accumulation. The computations can be summarized as follows:
theta == peer.offset, delta == peer.delay, epsilon == peer.dispersion = rho + phi tau + epsilon sub sigma, lambda == epsilon + | delta | over 2,
where tau is the interval since the original timestamp (from which theta and delta were determined) was transmitted to the present time and epsilon sub sigma is the filter dispersion (see clock-filter procedure below). The variables relative to the root of the synchronization subnet via peer i are determined as follows:
THETA sub i == theta sub i , DELTA sub i == peer.rootdelay + delta sub i, EPSILON sub i == peer.rootdispersion + epsilon sub i + phi tau sub i , LAMBDA sub i == EPSILON sub i + | DELTA sub i | over 2 ,
where all variables are understood to pertain to the ith peer. Finally, assuming the ith peer is selected for synchronization, the system variables are determined as follows:
THETA = combined final offset , DELTA = DELTA sub i, EPSILON = EPSILON sub i + epsilon sub xi + | THETA | , LAMBDA = LAMBDA sub i ,
where epsilon sub xi is the select dispersion (see clock-selection procedure below).
Informal pseudo-code which accomplishes these computations is presented below. Note that the pseudo-code is represented in no particular language, although it has many similarities to the C language. Specific details on the important algorithms are further illustrated in the C-language routines in Appendix I.