indexpreviousnext

file name: algop.hpp, algop.cpp
author: Klaus Schossmaier
classification: simulation
contents: class COP, derived from class ACClockSyncAlgorithm
use: provides a convergence function that uses the optimal precision (OP) function to compute a new clock value and a new accuracy interval; the needed parameters for function OP are either provided as constants or computed
 

global items used by COP:


member variables of COP:

int cntDelay: Gives the number of transmission delay measurements after startup.
default and reset value: 0

double piHMinus: Parameter of function OP (negative part of maximal precision interval).

double piHPlus: Parameter of function OP (positive part of maximal precision interval).

double piOwnMinus: Parameter of function OP (negative part of own precision interval).

double piOwnPlus: Parameter of function OP (positive part of own precision interval).

double Ups: Parameter of function OP (maximal state correction).
 

member functions of COP:

COP (CClockSync *cs): This constructor function initializes the counter for the delay measurements, sets the resynchronization status of cs to True and calls ClockChanged() to initialize clock dependent data. If cs is NULL, an assert fails.

virtual void ClockChanged (): Initializes the deterioration and the accuracy interval maintained by the local clock, the precision intervals and maximal state correction to parameterize function OP. 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 sets the algorithm parameters either directly by using macros or computes their values with the help of various functions from class ACClockSyncAlgorithm and class CClockInterface. The clock is set 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, OP() is called with this network. If the function returns True, the resulting reference point and accuracy interval is stored in newClockValue, and timeValid is set to True. If there is no associated network, or if OP() 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 OP() has failed.
Note: If no associated network exists, OP() is not called and the database remains unchanged. If OP() is called and fails, all time intervals stored for the associated network are discarded.

virtual void Init(): Sets member cntDelay to its reset value and sets the resynchronization status of CS to True.

virtual EBool StoreTime (const STimestamp& time, double resync, SINT32 networkID, const CAddr& netAddress, int area, EBool gps): When CS is resynchronizing no time is stored and False is returned, otherwise StoreTime() of the base class is called with the input parameters and propagates its return value.

virtual EBool StoreDelay (double localDelay, double remoteDelay, const SRate& remoteRate, SINT32 networkID, const CAddr& netAddress): Counts the number of delay measurement rounds after startup in member cntDelay and sets the resynchronization status of CS to False if StartSynchronization rounds have passed (after that, the function stops counting). Calls StoreDelay() of the base class with the input parameters and propagates its return value.

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

EBool OP (CNtpTime& point, double& alpha_minus, double& alpha_plus, 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 preIntResult contains the new precision interval and accIntResult the new accuracy interval and parameters point, alpha_minus, alpha_plus are set to handback the result. If the computation has failed, False is returned.
Algorithm OP: The pre-processed precision intervals precisionIntervals[] and accuracy intervals accuracyIntervals[] are calculated from database, where in [0] the own ones are stored. The Marzullo function ApplyMarzullo() is applied on the precision intervals, the resulting interval preIntMarz is intersected with the own one, and the reference point is fixed, leading to preIntResult. The Marzullo function is applied on the accuracy intervals, the resulting interval accIntMarz is intersected with the own one, and extended to contain the reference point, leading to accIntResult. At last, the parameters point, alpha_minus, alpha_plus are set to the result.
Note: The debugging code to output the intervals on gnuplot-files can be (de)activated by (un)defining the according macros.
 

local items of the implementation file:

#define CloseAcc(): The macro closes the accuracy file if GNU_ACC is defined, and it evaluates to a null-statement otherwise.

#define CloseAdj(): The macro closes the adjustments file if GNU_ADJ is defined, and it evaluates to a null-statement otherwise.

#define CloseDet(): The macro closes the deteriorated accuracy file if GNU_DET is defined, and it evaluates to a null-statement otherwise.

#define ClosePre(): The macro closes the precision file if GNU_PRE is defined, and it evaluates to a null-statement otherwise.

const double EpsilonMinusInitial: Initial values for EpsilonMinus for the computation of the
precision intervals.

const double EpsilonPlusInitial: Initial values for EpsilonPlus for the computation of the
precision intervals.

#define GNU_ACC: Macro to produce debugging code for the output of accuracy intervals. The file is overwritten in each call to OP().

#define GNU_ADJ: Macro to produce debugging code for the output of adjustments. Each call to OP() appends data to the file.

#define GNU_DET: Macro to produce debugging code for the output of deteriorated accuracy intervals. Each call to OP() appends data to the file.

#define GNU_PRE: Macro to produce debugging code for the output of precision intervals. The file is overwritten in each call to OP().

#define NAME_ACC: Contains the filename for accuracy output (acc.dat).

#define NAME_ADJ: Contains the filename for adjustments output (adj.dat).

#define NAME_DET: Contains the filename for deteriorated accuracy output (det.dat).

#define NAME_PRE: Contains the filename for precision output (pre.dat).

#define PI_H_MINUS: Macro to define parameter of function OP (negative part of maximal precision interval).

#define PI_H_PLUS: Macro to define parameter of function OP (positive part of maximal precision interval).

#define PI_O_MINUS: Macro to define parameter of function OP (negative part of own precision interval).

#define PI_O_PLUS: Macro to define parameter of function OP (positive part of own precision interval).

Note: If PI_H_MINUS/PLUS is much larger than  PI_O_MINUS/PLUS the internal synchronization
becomes at least as bad as their difference.

const int StartSynchronization: Number of delay measurements before the algorithm starts
using the delay data in StoreTime().

#define UPSILON_MAX: Macro to define parameter of function OP (maximal state correction).
 


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