#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 |
| GlobalStatistics * | globalStatistics |
| std::map< NodeHandle, SimpleGameClient * > | Topology |
| cOutVector | cOV_NodeCount |
| cOutVector | cOV_ZeroMissingNeighbors |
| cOutVector | cOV_AverageMissingNeighbors |
| cOutVector | cOV_MaxMissingNeighbors |
| cOutVector | cOV_AverageDrift |
Definition at line 34 of file ConnectivityProbeApp.h.
| ConnectivityProbeApp::~ConnectivityProbeApp | ( | ) |
Definition at line 124 of file ConnectivityProbeApp.cc.
{
// destroy self timer messages
cancelAndDelete(probeTimer);
}
| 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);
SimpleGameClient* client;
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
extractTopology();
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);
RECORD_STATS (
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.
{
globalStatistics = GlobalStatisticsAccess().get();
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");
}
}
cOutVector ConnectivityProbeApp::cOV_AverageDrift [private] |
Definition at line 54 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbeApp::cOV_AverageMissingNeighbors [private] |
Definition at line 52 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbeApp::cOV_MaxMissingNeighbors [private] |
Definition at line 53 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbeApp::cOV_NodeCount [private] |
Definition at line 50 of file ConnectivityProbeApp.h.
Referenced by initialize().
cOutVector ConnectivityProbeApp::cOV_ZeroMissingNeighbors [private] |
Definition at line 51 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), and initialize().
Definition at line 44 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), and initialize().
simtime_t ConnectivityProbeApp::probeIntervall [private] |
Definition at line 42 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), and initialize().
cMessage* ConnectivityProbeApp::probeTimer [private] |
Definition at line 43 of file ConnectivityProbeApp.h.
Referenced by handleMessage(), initialize(), and ~ConnectivityProbeApp().
std::map<NodeHandle, SimpleGameClient*> ConnectivityProbeApp::Topology [private] |
Definition at line 45 of file ConnectivityProbeApp.h.
Referenced by extractTopology(), and handleMessage().
1.7.1