GlobalStatistics Class Reference

Modul to record global statistics. More...

#include <GlobalStatistics.h>

List of all members.

Classes

struct  OutVector
 < struct for cOutVectors and cummulated values More...

Public Member Functions

 ~GlobalStatistics ()
 Destructor.
void doFinish ()
 Do the actual finish() call and record scalars needed because finish() gets called before all nodes have transmitted their data to GlobalStatistics.
void addStdDev (const std::string &name, double value)
 Add a new value to the cStdDev container specified by the name parameter.
void recordOutVector (const std::string &name, double value)
 record a value to a global cOutVector defined by name
void startMeasuring ()
bool isMeasuring ()
simtime_t getMeasureStartTime ()
simtime_t calcMeasuredLifetime (simtime_t creationTime)

Public Attributes

double sentKBRTestAppMessages
 total number of messages sent by KBRTestApp
double deliveredKBRTestAppMessages
 total number of messages delivered by KBRTestApp
int testCount
cOutVector currentDeliveryVector
 statistical output vector for current delivery ratio
int nodesInitialized
 nodes that have run initialize() and "registered" with GlobalStatistics
int nodesFinished
 nodes that have run finished() and have "deregistered" with GlobalStatistics

Static Public Attributes

static const double MIN_MEASURED = 0.1
 minimum useful measured lifetime in seconds

Protected Member Functions

virtual void initialize ()
 Init member function of module.
virtual void handleMessage (cMessage *msg)
 HandleMessage member function of module.
virtual void finish ()
 Finish member function of module.

Protected Attributes

std::map< std::string, cStdDev * > stdDevMap
 map to store and access the statistics data
std::map< std::string,
OutVector * > 
outVectorMap
 map to store and access the output vectors
cMessage * globalStatTimer
 timer for periodic statistic updates
double globalStatTimerInterval
 interval length of periodic statistic timer
bool measuring
simtime_t measureStartTime


Detailed Description

Modul to record global statistics.

Author:
Ingmar Baumgart

Definition at line 50 of file GlobalStatistics.h.


Constructor & Destructor Documentation

GlobalStatistics::~GlobalStatistics (  ) 

Destructor.

Definition at line 214 of file GlobalStatistics.cc.

00215 {
00216     // deallocate vectors
00217     for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin();
00218     iter != stdDevMap.end(); iter++) {
00219         delete iter->second;
00220     }
00221     stdDevMap.clear();
00222 
00223     for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin();
00224     iter != outVectorMap.end(); iter++) {
00225         delete iter->second;
00226     }
00227     outVectorMap.clear();
00228 }


Member Function Documentation

void GlobalStatistics::addStdDev ( const std::string &  name,
double  value 
)

Add a new value to the cStdDev container specified by the name parameter.

If the container does not exist yet, a new container is created

Parameters:
name a string to identify the container (should be "Module: Scalar Name")
value the value to add

Definition at line 137 of file GlobalStatistics.cc.

Referenced by Nps::coordsReqRpcResponse(), SimpleUDP::finish(), CryptoModule::finish(), BaseOverlay::finish(), BaseApp::finish(), SimMud::finishApp(), Scribe::finishApp(), NeighborCache::finishApp(), KBRTestApp::finishApp(), GIASearchApp::finishApp(), DHTTestApp::finishApp(), DHT::finishApp(), CBRDHT::finishApp(), Vast::finishOverlay(), Quon::finishOverlay(), PubSubMMOG::finishOverlay(), PubSubLobby::finishOverlay(), oversim::Koorde::finishOverlay(), Kademlia::finishOverlay(), Gia::finishOverlay(), oversim::Chord::finishOverlay(), Broose::finishOverlay(), BasePastry::finishOverlay(), Vivaldi::finishVivaldi(), DHTTestApp::handleGetResponse(), ConnectivityProbeQuon::handleMessage(), ConnectivityProbeApp::handleMessage(), ConnectivityProbe::handleMessage(), PubSubMMOG::handleMoveListMessage(), Vast::handleNodeMove(), Quon::handleNodeMove(), SimMud::handleOtherPlayerMove(), and DHTTestApp::handlePutResponse().

00138 {
00139     if (!measuring) {
00140         return;
00141     }
00142 
00143     std::map<std::string, cStdDev*>::iterator sdPos = stdDevMap.find(name);
00144     cStdDev* sd = NULL;
00145 
00146     if (sdPos == stdDevMap.end()) {
00147         Enter_Method_Silent();
00148         sd = new cStdDev(name.c_str());
00149         stdDevMap.insert(pair<std::string, cStdDev*>(name, sd));
00150     } else {
00151         sd = sdPos->second;
00152     }
00153 
00154     sd->collect(value);
00155 }

simtime_t GlobalStatistics::calcMeasuredLifetime ( simtime_t  creationTime  ) 

void GlobalStatistics::doFinish (  ) 

Do the actual finish() call and record scalars needed because finish() gets called before all nodes have transmitted their data to GlobalStatistics.

Definition at line 99 of file GlobalStatistics.cc.

Referenced by finish(), and BaseOverlay::finish().

00100 {
00101     if (nodesInitialized != nodesFinished) return;
00102 
00103     recordScalar("GlobalStatistics: Simulation Time", simTime());
00104 
00105     bool outputMinMax = par("outputMinMax");
00106     bool outputStdDev = par("outputStdDev");
00107 
00108     // record stats from other modules
00109     for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin();
00110     iter != stdDevMap.end(); iter++) {
00111 
00112         const std::string& n = iter->first;
00113         const cStatistic& stat = *(iter->second);
00114 
00115         recordScalar((n + ".mean").c_str(), stat.getMean());
00116 
00117         if (outputStdDev)
00118             recordScalar((n + ".stddev").c_str(), stat.getStddev());
00119 
00120         if (outputMinMax) {
00121             recordScalar((n + ".min").c_str(), stat.getMin());
00122             recordScalar((n + ".max").c_str(), stat.getMax());
00123         }
00124     }
00125 
00126     for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin();
00127     iter != outVectorMap.end(); iter++) {
00128 
00129         const OutVector& ov = *(iter->second);
00130 
00131         double mean = ov.count > 0 ? ov.value / ov.count : 0;
00132 
00133         recordScalar(("Vector: " + iter->first + ".mean").c_str(), mean);
00134     }
00135 }

void GlobalStatistics::finish (  )  [protected, virtual]

Finish member function of module.

Definition at line 94 of file GlobalStatistics.cc.

00095 {
00096     doFinish();
00097 }

simtime_t GlobalStatistics::getMeasureStartTime (  )  [inline]

Definition at line 95 of file GlobalStatistics.h.

00095 { return measureStartTime; };

void GlobalStatistics::handleMessage ( cMessage *  msg  )  [protected, virtual]

HandleMessage member function of module.

Definition at line 66 of file GlobalStatistics.cc.

00067 {
00068     if (msg == globalStatTimer) {
00069         // schedule next timer event
00070         scheduleAt(simTime() + globalStatTimerInterval, msg);
00071 
00072         double ratio;
00073 
00074         // quick hack for live display of the current KBR delivery ratio
00075         if (sentKBRTestAppMessages == 0) {
00076             ratio = 0;
00077         } else {
00078             ratio = (double)deliveredKBRTestAppMessages /
00079             (double)sentKBRTestAppMessages;
00080         }
00081 
00082         if (ratio > 1) ratio = 1;
00083 
00084         currentDeliveryVector.record(ratio);
00085         sentKBRTestAppMessages = 0;
00086         deliveredKBRTestAppMessages = 0;
00087 
00088         return;
00089     }
00090 
00091     error("GlobalStatistics::handleMessage(): Unknown message type!");
00092 }

void GlobalStatistics::initialize (  )  [protected, virtual]

Init member function of module.

Definition at line 32 of file GlobalStatistics.cc.

00033 {
00034     sentKBRTestAppMessages = 0;
00035     deliveredKBRTestAppMessages = 0;
00036 
00037     nodesInitialized = nodesFinished = 0;
00038 
00039     measuring = par("measureNetwInitPhase");
00040     measureStartTime = 0;
00041 
00042     currentDeliveryVector.setName("Current Delivery Ratio");
00043 
00044     // start periodic globalStatTimer
00045     globalStatTimerInterval = par("globalStatTimerInterval");
00046 
00047     if (globalStatTimerInterval > 0) {
00048         globalStatTimer = new cMessage("globalStatTimer");
00049         scheduleAt(simTime() + globalStatTimerInterval, globalStatTimer);
00050     }
00051 
00052     WATCH(measuring);
00053     WATCH(measureStartTime);
00054     WATCH(currentDeliveryVector);
00055 }

bool GlobalStatistics::isMeasuring (  )  [inline]

void GlobalStatistics::recordOutVector ( const std::string &  name,
double  value 
)

record a value to a global cOutVector defined by name

Parameters:
name a string to identify the vector (should be "Module: Scalar Name")
value the value to add

Definition at line 157 of file GlobalStatistics.cc.

Referenced by NeighborCache::calcRttError(), ParetoChurn::createNode(), LifetimeChurn::createNode(), ParetoChurn::deleteNode(), LifetimeChurn::deleteNode(), KBRTestApp::evaluateData(), Landmark::finishApp(), Kademlia::handleBucketRefreshTimerExpired(), KBRTestApp::handleLookupResponse(), GlobalNodeList::handleMessage(), GlobalDhtTestMap::handleMessage(), KBRTestApp::handleRpcResponse(), KBRTestApp::handleRpcTimeout(), oversim::Nice::handleTimerEvent(), oversim::Nice::handleUDPMessage(), ParetoChurn::initializeChurn(), and oversim::Nice::maintenance().

00159 {
00160     if (!measuring) {
00161         return;
00162     }
00163 
00164     std::map<std::string, OutVector*>::iterator ovPos =
00165         outVectorMap.find(name);
00166     OutVector* ov = NULL;
00167 
00168     if (ovPos == outVectorMap.end()) {
00169         Enter_Method_Silent();
00170         ov = new OutVector(name);
00171         outVectorMap.insert(pair<std::string, OutVector*>(name, ov));
00172     } else {
00173         ov = ovPos->second;
00174     }
00175 
00176     ov->vector.record(value);
00177     ov->value += value;
00178     ov->count++;
00179 
00180 #if 0
00181     // avg vector
00182     if (avg != -1) {
00183         std::string name_avg = name + "_avg";
00184         std::map<std::string, OutVector*>::iterator ovPos_avg =
00185             outVectorMap.find(name_avg);
00186         OutVector* ov_avg = NULL;
00187 
00188         if (ovPos_avg == outVectorMap.end()) {
00189             Enter_Method_Silent();
00190             ov_avg = new OutVector(name_avg);
00191             outVectorMap.insert(pair<std::string, OutVector*>(name_avg, ov_avg));
00192         } else {
00193             ov_avg = ovPos_avg->second;
00194         }
00195         int div = ((ov_avg->count >= avg) ? (avg - 1) : ov_avg->count);
00196         if (div <= 0) div = 1;
00197 
00198         double newValue = (ov_avg->avg * div + value) / (div + 1);
00199         ov_avg->vector.record(newValue);
00200         ov_avg->avg = newValue;
00201         ov_avg->value += newValue;
00202         ov_avg->count++;
00203     }
00204 #endif
00205 
00206 }

void GlobalStatistics::startMeasuring (  ) 

Definition at line 57 of file GlobalStatistics.cc.

Referenced by UnderlayConfigurator::handleMessage().

00058 {
00059     if (!measuring) {
00060         measuring = true;
00061         measureStartTime = simTime();
00062     }
00063 }


Member Data Documentation

statistical output vector for current delivery ratio

Definition at line 58 of file GlobalStatistics.h.

Referenced by handleMessage(), and initialize().

total number of messages delivered by KBRTestApp

Definition at line 56 of file GlobalStatistics.h.

Referenced by KBRTestApp::evaluateData(), handleMessage(), and initialize().

cMessage* GlobalStatistics::globalStatTimer [protected]

timer for periodic statistic updates

Definition at line 114 of file GlobalStatistics.h.

Referenced by handleMessage(), and initialize().

interval length of periodic statistic timer

Definition at line 115 of file GlobalStatistics.h.

Referenced by handleMessage(), and initialize().

simtime_t GlobalStatistics::measureStartTime [protected]

bool GlobalStatistics::measuring [protected]

const double GlobalStatistics::MIN_MEASURED = 0.1 [static]

nodes that have run finished() and have "deregistered" with GlobalStatistics

Definition at line 61 of file GlobalStatistics.h.

Referenced by doFinish(), BaseOverlay::finish(), and initialize().

nodes that have run initialize() and "registered" with GlobalStatistics

Definition at line 60 of file GlobalStatistics.h.

Referenced by doFinish(), initialize(), and BaseOverlay::initialize().

std::map<std::string, OutVector*> GlobalStatistics::outVectorMap [protected]

map to store and access the output vectors

Definition at line 113 of file GlobalStatistics.h.

Referenced by doFinish(), recordOutVector(), and ~GlobalStatistics().

total number of messages sent by KBRTestApp

Definition at line 55 of file GlobalStatistics.h.

Referenced by handleMessage(), KBRTestApp::handleTimerEvent(), and initialize().

std::map<std::string, cStdDev*> GlobalStatistics::stdDevMap [protected]

map to store and access the statistics data

Definition at line 112 of file GlobalStatistics.h.

Referenced by addStdDev(), doFinish(), and ~GlobalStatistics().

Definition at line 57 of file GlobalStatistics.h.


The documentation for this class was generated from the following files:

Generated on Tue Sep 8 17:26:58 2009 for OverSim by  doxygen 1.5.8