79 minJitter(SIMTIME_MAX),
94 cerr <<
"Messages should not arrive unordered";
100 simtime_t delay = h_delay + p_delay;
122 if(jitter < 0) { jitter = -jitter; }
141 void IListener::initialize() {
142 this->getParentModule()->subscribe(
"ModularSignal", &module);
143 this->getParentModule()->subscribe(
"InfectionSignal", &module);
145 cXMLElement* Xml = NULL;
146 if (par(
"data").xmlValue() != NULL && par(
"data").xmlValue()->hasChildren()){
147 Xml = par(
"data").xmlValue();
148 }
else { error(
"data parameter not initialized!"); }
151 cXMLElementList QoSs = Xml->getChildrenByTagName(
"qos");
152 for(cXMLElement * n : QoSs) {
153 if (!n->getAttribute(
"name")) {
154 EV <<
"Error parsing Infected QoS. Its name is missing!" << endl;
157 if (!n->getAttribute(
"delay")) {
158 EV <<
"Error parsing Infected QoS. Its delay is missing!" << endl;
161 if (!n->getAttribute(
"jitter")) {
162 EV <<
"Error parsing Infected QoS. Its jitter is missing!" << endl;
166 string name = n->getAttribute(
"name");
167 double delay = atof(n->getAttribute(
"delay"))/1000.0;
168 double jitter = atof(n->getAttribute(
"jitter"))/1000.0;
170 EV <<
"Error parsing Infected QoS. Its name is empty!" << endl;
174 EV <<
"Error parsing Infected QoS. Its delay <=0!" << endl;
178 EV <<
"Error parsing Infected QoS. Its jitter <=0!" << endl;
182 module.QoS.insert(name);
183 module.QoSDelay[name] = delay;
184 module.QoSJitter[name] = jitter;
187 h_delayV = par(
"mtu").longValue()/1500.0;
188 module.h_delayV = h_delayV;
194 if(
HopDelayMsg * m = dynamic_cast<HopDelayMsg*>(obj)) {
198 }
else if(
HopRcvMsg * m = dynamic_cast<HopRcvMsg*>(obj) ) {
202 }
else if(
HopLossMsg * m = dynamic_cast<HopLossMsg*>(obj) ) {
206 }
else if(
SendInfMsg * m = dynamic_cast<SendInfMsg*>(obj) ) {
208 flowId fId(m->src, m->dst, m->srcCepId, m->qos);
210 }
else if(
RecvInfMsg * m = dynamic_cast<RecvInfMsg*>(obj)) {
211 flowId fId(m->src, m->dst, m->src_cepID, m->qos);
217 out <<
"Processed per hop :: " << endl;
218 for(
string qos :
QoS) {
219 out <<
"\tQoS :: " << qos << endl;
221 out <<
"\t\tProcessed/Dropped : "
226 out <<
"\t\tHop Delay : "
234 for(
string qos :
QoS) {
235 out <<
"QoS," << qos << endl;
236 out <<
"RCV, DROP, DROP %,,AVG PK W, MAX PK W,,DIST PK WT:";
237 for(
int i = 0; i<4000;) {
239 if(i < 10) { i += 1; }
240 else if(i < 100) { i += 10; }
245 out << mI.second.rcv <<
246 "," << mI.second.drop <<
247 "," <<
Idround(100.0*mI.second.drop/(
double)mI.second.rcv, 4) <<
248 ",," <<
Idround(mI.second.sumDel/(
double)mI.second.countDel, 4) <<
249 "," << mI.second.maxDel <<
",,";
253 for(
auto wt : mI.second.distDel) {
254 while(wt.first > cWT) {
256 if(cWT < 10) { cWT += 1; }
257 else if(cWT < 100) { cWT += 10; }
264 }
else if(wt.first == cWT) {
267 if(cWT < 10) { cWT += 1; }
268 else if(cWT < 100) { cWT += 10; }
275 out <<
"QoS," << qos << endl << endl;
279 out <<
"QoS,*" << endl;
280 out <<
"RCV, DROP, DROP %,,AVG PK W, MAX PK W,,DIST PK WT:";
281 for(
int i = 0; i<4000;) {
283 if(i < 10) { i += 1; }
284 else if(i < 100) { i += 10; }
289 out << mI.second.rcv <<
290 "," << mI.second.drop <<
291 "," <<
Idround(100.0*mI.second.drop/(
double)mI.second.rcv, 4) <<
292 ",," <<
Idround(mI.second.sumDel/(
double)mI.second.countDel, 4) <<
293 "," << mI.second.maxDel <<
",,";
297 for(
auto wt : mI.second.distDel) {
298 while(wt.first > cWT) {
300 if(cWT < 10) { cWT += 1; }
301 else if(cWT < 100) { cWT += 10; }
308 }
else if(wt.first == cWT) {
311 if(cWT < 10) { cWT += 1; }
312 else if(cWT < 100) { cWT += 10; }
319 out <<
"QoS,*" << endl << endl;
324 out <<
"QoS,,RCV, DROP, DROP %,,AVG PK W, MAX PK W,,DIST PK WT:";
325 for(
int i = 0; i<=5000;) {
327 if(i < 10) { i += 1; }
328 else if(i < 100) { i += 10; }
332 for(
string qos :
QoS) {
342 "," <<
Idround(100.0*mI.drop/(
double)rcv, 4) <<
343 ",," <<
Idround(mI.sumDel/(
double)mI.countDel, 4) <<
349 for(
auto wt : mI.distDel) {
350 while(wt.first > cWT) {
352 if(cWT < 10) { cWT += 1; }
353 else if(cWT < 100) { cWT += 10; }
360 }
else if(wt.first == cWT) {
363 if(cWT < 10) { cWT += 1; }
364 else if(cWT < 100) { cWT += 10; }
377 out <<
"QoS,,RCV, DROP, DROP %,,AVG PK W, MAX PK W,,DIST PK WT:";
378 for(
int i = 0; i<=5000;) {
380 if(i == 0) { i = 10; }
381 else if(i == 10) { i = 50; }
382 else if(i == 50) { i = 100; }
383 else if(i == 100) { i = 500; }
384 else if(i == 500) { i = 1000; }
388 for(
string qos : QoS) {
398 "," <<
Idround(100.0*mI.drop/(
double)rcv, 4) <<
399 ",," <<
Idround(mI.sumDel/(
double)mI.countDel, 4) <<
405 for(
auto wt : mI.distDel) {
406 while(wt.first > cWT) {
408 if(cWT == 0) { cWT = 10; }
409 else if(cWT == 10) { cWT = 50; }
410 else if(cWT == 50) { cWT = 100; }
411 else if(cWT == 100) { cWT = 500; }
412 else if(cWT == 500) { cWT = 1000; }
413 else { cWT += 1000; }
419 }
else if(wt.first == cWT) {
422 if(cWT == 0) { cWT = 10; }
423 else if(cWT == 10) { cWT = 50; }
424 else if(cWT == 50) { cWT = 100; }
425 else if(cWT == 100) { cWT = 500; }
426 else if(cWT == 500) { cWT = 1000; }
427 else { cWT += 1000; }
438 for(
string qos :
QoS) {
439 out <<
"QoS," << qos << endl;
440 out <<
"SRC, DST, CEPID,,SEND, DROP, DROP %,,MIN DELAY,AVG DELAY,MAX DELAY,,MIN JITTER,AVG JITTER,MAX JITTER";
443 out << mI.first.src <<
444 ","<< mI.first.dst <<
445 ","<< mI.first.srcCepId <<
446 ",," << mI.second.snd <<
447 "," << (mI.second.snd - mI.second.rcv) <<
448 "," << 100.0*(mI.second.snd - mI.second.rcv)/(double)mI.second.snd <<
449 ",," << 1000*mI.second.minDel.dbl() <<
450 "," << 1000*mI.second.sumDel.dbl()/(double)mI.second.countDel <<
451 "," << 1000*mI.second.maxDel.dbl() <<
452 ",," << 1000*mI.second.minJitter.dbl() <<
453 "," << 1000*mI.second.sumJit.dbl()/(double)mI.second.countJit <<
454 "," << 1000*mI.second.maxJitter.dbl() <<
457 out <<
"QoS," << qos << endl << endl;
462 map<string, map<string, map<string, flowInfo> > > qos_src_dst_fInfo;
463 set<simtime_t> delays, jitters;
466 for(
string qos :
QoS) {
469 flowInfo & fI = qos_src_dst_fInfo[qos][mI.first.src][mI.first.dst];
476 fI.
distDel[d.first] += d.second;
477 delays.insert(d.first);
485 fI.
distJit[d.first] += d.second;
486 delays.insert(d.first);
493 consDrops.insert(d.first);
498 for(
string qos : QoS) {
499 out <<
"QoS," << qos << endl;
500 out <<
"SRC, DST,,SEND, DROP, DROP %,,MIN DELAY,AVG DELAY,MAX DELAY,,MIN JITTER,AVG JITTER,MAX JITTER";
502 for(
auto & src_ : qos_src_dst_fInfo[qos]) {
503 string src = src_.first;
504 for(
auto & dst_ : src_.second) {
505 string dst = dst_.first;
512 "," << (mI.
snd - mI.
rcv) <<
513 "," << 100.0*(mI.
snd - mI.
rcv)/(double)mI.
snd <<
514 ",," << 1000*mI.
minDel.dbl() <<
516 "," << 1000*mI.
maxDel.dbl() <<
526 for(
string qos : QoS) {
527 outb <<
"QoS," << qos << endl;
528 outb <<
"SRC, DST,,SEND, DROP, DROP %,, DROPs";
529 for(
auto & d : consDrops) { outb <<
"," <<d; }
531 for(
auto & src_ : qos_src_dst_fInfo[qos]) {
532 string src = src_.first;
533 for(
auto & dst_ : src_.second) {
534 string dst = dst_.first;
540 "," << (mI.
snd - mI.
rcv) <<
541 "," << 100.0*(mI.
snd - mI.
rcv)/(double)mI.
snd <<
543 for(
auto & d : consDrops) {
553 for(
string qos :
QoS) {
554 out <<
"QoS," << qos << endl;
555 out <<
"SRC, DST, CEPID,,SEND, DROP, DROP %,,MIN DELAY,AVG DELAY,MAX DELAY,,MIN JITTER,AVG JITTER,MAX JITTER";
558 out << mI.first.src <<
559 ","<< mI.first.dst <<
560 ","<< mI.first.srcCepId <<
561 ",," << mI.second.snd <<
562 "," << (mI.second.snd - mI.second.rcv) <<
563 "," << 100.0*(mI.second.snd - mI.second.rcv)/(double)mI.second.snd <<
564 ",," << mI.second.minPST <<
565 "," << mI.second.sumPST/(
double)mI.second.countPST <<
566 "," << mI.second.maxPST <<
569 out <<
"QoS," << qos << endl << endl;
574 map<string, map<string, map<string, flowInfo> > > qos_src_dst_fInfo;
578 for(
string qos :
QoS) {
581 flowInfo & fI = qos_src_dst_fInfo[qos][mI.first.src][mI.first.dst];
588 fI.
distPST[d.first] += d.second;
589 delays.insert(d.first);
596 consDrops.insert(d.first);
601 for(
string qos : QoS) {
602 out <<
"QoS," << qos << endl;
603 out <<
"SRC, DST,,SEND, DROP, DROP %,,MIN DELAY,AVG DELAY,MAX DELAY,,MIN JITTER,AVG JITTER,MAX JITTER";
605 for(
auto & src_ : qos_src_dst_fInfo[qos]) {
606 string src = src_.first;
607 for(
auto & dst_ : src_.second) {
608 string dst = dst_.first;
615 "," << (mI.
snd - mI.
rcv) <<
616 "," << 100.0*(mI.
snd - mI.
rcv)/(double)mI.
snd <<
629 map<string, flowInfo> qos_fInfo;
630 set<simtime_t> delays, jitters;
633 for(
string qos :
QoS) {
643 fI.
distDel[d.first] += d.second;
644 delays.insert(d.first);
652 fI.
distJit[d.first] += d.second;
653 delays.insert(d.first);
660 consDrops.insert(d.first);
665 out <<
"QoS,,SEND, DROP, DROP %,,MIN DELAY,AVG DELAY,MAX DELAY,,MIN JITTER,AVG JITTER,MAX JITTER";
667 for(
string qos : QoS) {
671 "," << (mI.
snd - mI.
rcv) <<
672 "," << 100.0*(mI.
snd - mI.
rcv)/(double)mI.
snd <<
673 ",," << 1000*mI.
minDel.dbl() <<
675 "," << 1000*mI.
maxDel.dbl() <<
683 outb <<
"QoS,,SEND, DROP, DROP %,, DROPs";
684 for(
auto & d : consDrops) { outb <<
"," <<d; }
686 for(
string qos : QoS) {
690 "," << (mI.
snd - mI.
rcv) <<
691 "," << 100.0*(mI.
snd - mI.
rcv)/(double)mI.
snd <<
693 for(
auto & d : consDrops) {
701 void IListener::finish() {
702 string config = par(
"configname").stdstringValue();
703 string run = par(
"runname").stdstringValue();
705 string filename =
"logs/" + config +
"." + run;
706 EV <<
"outfile "<< filename << endl;
710 out.open (filename +
".out");
711 out <<
"Config : "<< config << endl;
712 out <<
"Rate : "<< run << endl;
717 out.open (filename +
".hopInfo.csv");
718 out << config << endl;
720 module.printHopInfo(out);
723 out.open (filename +
".gHopInfo.csv");
724 out << config << endl;
726 module.printGHopInfo(out);
730 out.open (filename +
".FlowInfo.csv");
731 out << config << endl;
733 module.printFlowInfo(out);
736 out.open (filename +
".jFlowInfo.csv");
737 outb.open (filename +
".jFlowDrops.csv");
738 out << config << endl;
740 outb << config << endl;
742 module.printJFlowInfo(out, outb);
747 out.open (filename +
".PSTFlowInfo.csv");
748 out << config << endl;
750 module.printPSTFlowInfo(out);
753 out.open (filename +
".jPSTFlowInfo.csv");
754 out << config << endl;
756 outb << config << endl;
758 module.printPSTJFlowInfo(out);
763 out.open (filename +
".QoSInfo.csv");
764 outb.open (filename +
".QoSDrops.csv");
765 out << config << endl;
767 outb << config << endl;
769 module.printQoSInfo(out, outb);
778 int exp_base10 = round(log10(a));
779 double man_base10 = a*pow(10.0,-exp_base10);
780 double factor = pow(10.0,-ndigits+1);
781 double truncated_man_base10 = man_base10 - fmod(man_base10,factor);
782 double rounded_remainder = fmod(man_base10,factor)/factor;
784 rounded_remainder = rounded_remainder > 0.5 ? 1.0*factor : 0.0;
786 return (truncated_man_base10 + rounded_remainder)*pow(10.0,exp_base10) ;
bool operator<(const flowId &o) const
void printQoSInfo(ofstream &out, ofstream &outb)
double Idround(double a, int ndigits)
virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj)
void printHopInfo(ofstream &out)
flowId(string _src, string _dst, int _srcCepId, string _qos)
map< string, modQoSInfo > hopQoSInfo
void printPSTFlowInfo(ofstream &out)
map< string, map< flowId, flowInfo > > QoSFlowInfo
void printGHopInfo(ofstream &out)
void printPSTJFlowInfo(ofstream &out)
Define_Module(IListener::IListener)
void printFlowInfo(ofstream &out)
simtime_t toDistIndex(simtime_t t)
map< string, int > QoSsend
map< int, int > countConsDrop
void RcvMsg(int nSec, simtime_t h_delay, simtime_t p_delay, int pst_delay)
map< cModule *, modQoSInfo > modulesInfo
map< string, map< cModule *, modQoSInfo > > modulesQoSInfo
void printJFlowInfo(ofstream &out, ofstream &outb)
map< simtime_t, int > distJit
void print(ofstream &out)
map< simtime_t, int > distDel