OverSim
ConnectivityProbeApp Class Reference

#include <ConnectivityProbeApp.h>

Public Member Functions

void initialize ()
void handleMessage (cMessage *msg)
 ~ConnectivityProbeApp ()

Private Member Functions

void extractTopology ()

Private Attributes

simtime_t probeIntervall
cMessage * probeTimer
GlobalStatisticsglobalStatistics
std::map< NodeHandle,
SimpleGameClient * > 
Topology
cOutVector cOV_NodeCount
cOutVector cOV_ZeroMissingNeighbors
cOutVector cOV_AverageMissingNeighbors
cOutVector cOV_MaxMissingNeighbors
cOutVector cOV_AverageDrift

Detailed Description

Definition at line 35 of file ConnectivityProbeApp.h.

Constructor & Destructor Documentation

ConnectivityProbeApp::~ConnectivityProbeApp ( )

Definition at line 124 of file ConnectivityProbeApp.cc.

{
// destroy self timer messages
cancelAndDelete(probeTimer);
}

Member Function Documentation

void ConnectivityProbeApp::extractTopology ( )
private

Definition at line 110 of file ConnectivityProbeApp.cc.

Referenced by handleMessage().

{
for(int i=0; i<=simulation.getLastModuleId(); i++) {
cModule* module = simulation.getModule(i);
if((client = dynamic_cast<SimpleGameClient*>(module))) {
if(client->isOverlayReady()) {
Topology.insert(std::make_pair(client->getThisNode(), client));
}
}
}
}
void ConnectivityProbeApp::handleMessage ( cMessage *  msg)

Definition at line 47 of file ConnectivityProbeApp.cc.

{
// fill topology with all modules
if(Topology.size() == 0) {
return;
}
// catch self timer messages
if(msg->isName("probeTimer")) {
//reset timer
cancelEvent(probeTimer);
scheduleAt(simTime() + probeIntervall, msg);
int mnMax = 0;
int mnZero = 0;
int driftCount = 0;
double mnAverage = 0.0;
double drift = 0.0;
for(std::map<NodeHandle, SimpleGameClient*>::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
int missing = 0;
Vector2D pos = itTopology->second->getPosition();
double AOIWidth = itTopology->second->getAOI();
for(std::map<NodeHandle, SimpleGameClient*>::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) {
if(itI != itTopology && pos.distanceSqr(itI->second->getPosition()) <= AOIWidth*AOIWidth) {
NeighborMap::iterator currentSite = itTopology->second->Neighbors.find(itI->second->getThisNode());
if(currentSite == itTopology->second->Neighbors.end()) {
++missing;
}
else {
drift += sqrt(currentSite->second.position.distanceSqr(itI->second->getPosition()));
++driftCount;
}
}
}
mnAverage += missing;
if(mnMax < missing) {
mnMax = missing;
}
if(missing == 0) {
++mnZero;
}
}
mnAverage /= (double)Topology.size();
if(driftCount > 0) {
drift /= (double)driftCount;
}
cOV_ZeroMissingNeighbors.record((double)mnZero);
globalStatistics->addStdDev("ConnectivityProbe: percentage zero missing neighbors", (double)mnZero * 100.0 / (double)Topology.size());
globalStatistics->addStdDev("ConnectivityProbe: average drift", drift);
);
cOV_AverageMissingNeighbors.record(mnAverage);
cOV_MaxMissingNeighbors.record((double)mnMax);
cOV_AverageDrift.record(drift);
}
Topology.clear();
}
void ConnectivityProbeApp::initialize ( )

Definition at line 29 of file ConnectivityProbeApp.cc.

{
probeIntervall = par("connectivityProbeIntervall");
probeTimer = new cMessage("probeTimer");
if(probeIntervall > 0.0) {
scheduleAt(simTime() + probeIntervall, probeTimer);
cOV_NodeCount.setName("total node count");
cOV_ZeroMissingNeighbors.setName("neighbor-error free nodes");
cOV_AverageMissingNeighbors.setName("average missing neighbors per node");
cOV_MaxMissingNeighbors.setName("largest missing neighbors count");
cOV_AverageDrift.setName("average drift");
}
}

Member Data Documentation

cOutVector ConnectivityProbeApp::cOV_AverageDrift
private

Definition at line 55 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeApp::cOV_AverageMissingNeighbors
private

Definition at line 53 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeApp::cOV_MaxMissingNeighbors
private

Definition at line 54 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbeApp::cOV_NodeCount
private

Definition at line 51 of file ConnectivityProbeApp.h.

Referenced by initialize().

cOutVector ConnectivityProbeApp::cOV_ZeroMissingNeighbors
private

Definition at line 52 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

GlobalStatistics* ConnectivityProbeApp::globalStatistics
private

Definition at line 45 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

simtime_t ConnectivityProbeApp::probeIntervall
private

Definition at line 43 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), and initialize().

cMessage* ConnectivityProbeApp::probeTimer
private

Definition at line 44 of file ConnectivityProbeApp.h.

Referenced by handleMessage(), initialize(), and ~ConnectivityProbeApp().

std::map<NodeHandle, SimpleGameClient*> ConnectivityProbeApp::Topology
private

Definition at line 46 of file ConnectivityProbeApp.h.

Referenced by extractTopology(), and handleMessage().


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