index previous next 

file name: netacc.hpp, netacc.cpp
classification: pure simulation
contents: class CNetworkAccountant
derived from: class CAccountant
use: provides a database for the storage of network transmission delays; the delays are associated with a pair of keys <SINT32 sender, SINT32 receiver>; the class can use its data to compute an arbitrary delay between two nodes

Note: the key is seen as an ordered tuple. Thus, if you enter delay data from node A to node B and then request an arbitrary delay for a message from B to A, the data of <A, B> is not considered.
 

global items used:

 
local (static) functions of the implementation file:

inline SINT32 GetNoAccount(): Returns NoAccount.
 
 
member variables:

EBool initCalled_: set to True by Init(), and to False by Dispose().
default and reset value: True

SINT32 networkID_: is used to initialize the random generator.
default: parameter networkID of the ctor

CRandom *random_: the random class used to generate random numbers.
default and reset value: a newly created random class with using the random stream specified by networkID
 
 
member functions:

CNetworkAccountant (SINT32 networkID): Stores the networkID, sets all members to their default values.

virtual ~CNetworkAccountant (): Deletes the dynamic members.

EBool DeleteNode (SINT32 nodeID): If entries for the node exist, all data concerning the node (whether as sender or as receiver) will be destroyed and the method will return True. If the node does not exist, False is returned.

virtual void Dispose(): If initCalled is True, all dynamic members are deleted and initCalled is set to False. All transmission data will be lost. If initCalled is already False, the function has no effect.

double GetArbitraryDelay (SINT32 senderID, SINT32 receiverID, EArrival& arrivalType): Returns a random transmission delay in the specified arrival interval. If arrivalType is equal to EArrivalCount, the interval is chosen according to the probabilities for early/late messages that are stored for the given pair of nodes.
Then, a random value is computed according to the data stored for the given arrival interval. Before the value is computed, the distribution data is checked to avoid inconsistencies which may have occured during the configuration. If there are inconsistencies, then they are either repaired (p.e., interval bounds are adjusted if possible) or the function returns NoAccount. The adjustments are not stored.
If there is no data stored for the pair of nodes, and if the senderID and receiverID are not equal, the method returns NoAccount. If the senderID and receiverID are the same, constant DefaultOwnDelay is returned. In any case, if there is no data stored, parameter arrival remains unchanged.

EBool GetDataParameter (SNetDistributionP2P *param): Returns True if the parameter has been read successfully. Calls GetDelay() to get the delay data. If the function fails, then False is returned. Otherwise, the parameter type is checked:

If the parameter type is not one of the three listed above, the function returns False.

virtual EBool GetParameter (SParameter& param) const: Returns True if the parameter could be read. If it does not say otherwise, the supported parameters assume that param is of the type SSingleNetworkParameter.

All other parameters are not supported, and False is returned.

double GetProbability (SNetworkData& param): Returns the probability of probType, or NoAccount if no entry exists.

virtual void Init (): If initCalled is False, the function creates all dynamic members and initializes all class members to default values (like in the ctor). initCalled is then set to True. If initCalled is already True, the function has no effect.

EBool IsConnected (SINT32 senderID, SINT32 receiverID): Returns True if an entry for the pair of nodes exists, otherwise False.

EBool SetDataParameter (const SNetDistributionP2P& param): Returns True if the parameter has been set successfully. The function first calls GetDelay() to get the data entry for the sender/receiver pair specified in param. The data entry is called delay in the text below.

If the parameter type is not one of the three listed above, False is returned.
Note: The order in which the three distribution parameters are set is important. For example, if the initial distribution values are all zero und you set the timely distribution first, then it will invalidate the fast interval and will report this. You can avoid this report if you set the fast interval first: this will set the upper bound of the fast interval to its correct value and set the lower bound to zero. If you then set the regular interval, it will still adapt the lower bound of the fast interval, but if you have specified a correct upper bound, then the interval will not be invalidated and just the lower bound will be set to its intended value.

virtual EBool SetParameter (const SParameter& param): Returns True if the parameter could be set. If it does not say otherwise, the supported parameters assume that param is of the type SSingleNetworkParameter.

All other parameters are not supported, and False is returned.

EBool SetProbability (SNetworkData& param): If param.value is not negative and if the sum of param.value and the stored value of the other probability is not greater than one, the function sets the stored arrival probability corresponding to param.type to param.value and returns True. Otherwise, it returns False and nothing happens.


last modified: Fri Feb 5 18:56:28 1999