#include <ConnectivityProbePR.h>
Definition at line 47 of file ConnectivityProbePR.h.
Public Member Functions | |
| void | initialize () |
| void | handleMessage (cMessage *msg) |
| ~ConnectivityProbePR () | |
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 |
| PRTopology | Topology |
| GlobalStatistics * | globalStatistics |
| cOutVector | cOV_NodeCount |
| cOutVector | cOV_MaximumComponent |
| cOutVector | cOV_MaxConnectivity |
| cOutVector | cOV_ZeroMissingNeighbors |
| cOutVector | cOV_AverageMissingNeighbors |
| cOutVector | cOV_MaxMissingNeighbors |
| cOutVector | cOV_AverageDrift |
| ConnectivityProbePR::~ConnectivityProbePR | ( | ) |
Definition at line 245 of file ConnectivityProbePR.cc.
00246 { 00247 // destroy self timer messages 00248 cancelAndDelete(probeTimer); 00249 cancelAndDelete(plotTimer); 00250 }
| void ConnectivityProbePR::initialize | ( | ) |
Definition at line 39 of file ConnectivityProbePR.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.0f) { 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 ConnectivityProbePR::handleMessage | ( | cMessage * | msg | ) |
Definition at line 65 of file ConnectivityProbePR.cc.
00066 { 00067 // fill topology with all QUONPR 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(PRTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00082 unsigned int count = getComponentSize(itTopology->second.getModule()->getKey()); 00083 if(count > maxComponent) { 00084 maxComponent = count; 00085 } 00086 if(count == Topology.size()) { 00087 break; 00088 } 00089 } 00090 00091 cOV_NodeCount.record((double)Topology.size()); 00092 cOV_MaximumComponent.record((double)maxComponent); 00093 cOV_MaxConnectivity.record((double)maxComponent * 100.0 / (double)Topology.size()); 00094 RECORD_STATS ( 00095 globalStatistics->addStdDev("ConnectivityProbe: max connectivity", (double)maxComponent * 100.0 / (double)Topology.size()); 00096 ); 00097 00098 int mnMax = 0; 00099 int mnZero = 0; 00100 int driftCount = 0; 00101 double mnAverage = 0.0; 00102 double drift = 0.0; 00103 00104 for(PRTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00105 QPRBoundingBox AOI(itTopology->second.getModule()->getPosition(), itTopology->second.getModule()->getAOI()); 00106 int missing = 0; 00107 for(PRTopology::iterator itI = Topology.begin(); itI != Topology.end(); ++itI) { 00108 if(itI != itTopology && AOI.collide(itI->second.getModule()->getPosition())) { 00109 PRSiteMap::iterator currentSite = itTopology->second.getModule()->Sites.find(itI->second.getModule()->getKey()); 00110 if(currentSite == itTopology->second.getModule()->Sites.end()) { 00111 ++missing; 00112 } 00113 else { 00114 drift += sqrt(currentSite->second->position.distanceSqr(itI->second.getModule()->getPosition())); 00115 ++driftCount; 00116 } 00117 } 00118 } 00119 00120 mnAverage += missing; 00121 if(mnMax < missing) { 00122 mnMax = missing; 00123 } 00124 if(missing == 0) { 00125 ++mnZero; 00126 } 00127 } 00128 mnAverage /= (double)Topology.size(); 00129 if(driftCount > 0) { 00130 drift /= (double)driftCount; 00131 } 00132 00133 cOV_ZeroMissingNeighbors.record((double)mnZero); 00134 RECORD_STATS ( 00135 globalStatistics->addStdDev("ConnectivityProbe: percentage zero missing neighbors", (double)mnZero * 100.0 / (double)Topology.size()); 00136 ); 00137 cOV_AverageMissingNeighbors.record(mnAverage); 00138 cOV_MaxMissingNeighbors.record((double)mnMax); 00139 cOV_AverageDrift.record(drift); 00140 } 00141 else if(msg->isName("plotTimer")) { 00142 //reset timer 00143 cancelEvent(plotTimer); 00144 scheduleAt(simTime() + plotIntervall, msg); 00145 00146 int range = (int)Topology.begin()->second.getModule()->getAreaDimension(); 00147 std::stringstream oss; 00148 std::string filename; 00149 int simTimeInt, stellen = 1; 00150 simTimeInt = (int)SIMTIME_DBL(simTime()); 00151 oss << "plot"; 00152 for(int i=0; i<6; i++) { 00153 if(!(simTimeInt / stellen)) { 00154 oss << "0"; 00155 } 00156 stellen *= 10; 00157 } 00158 oss << simTimeInt; 00159 00160 // open / write plot file 00161 filename = oss.str() + ".plot"; 00162 pltNetwork.open(filename.c_str(), std::ios::out); 00163 pltNetwork << "set xrange [0:" << range << "]" << endl; 00164 pltNetwork << "set yrange [0:" << range << "]" << endl; 00165 pltNetwork << "set nokey" << endl; 00166 00167 // open point file 00168 filename = oss.str() + ".point"; 00169 pltData.open(filename.c_str(), std::ios::out); 00170 00171 pltNetwork << "plot '" << filename << "' using 1:2 with points pointtype 7,\\" << endl; 00172 00173 // open vector file 00174 filename = oss.str() + ".arrow"; 00175 pltVector.open(filename.c_str(), std::ios::out); 00176 00177 pltNetwork << " '" << filename << "' using 1:2:3:4 with vectors linetype 1" << endl; 00178 pltNetwork.close(); 00179 00180 // write point data file 00181 for(PRTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00182 pltData << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << endl; 00183 } 00184 pltData.close(); 00185 00186 //write arrow data file 00187 for(PRTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00188 for(PRSiteMap::iterator itSites = itTopology->second.getModule()->Sites.begin(); itSites != itTopology->second.getModule()->Sites.end(); ++itSites) { 00189 if(plotConnections) { 00190 PRTopology::iterator destNode = Topology.find(itSites->second->address.key); 00191 if(destNode != Topology.end()) { 00192 Vector2D relPos = destNode->second.getModule()->getPosition() - itTopology->second.getModule()->getPosition(); 00193 pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t" 00194 << relPos.x << "\t" << relPos.y << endl; 00195 } 00196 } 00197 else { 00198 Vector2D relPos = itSites->second->position - itTopology->second.getModule()->getPosition(); 00199 pltVector << itTopology->second.getModule()->getPosition().x << "\t" << itTopology->second.getModule()->getPosition().y << "\t" 00200 << relPos.x << "\t" << relPos.y << endl; 00201 } 00202 } 00203 } 00204 pltVector.close(); 00205 } 00206 Topology.clear(); 00207 }
| void ConnectivityProbePR::extractTopology | ( | ) | [private] |
Definition at line 209 of file ConnectivityProbePR.cc.
Referenced by handleMessage().
00210 { 00211 for(int i=0; i<=simulation.getLastModuleId(); i++) { 00212 cModule* module = simulation.getModule(i); 00213 if(module && dynamic_cast<QuonPR*>(module)) { 00214 QuonPR* quonpr = check_and_cast<QuonPR*>(module); 00215 if(quonpr->getState() == QREADY) { 00216 PRTopologyNode temp(i); 00217 Topology.insert(std::make_pair(quonpr->getKey(), temp)); 00218 } 00219 } 00220 } 00221 }
| void ConnectivityProbePR::resetTopologyNodes | ( | ) | [private] |
Definition at line 223 of file ConnectivityProbePR.cc.
00224 { 00225 for(PRTopology::iterator itTopology = Topology.begin(); itTopology != Topology.end(); ++itTopology) { 00226 itTopology->second.visited = false; 00227 } 00228 }
| unsigned int ConnectivityProbePR::getComponentSize | ( | OverlayKey | key | ) | [private] |
Definition at line 230 of file ConnectivityProbePR.cc.
Referenced by handleMessage().
00231 { 00232 PRTopology::iterator itEntry = Topology.find(key); 00233 if(itEntry != Topology.end() && itEntry->second.visited == false) { 00234 int count = 1; 00235 itEntry->second.visited = true; 00236 QuonPR* quonpr = itEntry->second.getModule(); 00237 for(PRSiteMap::iterator itSites = quonpr->Sites.begin(); itSites != quonpr->Sites.end(); ++itSites) { 00238 count += getComponentSize(itSites->first); 00239 } 00240 return count; 00241 } 00242 return 0; 00243 }
std::fstream ConnectivityProbePR::pltNetwork [private] |
std::fstream ConnectivityProbePR::pltData [private] |
std::fstream ConnectivityProbePR::pltVector [private] |
simtime_t ConnectivityProbePR::probeIntervall [private] |
Definition at line 60 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
simtime_t ConnectivityProbePR::plotIntervall [private] |
Definition at line 61 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
bool ConnectivityProbePR::plotConnections [private] |
Definition at line 62 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cMessage* ConnectivityProbePR::probeTimer [private] |
Definition at line 63 of file ConnectivityProbePR.h.
Referenced by handleMessage(), initialize(), and ~ConnectivityProbePR().
cMessage* ConnectivityProbePR::plotTimer [private] |
Definition at line 64 of file ConnectivityProbePR.h.
Referenced by handleMessage(), initialize(), and ~ConnectivityProbePR().
PRTopology ConnectivityProbePR::Topology [private] |
Definition at line 65 of file ConnectivityProbePR.h.
Referenced by extractTopology(), getComponentSize(), handleMessage(), and resetTopologyNodes().
Definition at line 66 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_NodeCount [private] |
Definition at line 69 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_MaximumComponent [private] |
Definition at line 70 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_MaxConnectivity [private] |
Definition at line 71 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_ZeroMissingNeighbors [private] |
Definition at line 72 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_AverageMissingNeighbors [private] |
Definition at line 73 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_MaxMissingNeighbors [private] |
Definition at line 74 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
cOutVector ConnectivityProbePR::cOV_AverageDrift [private] |
Definition at line 75 of file ConnectivityProbePR.h.
Referenced by handleMessage(), and initialize().
1.5.5