Skip to main content

2. Design of the Synchronization Algorithm

The synchronization algorithm is distributed in nature, with protocol peers maintained in every host on the network. Peers communicate with each other on a pairwise basis using special control messages, called Hello messages, exchanged periodically over the ordinary data links between them. The Hello messages contain information necessary for each host to calculate the delay and offset between the local clock of the host and the clock of every other host on the network and are also used to drive the routing algorithm.

The synchronization algorithm includes several features to improve the accuracy and stability of the local clock in the case of host or link failures. In following sections the design of the algorithm is summarized. Full design details are given in [5] along with a formal description of the Hello protocol.

2.1. The Logical Clock​

In the DCnet model each service point, or host, is equipped with a hardware clock, usually in the form of an off-the-shelf interface. Using this and software registers, a logical clock is constructed including a 48-bit Clock Register, which increments at a 1000 Hz rate, a 32-bit Clock-Adjust Register, which is used to slew the Clock Register in response to raw corrections received over the net, and a Counter Register, which is used in some interface designs as an auxilliary counter. The configuration and decimal point of these registers are shown in Figure 1.

           Clock Register

0 16 32
+---------------+---------------+---------------+
| | | |
+---------------+---------------+---------------+
A
decimal point

Clock-Adjust Register

0 16
+---------------+---------------+
| | |
+---------------+---------------+
A
decimal point

Counter Register

0 16
+---------------+
| |
+---------------+
A
decimal point

Figure 1. Clock Registers

The Clock Register and Clock-Adjust Register are implemented in memory. In typical clock interface designs such as the DEC KMV11-A the Counter Register is implemented in the interface as a buffered counter driven by a crystal oscillator. A counter overflow is signalled by an interrupt, which results in an increment of the Clock Register at bit 15 and the propagation of carries as required. The time of day is determined by reading the Counter Register, which does not disturb its counting process, and adding its value to that of the Clock Register with decimal points aligned.

In other interface designs such as the simple LSI-11 event-line mechanism, each tick of the clock is signalled by an interrupt at intervals of 10, 16-2/3 or 20 ms, depending on interface and clock source. When this occurs the appropriate number of milliseconds, expressed to 32 bits in precision, is added to the Clock Register with decimal points aligned.

It should be noted at this point that great care in operating system design is necessary in order to preserve the full accuracy of timestamps with respect to the application program, which must be protected from pre-emption, excessive device latencies and so forth. In addition, the execution times of all sequences operating with the interrupt system disabled must be strictly limited. Since the PDP11 operating system most often used in the DCnet (the "Fuzzball" operating system) has been constructed with these considerations foremost in mind, it has been especially useful for detailed network performance testing and evaluation. Other systems, in particular the various Unix systems, have not been found sufficiently accurate for this purpose.

Left uncorrected, the host logical clock runs at the rate of its intrinsic oscillator, whether derived from a crystal or the power frequency. The correction mechanism uses the Clock-Adjust Register, which is updated from time to time as raw corrections are received. The corrections are computed using roundtrip delays and offsets derived from the routing algorithm, described later in this document, which are relatively noisy compared to the precision of the logical clock. A carefully designed smoothing mechansim insures stability, as well as isolation from large transients that occur due to link retransmissions, host reboots and similar disruptions.

2.2. Linear Phase Adjustments​

The correction is introduced as a signed 32-bit integer in milliseconds. If the magnitude of the correction is less than 128 ms, the low-order 16 bits replaces bits 0-15 in the Clock-Adjust register. At suitable intervals, depending on the jitter of the intrinsic oscillator, the value of this register is divided by a fixed value, forming a quotient which is first added to the Clock Register, then subtracted from the Clock-Adjust Register. This technique has several advantages:

  1. The clock never runs backwards; that is, successive timestamps always increase monotonically.

  2. In the event of loss of correction information, the clock slews to the last correction received.

  3. The rate of slew is proportional to the magnitude of the last correction. This allows rapid settling in case of large corrections, but provides high stability in case of small corrections.

  4. The sequence of computations preserves the highest precision and minimizes the propagation of round-off errors.

Experience has indicated the choice of 256 as appropriate for the dividend above, which yields a maximum slew-rate magnitude less than 0.5 ms per adjustment interval and a granularity of about 2.0 microseconds, which is of the same order as the intrinsic tolerance of the crystal oscillators used in typical clock interfaces. In the case of crystal-derived clocks, an adjustment interval of four seconds has worked well, which yields a maximum slew-rate magnitude of 125 microseconds per second. In the case of power-frequency clocks or especially noisy links, the greatly increased jitter requires shorter adjustment intervals in the range of 0.5 second, which yields a maximum slew-rate magnitude of 1.0 ms per second.

In most cases, independent corrections are generated over each link at intervals of 30 seconds or less. Using the above choices a single sample error of 128 ms causes an error at the next sample interval no greater than about 7.5 ms with the longer adjustment interval and 30 ms with the shorter. The number of adjustment intervals to reduce the residual error by half is about 177, or about 12 minutes with the longer interval and about 1.5 minutes with the shorter. This completely characterizes the linear dynamics of the mechanism.

2.3. Nonlinear Phase Adjustments​

When the magnitude of the correction exceeds 128 ms, the possiblity exists that the clock is so far out of synchronization with the reference host that the best action is an immediate and wholesale replacement of Clock Register contents, rather than a graduated slewing as described above. In practice the necessity to do this is rare and occurs when the local host or reference host is rebooted, for example. This is fortunate, since step changes in the clock can result in the clock apparently running backward, as well as incorrect delay and offset measurements of the synchronization mechanism itself.

However, it sometimes happens that, due to link retransmissions or occasional host glitches, a single correction sample will be computed with magnitude exceeding 128 ms. In practice this happens often enough that a special procedure has been incorporated into the design. If a sample exceeding the limit is received, its value is saved temporarily and does not affect the Clock-Adjust Register. In addition, a timer is initialized, if not already running, to count down to zero in a specified time, currently 30 seconds.

If the timer is already running when a new correction sample with magnitude exceeeding 128 ms arrives, its value and the saved sample value are averaged with equal weights to form a new saved sample value. If a new correction sample arrives with magnitude less than 128 ms, the timer is stopped and the saved sample value discarded. If the timer counts down to zero, the saved sample value replaces the contents of the Clock Register and the Clock-Adjust Register is set to zero. This procedure has the effect that occasional spikes in correction values are discarded, but legitimate step changes are prefiltered and then used to reset the clock after no more than a 30-second delay.