OverSim
GlobalStatistics Class Reference

Module to record global statistics. More...

#include <GlobalStatistics.h>

Classes

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

Public Member Functions

 ~GlobalStatistics ()
 Destructor.
void addStdDev (const std::string &name, double value)
 Add a new value to the cStdDev container specified by the name parameter.
void recordHistogram (const std::string &name, double value)
 Add a value to the histogram plot, or create a new histogram if one hasn't yet been created with name.
void recordOutVector (const std::string &name, double value)
 Record a value to a global cOutVector defined by name.
void startMeasuring ()
bool isMeasuring ()
bool getMeasureNetwInitPhase ()
simtime_t getMeasureStartTime ()
simtime_t calcMeasuredLifetime (simtime_t creationTime)
void finalizeStatistics ()

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

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 scalars
std::map< std::string,
cHistogram * > 
histogramMap
 map to store and access histograms
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
bool measureNetwInitPhase
simtime_t measureStartTime

Detailed Description

Module to record global statistics.

Author
Ingmar Baumgart

Definition at line 50 of file GlobalStatistics.h.

Constructor & Destructor Documentation

GlobalStatistics::~GlobalStatistics ( )

Destructor.

Definition at line 213 of file GlobalStatistics.cc.

{
// deallocate vectors
for (map<std::string, cStdDev*>::iterator it = stdDevMap.begin();
it != stdDevMap.end(); it++) {
delete it->second;
}
stdDevMap.clear();
for (map<std::string, OutVector*>::iterator it = outVectorMap.begin();
it != outVectorMap.end(); it++) {
delete it->second;
}
outVectorMap.clear();
for (map<std::string, cHistogram*>::iterator iter = histogramMap.begin();
iter != histogramMap.end(); iter++) {
delete iter->second;
}
histogramMap.clear();
}

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
namea string to identify the container (should be "Module: Scalar Name")
valuethe value to add

Definition at line 144 of file GlobalStatistics.cc.

Referenced by Quon::changeState(), Nps::coordsReqRpcResponse(), LoginCache::finish(), MessageObserver::finish(), SimpleTCP::finish(), SimpleUDP::finish(), MyApplication::finishApp(), SimpleGameClient::finishApp(), GIASearchApp::finishApp(), KBRTestApp::finishApp(), NeighborCache::finishApp(), Vast::finishOverlay(), Quon::finishOverlay(), MyOverlay::finishOverlay(), Gia::finishOverlay(), oversim::Nice::finishOverlay(), BasePastry::finishOverlay(), Kademlia::finishOverlay(), TreeManagement::finishTreeManagement(), Vivaldi::finishVivaldi(), ConnectivityProbeApp::handleMessage(), ConnectivityProbeQuon::handleMessage(), ConnectivityProbe::handleMessage(), Quon::handleNodeMove(), Vast::handleNodeMove(), GlobalViewBuilder::spreadGlobalView(), and DiscoveryMode::stop().

{
if (!measuring) {
return;
}
std::map<std::string, cStdDev*>::iterator sdPos = stdDevMap.find(name);
cStdDev* sd = NULL;
if (sdPos == stdDevMap.end()) {
Enter_Method_Silent();
sd = new cStdDev(name.c_str());
stdDevMap.insert(pair<std::string, cStdDev*>(name, sd));
} else {
sd = sdPos->second;
}
sd->collect(value);
}
simtime_t GlobalStatistics::calcMeasuredLifetime ( simtime_t  creationTime)
void GlobalStatistics::finalizeStatistics ( )

Definition at line 105 of file GlobalStatistics.cc.

Referenced by FinisherModule::finish().

{
recordScalar("GlobalStatistics: Simulation Time", simTime());
bool outputMinMax = par("outputMinMax");
bool outputStdDev = par("outputStdDev");
// record stats from other modules
for (map<std::string, cStdDev*>::iterator iter = stdDevMap.begin();
iter != stdDevMap.end(); iter++) {
const std::string& n = iter->first;
const cStatistic& stat = *(iter->second);
recordScalar((n + ".mean").c_str(), stat.getMean());
if (outputStdDev)
recordScalar((n + ".stddev").c_str(), stat.getStddev());
if (outputMinMax) {
recordScalar((n + ".min").c_str(), stat.getMin());
recordScalar((n + ".max").c_str(), stat.getMax());
}
}
for (map<std::string, cHistogram*>::iterator iter = histogramMap.begin();
iter != histogramMap.end(); iter++) {
const std::string& n = iter->first;
recordStatistic(n.c_str(), iter->second);
}
for (map<std::string, OutVector*>::iterator iter = outVectorMap.begin();
iter != outVectorMap.end(); iter++) {
const OutVector& ov = *(iter->second);
double mean = ov.count > 0 ? ov.value / ov.count : 0;
recordScalar(("Vector: " + iter->first + ".mean").c_str(), mean);
}
}
void GlobalStatistics::finish ( )
protectedvirtual

Finish member function of module.

Definition at line 94 of file GlobalStatistics.cc.

{
// Here, the FinisherModule is created which will get destroyed at last.
// This way, all other modules have sent their statistical data to the
// GobalStatisticModule before GlobalStatistics::finalizeStatistics()
// is called by FinisherModule::finish()
cModuleType* moduleType = cModuleType::get("oversim.common.FinisherModule");
moduleType->create("finisherModule", getParentModule()->getParentModule());
}
bool GlobalStatistics::getMeasureNetwInitPhase ( )
inline

Definition at line 91 of file GlobalStatistics.h.

Referenced by BasePastry::finishOverlay().

simtime_t GlobalStatistics::getMeasureStartTime ( )
inline

Definition at line 92 of file GlobalStatistics.h.

{ return measureStartTime; };
void GlobalStatistics::handleMessage ( cMessage *  msg)
protectedvirtual

HandleMessage member function of module.

Definition at line 66 of file GlobalStatistics.cc.

{
if (msg == globalStatTimer) {
// schedule next timer event
scheduleAt(simTime() + globalStatTimerInterval, msg);
double ratio;
// quick hack for live display of the current KBR delivery ratio
ratio = 0;
} else {
ratio = (double)deliveredKBRTestAppMessages /
}
if (ratio > 1) ratio = 1;
currentDeliveryVector.record(ratio);
return;
}
error("GlobalStatistics::handleMessage(): Unknown message type!");
}
void GlobalStatistics::initialize ( )
protectedvirtual

Init member function of module.

Definition at line 34 of file GlobalStatistics.cc.

{
measuring = measureNetwInitPhase = par("measureNetwInitPhase");
currentDeliveryVector.setName("Current Delivery Ratio");
// start periodic globalStatTimer
globalStatTimerInterval = par("globalStatTimerInterval");
globalStatTimer = new cMessage("globalStatTimer");
scheduleAt(simTime() + globalStatTimerInterval, globalStatTimer);
}
WATCH(measuring);
}
void GlobalStatistics::recordHistogram ( const std::string &  name,
double  value 
)

Add a value to the histogram plot, or create a new histogram if one hasn't yet been created with name.

Definition at line 164 of file GlobalStatistics.cc.

{
if (!measuring) {
return;
}
std::map<std::string, cHistogram*>::iterator hPos = histogramMap.find(name);
cHistogram* h = NULL;
if (hPos == histogramMap.end()) {
Enter_Method_Silent();
h = new cHistogram(name.c_str());
histogramMap.insert(pair<std::string, cHistogram*>(name, h));
} else {
h = hPos->second;
}
h->collect(value);
}
void GlobalStatistics::recordOutVector ( const std::string &  name,
double  value 
)

Record a value to a global cOutVector defined by name.

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

Definition at line 184 of file GlobalStatistics.cc.

Referenced by LifetimeChurn::createNode(), ParetoChurn::createNode(), LifetimeChurn::deleteNode(), ParetoChurn::deleteNode(), KBRTestApp::evaluateData(), Landmark::finishApp(), Kademlia::handleBucketRefreshTimerExpired(), KBRTestApp::handleLookupResponse(), SimpleGameClient::handleLowerMessage(), GlobalNodeList::handleMessage(), KBRTestApp::handleRpcResponse(), KBRTestApp::handleRpcTimeout(), ParetoChurn::initializeChurn(), and NeighborCache::recordNcsEstimationError().

{
if (!measuring) {
return;
}
std::map<std::string, OutVector*>::iterator ovPos =
outVectorMap.find(name);
OutVector* ov = NULL;
if (ovPos == outVectorMap.end()) {
Enter_Method_Silent();
ov = new OutVector(name);
outVectorMap.insert(pair<std::string, OutVector*>(name, ov));
} else {
ov = ovPos->second;
}
ov->vector.record(value);
ov->value += value;
ov->count++;
}
void GlobalStatistics::startMeasuring ( )

Definition at line 57 of file GlobalStatistics.cc.

Referenced by UnderlayConfigurator::handleMessage().

{
if (!measuring) {
measuring = true;
measureStartTime = simTime();
}
}

Member Data Documentation

cOutVector GlobalStatistics::currentDeliveryVector

statistical output vector for current delivery ratio

Definition at line 58 of file GlobalStatistics.h.

double GlobalStatistics::deliveredKBRTestAppMessages

total number of messages delivered by KBRTestApp

Definition at line 56 of file GlobalStatistics.h.

Referenced by KBRTestApp::evaluateData().

cMessage* GlobalStatistics::globalStatTimer
protected

timer for periodic statistic updates

Definition at line 114 of file GlobalStatistics.h.

double GlobalStatistics::globalStatTimerInterval
protected

interval length of periodic statistic timer

Definition at line 115 of file GlobalStatistics.h.

std::map<std::string, cHistogram*> GlobalStatistics::histogramMap
protected

map to store and access histograms

Definition at line 112 of file GlobalStatistics.h.

bool GlobalStatistics::measureNetwInitPhase
protected

Definition at line 133 of file GlobalStatistics.h.

Referenced by getMeasureNetwInitPhase().

simtime_t GlobalStatistics::measureStartTime
protected

Definition at line 134 of file GlobalStatistics.h.

Referenced by getMeasureStartTime().

bool GlobalStatistics::measuring
protected

Definition at line 132 of file GlobalStatistics.h.

Referenced by isMeasuring().

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

map to store and access the output vectors

Definition at line 113 of file GlobalStatistics.h.

double GlobalStatistics::sentKBRTestAppMessages

total number of messages sent by KBRTestApp

Definition at line 55 of file GlobalStatistics.h.

Referenced by KBRTestApp::handleTimerEvent().

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

map to store and access scalars

Definition at line 111 of file GlobalStatistics.h.

int GlobalStatistics::testCount

Definition at line 57 of file GlobalStatistics.h.


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