#include <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 |
bool | plotMissing |
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 |
Definition at line 50 of file ConnectivityProbe.h.
ConnectivityProbe::~ConnectivityProbe | ( | ) |
Definition at line 293 of file ConnectivityProbe.cc.
00294 { 00295 // destroy self timer messages 00296 cancelAndDelete(probeTimer); 00297 cancelAndDelete(plotTimer); 00298 }
void ConnectivityProbe::extractTopology | ( | ) | [private] |
Definition at line 257 of file ConnectivityProbe.cc.
Referenced by handleMessage().
00258 { 00259 for(int i=0; i<=simulation.getLastModuleId(); i++) { 00260 cModule* module = simulation.getModule(i); 00261 if(module && dynamic_cast<Vast*>(module)) { 00262 Vast* vast = check_and_cast<Vast*>(module); 00263 if(vast->getState() == BaseOverlay::READY) { 00264 VTopologyNode temp(i); 00265 Topology.insert(std::make_pair(vast->getHandle().getKey(), temp)); 00266 } 00267 } 00268 } 00269 }
unsigned int ConnectivityProbe::getComponentSize | ( | OverlayKey | key | ) | [private] |
Definition at line 278 of file ConnectivityProbe.cc.
Referenced by handleMessage().
00279 { 00280 VTopology::iterator itEntry = Topology.find(key); 00281 if(itEntry != Topology.end() && itEntry->second.visited == false) { 00282 int count = 1; 00283 itEntry->second.visited = true; 00284 Vast* vast = itEntry->second.getModule(); 00285 for(SiteMap::iterator itSites = vast->Sites.begin(); itSites != vast->Sites.end(); ++itSites) { 00286 count += getComponentSize(itSites->first.getKey()); 00287 } 00288 return count; 00289 } 00290 return 0; 00291 }
void ConnectivityProbe::handleMessage | ( | cMessage * | msg | ) |
Definition at line 66 of file ConnectivityProbe.cc.
00067 { 00068 // fill topology with all VAST modules 00069 extractTopology(); 00070 00071 if(Topology.size() == 0) { 00072 return; 00073 } 00074 00075 // catch self timer messages 00076 if(msg->isName("probeTimer")) { 00077 //reset timer 00078 cancelEvent(probeTimer); 00079 scheduleAt(simTime() + probeIntervall, msg); 00080 00081 unsigned int maxComponent = 0; 00082 for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00083 unsigned int count = getComponentSize(itTopology->second.getModule()->getHandle().getKey()); 00084 if(count > maxComponent) { 00085 maxComponent = count; 00086 } 00087 resetTopologyNodes(); 00088 if(count == Topology.size()) { 00089 break; 00090 } 00091 } 00092 00093 cOV_NodeCount.record((double)Topology.size()); 00094 cOV_MaximumComponent.record((double)maxComponent); 00095 cOV_MaxConnectivity.record((double)maxComponent * 100.0 / (double)Topology.size()); 00096 RECORD_STATS ( 00097 globalStatistics->addStdDev("ConnectivityProbe: max connectivity", (double)maxComponent * 100.0 / (double)Topology.size()); 00098 ); 00099 00100 int mnMax = 0; 00101 int mnZero = 0; 00102 int driftCount = 0; 00103 double mnAverage = 0.0; 00104 double drift = 0.0; 00105 00106 for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00107 double AOIWidthSqr = itTopology->second.getModule()->getAOI(); 00108 AOIWidthSqr *= AOIWidthSqr; 00109 Vector2D vastPosition = itTopology->second.getModule()->getPosition(); 00110 int missing = 0; 00111 for(VTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) { 00112 if(itI != itTopology && vastPosition.distanceSqr(itI->second.getModule()->getPosition()) <= AOIWidthSqr) { 00113 SiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getHandle()); 00114 if(currentSite == itTopology->second.getModule()->Sites.end()) { 00115 ++missing; 00116 } 00117 else { 00118 drift += sqrt(currentSite->second->coord.distanceSqr(itI->second.getModule()->getPosition())); 00119 ++driftCount; 00120 } 00121 } 00122 } 00123 00124 mnAverage += missing; 00125 if(mnMax < missing) { 00126 mnMax = missing; 00127 } 00128 if(missing == 0) { 00129 ++mnZero; 00130 } 00131 } 00132 mnAverage /= (double)Topology.size(); 00133 if(driftCount > 0) { 00134 drift /= (double)driftCount; 00135 } 00136 00137 cOV_ZeroMissingNeighbors.record((double)mnZero); 00138 RECORD_STATS ( 00139 globalStatistics->addStdDev("ConnectivityProbe: percentage zero missing neighbors", (double)mnZero * 100.0 / (double)Topology.size()); 00140 globalStatistics->addStdDev("ConnectivityProbe: average drift", drift); 00141 ); 00142 cOV_AverageMissingNeighbors.record(mnAverage); 00143 cOV_MaxMissingNeighbors.record((double)mnMax); 00144 cOV_AverageDrift.record(drift); 00145 } 00146 else if(msg->isName("plotTimer")) { 00147 //reset timer 00148 cancelEvent(plotTimer); 00149 scheduleAt(simTime() + plotIntervall, msg); 00150 00151 bool missingFound = false; 00152 if(plotMissing) { 00153 for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00154 double AOIWidthSqr = itTopology->second.getModule()->getAOI(); 00155 AOIWidthSqr *= AOIWidthSqr; 00156 Vector2D vastPosition = itTopology->second.getModule()->getPosition(); 00157 for(VTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) { 00158 if(itI != itTopology && vastPosition.distanceSqr(itI->second.getModule()->getPosition()) <= AOIWidthSqr) { 00159 SiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getHandle()); 00160 if(currentSite == itTopology->second.getModule()->Sites.end()) { 00161 missingFound=true; 00162 } 00163 } 00164 } 00165 } 00166 } 00167 00168 if(!plotMissing || missingFound) { 00169 00170 int range = (int)Topology.begin()->second.getModule()->getAreaDimension(); 00171 std::stringstream oss; 00172 std::string filename; 00173 int simTimeInt, stellen = 1; 00174 simTimeInt = (int)SIMTIME_DBL(simTime()); 00175 oss << "plot"; 00176 for(int i=0; i<6; i++) { 00177 if(!(simTimeInt / stellen)) { 00178 oss << "0"; 00179 } 00180 stellen *= 10; 00181 } 00182 oss << simTimeInt; 00183 00184 // open/ write plot file 00185 filename = oss.str() + ".plot"; 00186 pltNetwork.open(filename.c_str(), std::ios::out); 00187 pltNetwork << "set xrange [0:" << range << "]" << endl; 00188 pltNetwork << "set yrange [0:" << range << "]" << endl; 00189 pltNetwork << "set nokey" << endl; 00190 00191 // open point file 00192 filename = oss.str() + ".point"; 00193 pltData.open(filename.c_str(), std::ios::out); 00194 00195 pltNetwork << "plot '" << filename << "' using 1:2 with points pointtype 7,\\" << endl; 00196 00197 // open vector file 00198 filename = oss.str() + ".arrow"; 00199 pltVector.open(filename.c_str(), std::ios::out); 00200 00201 pltNetwork << " '" << filename << "' using 1:2:3:4 with vectors linetype 1" << endl; 00202 pltNetwork.close(); 00203 00204 // write point data file 00205 for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00206 pltData << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << endl; 00207 } 00208 pltData.close(); 00209 00210 //write arrow data file 00211 if(!plotMissing) { 00212 for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00213 for(SiteMap::iterator itSites = itTopology->second.getModule()->Sites.begin(); itSites != itTopology->second.getModule()->Sites.end(); ++itSites) { 00214 if(plotConnections) { 00215 VTopology::iterator destNode = Topology.find(itSites->second->addr.getKey()); 00216 if(destNode != Topology.end()) { 00217 Vector2D relPos = destNode->second.getModule()->getPosition() - itTopology->second.getModule()->getPosition(); 00218 pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t" 00219 << relPos.x << "\t" << relPos.y << endl; 00220 } 00221 } 00222 else { 00223 Vector2D relPos = itSites->second->coord - itTopology->second.getModule()->getPosition(); 00224 pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t" 00225 << relPos.x << "\t" << relPos.y << endl; 00226 } 00227 } 00228 } 00229 } else { 00230 for(VTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00231 double AOIWidthSqr = itTopology->second.getModule()->getAOI(); 00232 AOIWidthSqr *= AOIWidthSqr; 00233 Vector2D vastPosition = itTopology->second.getModule()->getPosition(); 00234 for(VTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) { 00235 if(itI != itTopology && vastPosition.distanceSqr(itI->second.getModule()->getPosition()) <= AOIWidthSqr) { 00236 SiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getHandle()); 00237 if(currentSite == itTopology->second.getModule()->Sites.end()) { 00238 Vector2D relPos = itI->second.getModule()->getPosition() - itTopology->second.getModule()->getPosition(); 00239 pltVector << itTopology->second.getModule()->getPosition().x << "\t" 00240 << itTopology->second.getModule()->getPosition().y << "\t" 00241 << relPos.x << "\t" << relPos.y << "\t" 00242 << itTopology->second.getModule()->getParentModule()->getParentModule()->getFullName() << ":" 00243 << itTopology->second.getModule()->thisSite.addr.getKey().toString(16) << "\t" 00244 << itI->second.getModule()->getParentModule()->getParentModule()->getFullName() << ":" 00245 << itI->second.getModule()->thisSite.addr.getKey().toString(16) << endl; 00246 } 00247 } 00248 } 00249 } 00250 } 00251 pltVector.close(); 00252 } 00253 } 00254 Topology.clear(); 00255 }
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 plotMissing= par("plotMissing"); 00048 00049 if(probeIntervall > 0.0) { 00050 scheduleAt(simTime() + probeIntervall, probeTimer); 00051 00052 cOV_NodeCount.setName("total node count"); 00053 cOV_MaximumComponent.setName("largest connected component"); 00054 cOV_MaxConnectivity.setName("connectivity in percent"); 00055 cOV_ZeroMissingNeighbors.setName("neighbor-error free nodes"); 00056 cOV_AverageMissingNeighbors.setName("average missing neighbors per node"); 00057 cOV_MaxMissingNeighbors.setName("largest missing neighbors count"); 00058 cOV_AverageDrift.setName("average drift"); 00059 } 00060 00061 if(plotIntervall > 0.0) { 00062 scheduleAt(simTime() + plotIntervall, plotTimer); 00063 } 00064 }
void ConnectivityProbe::resetTopologyNodes | ( | ) | [private] |
Definition at line 271 of file ConnectivityProbe.cc.
Referenced by handleMessage().
cOutVector ConnectivityProbe::cOV_AverageDrift [private] |
Definition at line 79 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbe::cOV_AverageMissingNeighbors [private] |
Definition at line 77 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbe::cOV_MaxConnectivity [private] |
Definition at line 75 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbe::cOV_MaximumComponent [private] |
Definition at line 74 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbe::cOV_MaxMissingNeighbors [private] |
Definition at line 78 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbe::cOV_NodeCount [private] |
Definition at line 73 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbe::cOV_ZeroMissingNeighbors [private] |
Definition at line 76 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
Definition at line 70 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
bool ConnectivityProbe::plotConnections [private] |
Definition at line 65 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().
bool ConnectivityProbe::plotMissing [private] |
Definition at line 66 of file ConnectivityProbe.h.
Referenced by handleMessage(), and initialize().
cMessage* ConnectivityProbe::plotTimer [private] |
Definition at line 68 of file ConnectivityProbe.h.
Referenced by handleMessage(), initialize(), and ~ConnectivityProbe().
std::fstream ConnectivityProbe::pltData [private] |
Definition at line 58 of file ConnectivityProbe.h.
Referenced by handleMessage().
std::fstream ConnectivityProbe::pltNetwork [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().
cMessage* ConnectivityProbe::probeTimer [private] |
Definition at line 67 of file ConnectivityProbe.h.
Referenced by handleMessage(), initialize(), and ~ConnectivityProbe().
VTopology ConnectivityProbe::Topology [private] |
Definition at line 69 of file ConnectivityProbe.h.
Referenced by extractTopology(), getComponentSize(), handleMessage(), and resetTopologyNodes().