ConnectivityProbe Class Reference

#include <ConnectivityProbe.h>

List of all members.


Detailed Description

Definition at line 50 of file ConnectivityProbe.h.


Public Member Functions

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

Private Member Functions

void extractTopology ()
void resetTopologyNodes ()
unsigned int getComponentSize (OverlayKey key)

Private Attributes

std::fstream pltNetwork
std::fstream pltData
std::fstream pltVector
simtime_t probeIntervall
simtime_t plotIntervall
bool plotConnections
cMessage * probeTimer
cMessage * plotTimer
VTopology Topology
GlobalStatistics * globalStatistics
cOutVector cOV_NodeCount
cOutVector cOV_MaximumComponent
cOutVector cOV_MaxConnectivity
cOutVector cOV_ZeroMissingNeighbors
cOutVector cOV_AverageMissingNeighbors
cOutVector cOV_MaxMissingNeighbors
cOutVector cOV_AverageDrift

Constructor & Destructor Documentation

ConnectivityProbe::~ConnectivityProbe (  ) 

Definition at line 248 of file ConnectivityProbe.cc.

00249 {
00250     // destroy self timer messages
00251     cancelAndDelete(probeTimer);
00252     cancelAndDelete(plotTimer);
00253 }


Member Function Documentation

void ConnectivityProbe::initialize (  ) 

Definition at line 39 of file ConnectivityProbe.cc.

00040 {
00041     globalStatistics = GlobalStatisticsAccess().get();
00042     probeIntervall = par("connectivityProbeIntervall");
00043     plotIntervall = par("visualizeNetworkIntervall");
00044     probeTimer = new cMessage("probeTimer");
00045     plotTimer = new cMessage("plotTimer");
00046     plotConnections = par("plotConnections");
00047 
00048     if(probeIntervall > 0.0) {
00049         scheduleAt(simTime() + probeIntervall, probeTimer);
00050 
00051         cOV_NodeCount.setName("total node count");
00052         cOV_MaximumComponent.setName("largest connected component");
00053         cOV_MaxConnectivity.setName("connectivity in percent");
00054         cOV_ZeroMissingNeighbors.setName("neighbor-error free nodes");
00055         cOV_AverageMissingNeighbors.setName("average missing neighbors per node");
00056         cOV_MaxMissingNeighbors.setName("largest missing neighbors count");
00057         cOV_AverageDrift.setName("average drift");
00058     }
00059 
00060     if(plotIntervall > 0.0) {
00061         scheduleAt(simTime() + plotIntervall, plotTimer);
00062     }
00063 }

void ConnectivityProbe::handleMessage ( cMessage *  msg  ) 

Definition at line 65 of file ConnectivityProbe.cc.

00066 {
00067     // fill topology with all VAST modules
00068     extractTopology();
00069 
00070     if(Topology.size() == 0) {
00071         return;
00072     }
00073 
00074     // catch self timer messages
00075     if(msg->isName("probeTimer")) {
00076         //reset timer
00077         cancelEvent(probeTimer);
00078         scheduleAt(simTime() + probeIntervall, msg);
00079 
00080         unsigned int maxComponent = 0;
00081         for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
00082             unsigned int count = getComponentSize(itTopology->second.getModule()->getHandle().key);
00083             if(count > maxComponent) {
00084                 maxComponent = count;
00085             }
00086             resetTopologyNodes();
00087             if(count == Topology.size()) {
00088                 break;
00089             }
00090         }
00091 
00092         cOV_NodeCount.record((double)Topology.size());
00093         cOV_MaximumComponent.record((double)maxComponent);
00094         cOV_MaxConnectivity.record((double)maxComponent * 100.0 / (double)Topology.size());
00095         RECORD_STATS (
00096             globalStatistics->addStdDev("ConnectivityProbe: max connectivity", (double)maxComponent * 100.0 / (double)Topology.size());
00097         );
00098 
00099         int mnMax = 0;
00100         int mnZero = 0;
00101         int driftCount = 0;
00102         double mnAverage = 0.0;
00103         double drift = 0.0;
00104 
00105         for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
00106             double AOIWidthSqr = itTopology->second.getModule()->getAOI();
00107             AOIWidthSqr *= AOIWidthSqr;
00108             Vector2D vastPosition = itTopology->second.getModule()->getPosition();
00109             int missing = 0;
00110             for(VTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) {
00111                 if(itI != itTopology && vastPosition.distanceSqr(itI->second.getModule()->getPosition()) <= AOIWidthSqr) {
00112                     SiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getHandle());
00113                     if(currentSite == itTopology->second.getModule()->Sites.end()) {
00114                         ++missing;
00115                     }
00116                     else {
00117                         drift += sqrt(currentSite->second->coord.distanceSqr(itI->second.getModule()->getPosition()));
00118                         ++driftCount;
00119                     }
00120                 }
00121             }
00122 
00123             mnAverage += missing;
00124             if(mnMax < missing) {
00125                 mnMax = missing;
00126             }
00127             if(missing == 0) {
00128                 ++mnZero;
00129             }
00130         }
00131         mnAverage /= (double)Topology.size();
00132         if(driftCount > 0) {
00133             drift /= (double)driftCount;
00134         }
00135 
00136         cOV_ZeroMissingNeighbors.record((double)mnZero);
00137         RECORD_STATS (
00138             globalStatistics->addStdDev("ConnectivityProbe: percentage zero missing neighbors", (double)mnZero * 100.0 / (double)Topology.size());
00139         );
00140         cOV_AverageMissingNeighbors.record(mnAverage);
00141         cOV_MaxMissingNeighbors.record((double)mnMax);
00142         cOV_AverageDrift.record(drift);
00143     }
00144     else if(msg->isName("plotTimer")) {
00145          //reset timer
00146         cancelEvent(plotTimer);
00147         scheduleAt(simTime() + plotIntervall, msg);
00148 
00149         int range = (int)Topology.begin()->second.getModule()->getAreaDimension();
00150         std::stringstream oss;
00151         std::string filename;
00152         int simTimeInt, stellen = 1;
00153         simTimeInt = (int)SIMTIME_DBL(simTime());
00154         oss << "plot";
00155         for(int i=0; i<6; i++) {
00156             if(!(simTimeInt / stellen)) {
00157                 oss << "0";
00158             }
00159             stellen *= 10;
00160         }
00161         oss << simTimeInt;
00162 
00163         // open/ write plot file
00164         filename = oss.str() + ".plot";
00165         pltNetwork.open(filename.c_str(), std::ios::out);
00166         pltNetwork << "set xrange [0:" << range << "]" << endl;
00167         pltNetwork << "set yrange [0:" << range << "]" << endl;
00168         pltNetwork << "set nokey" << endl;
00169 
00170         // open point file
00171         filename = oss.str() + ".point";
00172         pltData.open(filename.c_str(), std::ios::out);
00173 
00174         pltNetwork << "plot '" << filename << "' using 1:2 with points pointtype 7,\\" << endl;
00175 
00176         // open vector file
00177         filename = oss.str() + ".arrow";
00178         pltVector.open(filename.c_str(), std::ios::out);
00179 
00180         pltNetwork << "     '" << filename << "' using 1:2:3:4 with vectors linetype 1" << endl;
00181         pltNetwork.close();
00182 
00183         // write point data file
00184         for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
00185             pltData << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << endl;
00186         }
00187         pltData.close();
00188 
00189         //write arrow data file
00190         for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
00191             for(SiteMap::iterator itSites = itTopology->second.getModule()->Sites.begin(); itSites != itTopology->second.getModule()->Sites.end(); ++itSites) {
00192                 if(plotConnections) {
00193                     VTopology::iterator destNode = Topology.find(itSites->second->addr.key);
00194                     if(destNode != Topology.end()) {
00195                         Vector2D relPos = destNode->second.getModule()->getPosition() - itTopology->second.getModule()->getPosition();
00196                         pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t"
00197                                   << relPos.x << "\t" << relPos.y << endl;
00198                     }
00199                 }
00200                 else {
00201                     Vector2D relPos = itSites->second->coord - itTopology->second.getModule()->getPosition();
00202                     pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t"
00203                               << relPos.x << "\t" << relPos.y << endl;
00204                 }
00205             }
00206         }
00207         pltVector.close();
00208     }
00209     Topology.clear();
00210 }

void ConnectivityProbe::extractTopology (  )  [private]

Definition at line 212 of file ConnectivityProbe.cc.

Referenced by handleMessage().

00213 {
00214     for(int i=0; i<=simulation.getLastModuleId(); i++) {
00215         cModule* module = simulation.getModule(i);
00216         if(module && dynamic_cast<Vast*>(module)) {
00217             Vast* vast = check_and_cast<Vast*>(module);
00218             if(vast->getState() == BaseOverlay::READY) {
00219                 VTopologyNode temp(i);
00220                 Topology.insert(std::make_pair(vast->getHandle().key, temp));
00221             }
00222         }
00223     }
00224 }

void ConnectivityProbe::resetTopologyNodes (  )  [private]

Definition at line 226 of file ConnectivityProbe.cc.

Referenced by handleMessage().

00227 {
00228     for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) {
00229         itTopology->second.visited = false;
00230     }
00231 }

unsigned int ConnectivityProbe::getComponentSize ( OverlayKey  key  )  [private]

Definition at line 233 of file ConnectivityProbe.cc.

Referenced by handleMessage().

00234 {
00235     VTopology::iterator itEntry = Topology.find(key);
00236     if(itEntry != Topology.end() && itEntry->second.visited == false) {
00237         int count = 1;
00238         itEntry->second.visited = true;
00239         Vast* vast = itEntry->second.getModule();
00240         for(SiteMap::iterator itSites = vast->Sites.begin(); itSites != vast->Sites.end(); ++itSites) {
00241             count += getComponentSize(itSites->first.key);
00242         }
00243         return count;
00244     }
00245     return 0;
00246 }


Member Data Documentation

std::fstream ConnectivityProbe::pltNetwork [private]

Definition at line 58 of file ConnectivityProbe.h.

Referenced by handleMessage().

std::fstream ConnectivityProbe::pltData [private]

Definition at line 58 of file ConnectivityProbe.h.

Referenced by handleMessage().

std::fstream ConnectivityProbe::pltVector [private]

Definition at line 58 of file ConnectivityProbe.h.

Referenced by handleMessage().

simtime_t ConnectivityProbe::probeIntervall [private]

Definition at line 63 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

simtime_t ConnectivityProbe::plotIntervall [private]

Definition at line 64 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 65 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

cMessage* ConnectivityProbe::probeTimer [private]

Definition at line 66 of file ConnectivityProbe.h.

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

cMessage* ConnectivityProbe::plotTimer [private]

Definition at line 67 of file ConnectivityProbe.h.

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

Definition at line 69 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

cOutVector ConnectivityProbe::cOV_NodeCount [private]

Definition at line 72 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 73 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 74 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 75 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 76 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 77 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().

Definition at line 78 of file ConnectivityProbe.h.

Referenced by handleMessage(), and initialize().


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

Generated on Wed Mar 25 16:32:52 2009 for OverSim by  doxygen 1.5.5