indexpreviousnext

file name: algmarz.hpp, algmarz.cpp
author: Klaus Schossmaier
classification: simulation
contents: class CMarzullo, derived from class ACClockSyncAlgorithm
use: provides a convergence function that uses the Marzullo's function to compute a new clock value and a new accuracy interval; no extra parameters are nedded for this function
 

global items used by CMarzullo:


member functions of CMarzullo:

CMarzullo (CClockSync *cs): This constructor function calls ClockChanged() to initialize the deterioration and accuracy interval maintained by the local clock. If cs is NULL, an assert fails.

virtual void ClockChanged (): Initializes the deterioration and the accuracy interval maintained by the local clock. The function first calls ClockChanged() of the base class to initialize the estimated rate. Then it calls GetClock() to get a pointer to the local clock. If GetClock() returns NULL, the function returns at this point. Otherwise, it computes the accuracy deterioration and the accuracy interval and sets the clock accordingly.
Note: When initializing the clock, set the deterioration of the accuracy intervals before their length.

virtual EBool ConvergenceFunction (): The function gets first the associated network calling GetAssociatedNetwork(). If it exists, Marzullo() is called with this network. If the function returns True, the resulting interval is stored in newClockValue, and timeValid is set to True. If there is no associated network, or if Marzullo() returns False, timeValid is set to False. The function returns True if a new timestamp could be computed (in that case, inherited function ReportInterval() is called with the resulting interval of the CV), False if no associated network exists or if Marzullo() has failed.
Note: If no associated network exists, Marzullo() is not called and the database remains unchanged. If Marzullo() is called and fails, all time intervals stored for the associated network are discarded.

static ACClockSyncAlgorithm *CreateMarzullo (CClockSync *cs): Creates a new object of type CMarzullo (passes cs to the ctor) and returns a pointer to it.

EBool Marzullo (STimeInterval& interval, SINT32 networkID): Computes the new clock interval for the network, uses the time intervals that are stored in database. All interval entries of the given network are then deleted. The function returns True if the computation was successful, in that case interval contains the new accuracy interval. If the computation has failed, False is returned.
Algorithm Marzullo: The pre-processed accuracy intervals accuracyIntervals[] are calculated from database. The Marzullo function is applied on the accuracy intervals, where the reference point is set to the midpoint, leading to accIntResult. At last,  interval.refpoint, interval.low, interval.high are set to that result.
Note: The debugging code to output the intervals on gnuplot-files can be (de)activated by (un)defining the according macro. In this case, the function writes its accuracy intervals (input intervals and result) to a file. Since the file only contains the data of the last call to Marzullo(), you have to set a breakpoint at the end of Marzullo() and check the file output for the calls to Marzullo() that you are interested in.
 

local items of the implementation file:

GNU_ACC_MARZ: Macro to produce debugging code for the output of accuracy intervals onto acc.dat.
 

local (static) functions of the implementation file:

SExtendedTimestamp IntervalToClock (STimeInterval& interval): Converts an interval of type STimeInterval into type SExtendedTimestamp, so that the clock can be adjusted within function ConvergenceFunction(). In case of an accuracy interval overflow, the according length is set to the limit of the accuracy value encoded by Infinity.
 


last modified: Fri Feb 5 18:55:57 1999