RINASim  October 2016
Documentation of framework for OMNeT++
IListener.cc
Go to the documentation of this file.
1 // The MIT License (MIT)
2 //
3 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a copy
6 // of this software and associated documentation files (the "Software"), to deal
7 // in the Software without restriction, including without limitation the rights
8 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 // copies of the Software, and to permit persons to whom the Software is
10 // furnished to do so, subject to the following conditions:
11 //
12 // The above copyright notice and this permission notice shall be included in
13 // all copies or substantial portions of the Software.
14 //
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 // THE SOFTWARE.
22 
23 #include "IListener.h"
24 #include "AEConstantMsgs.h"
25 #include "ModularMonitorSignals.h"
26 #include "InfectionSignals.h"
27 
28 #include <iostream>
29 #include <fstream>
30 
32 
33 namespace IListener {
34 
36  maxDel(0.0),
37  countDel(0),
38  sumDel(0),
39  rcv(0),
40  drop(0) {}
41 
43  rcv++;
44  }
45 
47  drop++;
48  }
49 
50  void modQoSInfo::ServeMsg(int t) {
51  countDel++;
52  if(maxDel < t) { maxDel = t; }
53  sumDel += t;
54  distDel[t]++;
55  }
56 
57  flowId::flowId(string _src, string _dst, int _srcCepId, string _qos) :
58  src(_src),
59  dst(_dst),
60  srcCepId(_srcCepId),
61  qos(_qos) {}
62 
63  bool flowId::operator<( const flowId & o ) const {
64  if(src != o.src) { return src < o.src; }
65  if(dst != o.dst) { return dst < o.dst; }
66  if(qos != o.qos) { return qos < o.qos; }
67  return srcCepId < o.srcCepId;
68  }
69 
71  minDel(SIMTIME_MAX),
72  maxDel(0.0),
73  countDel(0),
74  sumDel(0.0),
75  minPST(9999),
76  maxPST(0),
77  countPST(0),
78  sumPST(0),
79  minJitter(SIMTIME_MAX),
80  maxJitter(0.0),
81  countJit(0),
82  sumJit(0.0),
83  snd(0),
84  rcv(0),
85  lastSec(0),
86  consDrop(0) {}
87 
89  snd++;
90  }
91 
92  void flowInfo::RcvMsg(int nSec, simtime_t h_delay, simtime_t p_delay, int pst_delay) {
93  if(lastSec > nSec) {
94  cerr << "Messages should not arrive unordered";
95 
96  exit(0);
97  }
98  rcv++;
99 
100  simtime_t delay = h_delay + p_delay;
101 
102  if(minDel > delay) { minDel = delay; }
103  if(maxDel < delay) { maxDel = delay; }
104  sumDel += delay;
105  distDel[toDistIndex(delay)]++;
106  countDel++;
107 
108 
109 
110  if(minPST > pst_delay) { minPST = pst_delay; }
111  if(maxPST < pst_delay) { maxPST = pst_delay; }
112  sumPST += pst_delay;
113  distPST[pst_delay]++;
114  countPST++;
115 
116  // Case All OK
117  if(lastSec+1 == nSec) {
118  if(lastSec > 0) {
119  consDrop = 0;
120 
121  simtime_t jitter = lastDelay - delay;
122  if(jitter < 0) { jitter = -jitter; }
123 
124  if(minJitter > jitter) { minJitter = jitter; }
125  if(maxJitter < jitter) { maxJitter = jitter; }
126  sumJit += jitter;
127  countJit++;
128  distJit[toDistIndex(jitter)]++;
129  }
130  } else {
131  consDrop++;
133  }
134 
135 
136 
137  lastSec = nSec;
138  lastDelay = delay;
139  }
140 
141  void IListener::initialize() {
142  this->getParentModule()->subscribe("ModularSignal", &module);
143  this->getParentModule()->subscribe("InfectionSignal", &module);
144 
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!"); }
149 
150 
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;
155  continue;
156  }
157  if (!n->getAttribute("delay")) {
158  EV << "Error parsing Infected QoS. Its delay is missing!" << endl;
159  continue;
160  }
161  if (!n->getAttribute("jitter")) {
162  EV << "Error parsing Infected QoS. Its jitter is missing!" << endl;
163  continue;
164  }
165 
166  string name = n->getAttribute("name");
167  double delay = atof(n->getAttribute("delay"))/1000.0;
168  double jitter = atof(n->getAttribute("jitter"))/1000.0;
169  if(name == "") {
170  EV << "Error parsing Infected QoS. Its name is empty!" << endl;
171  continue;
172  }
173  if(delay <= 0) {
174  EV << "Error parsing Infected QoS. Its delay <=0!" << endl;
175  continue;
176  }
177  if(jitter <= 0) {
178  EV << "Error parsing Infected QoS. Its jitter <=0!" << endl;
179  continue;
180  }
181 
182  module.QoS.insert(name);
183  module.QoSDelay[name] = delay;
184  module.QoSJitter[name] = jitter;
185 
186 
187  h_delayV = par("mtu").longValue()/1500.0;
188  module.h_delayV = h_delayV;
189  }
190 
191  }
192 
193  void IListenerModule::receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj) {
194  if(HopDelayMsg * m = dynamic_cast<HopDelayMsg*>(obj)) {
195  modulesQoSInfo[m->qos][m->module].ServeMsg(m->t);
196  hopQoSInfo[m->qos].ServeMsg(m->t);
197  modulesInfo[m->module].ServeMsg(m->t);
198  } else if(HopRcvMsg * m = dynamic_cast<HopRcvMsg*>(obj) ) {
199  modulesQoSInfo[m->qos][m->module].RcvMsg();
200  hopQoSInfo[m->qos].RcvMsg();
201  modulesInfo[m->module].RcvMsg();
202  } else if(HopLossMsg * m = dynamic_cast<HopLossMsg*>(obj) ) {
203  modulesQoSInfo[m->qos][m->module].DropMsg();
204  hopQoSInfo[m->qos].DropMsg();
205  modulesInfo[m->module].DropMsg();
206  } else if(SendInfMsg * m = dynamic_cast<SendInfMsg*>(obj) ) {
207  QoSsend[m->qos]++;
208  flowId fId(m->src, m->dst, m->srcCepId, m->qos);
209  QoSFlowInfo[m->qos][fId].SendMsg();
210  } else if(RecvInfMsg * m = dynamic_cast<RecvInfMsg*>(obj)) {
211  flowId fId(m->src, m->dst, m->src_cepID, m->qos);
212  QoSFlowInfo[m->qos][fId].RcvMsg(m->seqN, m->h_delay*h_delayV, m->p_delay, m->pst_delay);
213  }
214  }
215 
216  void IListenerModule::print(ofstream &out) {
217  out << "Processed per hop :: " << endl;
218  for(string qos : QoS) {
219  out << "\tQoS :: " << qos << endl;
220  modQoSInfo & mI = hopQoSInfo[qos];
221  out << "\t\tProcessed/Dropped : "
222  << mI.rcv <<"/"<< mI.drop
223  << " - ("<< Idround(100.0*mI.drop/(double)mI.rcv, 4)<<"%)"
224  << endl;
225 
226  out << "\t\tHop Delay : "
227  << Idround(mI.sumDel/(double)mI.countDel, 4) << "pk AVG / "
228  << mI.maxDel << "pk MAX"
229  << endl;
230  }
231  }
232 
233  void IListenerModule::printHopInfo(ofstream &out) {
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;) {
238  out << "," << i;
239  if(i < 10) { i += 1; }
240  else if(i < 100) { i += 10; }
241  else { i += 100; }
242  }
243  out << endl;
244  for(auto & mI : modulesQoSInfo[qos]) {
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 << ",,";
250 
251  int cWT = 0;
252  int cC = 0;
253  for(auto wt : mI.second.distDel) {
254  while(wt.first > cWT) {
255  out << "," << cC;
256  if(cWT < 10) { cWT += 1; }
257  else if(cWT < 100) { cWT += 10; }
258  else { cWT += 100; }
259  cC = 0;
260  }
261 
262  if(wt.first < cWT) {
263  cC += wt.second;
264  } else if(wt.first == cWT) {
265  cC += wt.second;
266  out << "," << cC;
267  if(cWT < 10) { cWT += 1; }
268  else if(cWT < 100) { cWT += 10; }
269  else { cWT += 100; }
270  cC = 0;
271  }
272  }
273  out << endl;
274  }
275  out << "QoS," << qos << endl << endl;
276 
277  }
278  out << 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;) {
282  out << "," << i;
283  if(i < 10) { i += 1; }
284  else if(i < 100) { i += 10; }
285  else { i += 100; }
286  }
287  out << endl;
288  for(auto & mI : modulesInfo) {
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 << ",,";
294 
295  int cWT = 0;
296  int cC = 0;
297  for(auto wt : mI.second.distDel) {
298  while(wt.first > cWT) {
299  out << "," << cC;
300  if(cWT < 10) { cWT += 1; }
301  else if(cWT < 100) { cWT += 10; }
302  else { cWT += 100; }
303  cC = 0;
304  }
305 
306  if(wt.first < cWT) {
307  cC += wt.second;
308  } else if(wt.first == cWT) {
309  cC += wt.second;
310  out << "," << cC;
311  if(cWT < 10) { cWT += 1; }
312  else if(cWT < 100) { cWT += 10; }
313  else { cWT += 100; }
314  cC = 0;
315  }
316  }
317  out << endl;
318  }
319  out << "QoS,*" << endl << endl;
320 
321  }
322 
323  void IListenerModule::printGHopInfo(ofstream &out) {
324  out << "QoS,,RCV, DROP, DROP %,,AVG PK W, MAX PK W,,DIST PK WT:";
325  for(int i = 0; i<=5000;) {
326  out << "," << i;
327  if(i < 10) { i += 1; }
328  else if(i < 100) { i += 10; }
329  else { i += 100; }
330  }
331  out << endl;
332  for(string qos : QoS) {
333 
334 
335  out << qos <<",,";
336 
337  auto & mI = hopQoSInfo[qos];
338  int rcv = QoSsend[qos];
339 
340  out << rcv <<
341  "," << mI.drop <<
342  "," << Idround(100.0*mI.drop/(double)rcv, 4) <<
343  ",," << Idround(mI.sumDel/(double)mI.countDel, 4) <<
344  "," << mI.maxDel <<
345  ",," << qos;
346 
347  int cWT = 0;
348  int cC = 0;
349  for(auto wt : mI.distDel) {
350  while(wt.first > cWT) {
351  out << "," << cC;
352  if(cWT < 10) { cWT += 1; }
353  else if(cWT < 100) { cWT += 10; }
354  else { cWT += 100; }
355  cC = 0;
356  }
357 
358  if(wt.first < cWT) {
359  cC += wt.second;
360  } else if(wt.first == cWT) {
361  cC += wt.second;
362  out << "," << cC;
363  if(cWT < 10) { cWT += 1; }
364  else if(cWT < 100) { cWT += 10; }
365  else { cWT += 100; }
366  cC = 0;
367  }
368  }
369  out << "," << cC;
370  out << endl;
371 
372  }
373 
374  out << endl;
375  out << endl;
376 
377  out << "QoS,,RCV, DROP, DROP %,,AVG PK W, MAX PK W,,DIST PK WT:";
378  for(int i = 0; i<=5000;) {
379  out << "," << i;
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; }
385  else { i += 1000; }
386  }
387  out << endl;
388  for(string qos : QoS) {
389 
390 
391  out << qos <<",,";
392 
393  auto & mI = hopQoSInfo[qos];
394  int rcv = QoSsend[qos];
395 
396  out << rcv <<
397  "," << mI.drop <<
398  "," << Idround(100.0*mI.drop/(double)rcv, 4) <<
399  ",," << Idround(mI.sumDel/(double)mI.countDel, 4) <<
400  "," << mI.maxDel <<
401  ",," << qos;
402 
403  int cWT = 0;
404  int cC = 0;
405  for(auto wt : mI.distDel) {
406  while(wt.first > cWT) {
407  out << "," << cC;
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; }
414  cC = 0;
415  }
416 
417  if(wt.first < cWT) {
418  cC += wt.second;
419  } else if(wt.first == cWT) {
420  cC += wt.second;
421  out << "," << cC;
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; }
428  cC = 0;
429  }
430  }
431  out << "," << cC;
432  out << endl;
433 
434  }
435  }
436 
437  void IListenerModule::printFlowInfo(ofstream &out) {
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";
441  out << endl;
442  for(auto & mI : QoSFlowInfo[qos]) {
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() <<
455  endl;
456  }
457  out << "QoS," << qos << endl << endl;
458  }
459  }
460 
461  void IListenerModule::printJFlowInfo(ofstream &out, ofstream &outb) {
462  map<string, map<string, map<string, flowInfo> > > qos_src_dst_fInfo;
463  set<simtime_t> delays, jitters;
464  set<int> consDrops;
465 
466  for(string qos : QoS) {
467  for(auto & mI : QoSFlowInfo[qos]) {
468  flowInfo &cI = mI.second;
469  flowInfo & fI = qos_src_dst_fInfo[qos][mI.first.src][mI.first.dst];
470 
471  if(cI.minDel < fI.minDel) { fI.minDel = cI.minDel; }
472  if(cI.maxDel > fI.maxDel) { fI.maxDel = cI.maxDel; }
473  fI.sumDel += cI.sumDel;
474  fI.countDel += cI.countDel;
475  for(auto & d:cI.distDel) {
476  fI.distDel[d.first] += d.second;
477  delays.insert(d.first);
478  }
479 
480  if(cI.minJitter < fI.minJitter) { fI.minJitter = cI.minJitter; }
481  if(cI.maxJitter > fI.maxJitter) { fI.maxJitter = cI.maxJitter; }
482  fI.sumJit += cI.sumJit;
483  fI.countJit += cI.countJit;
484  for(auto & d:cI.distJit) {
485  fI.distJit[d.first] += d.second;
486  delays.insert(d.first);
487  }
488 
489  fI.snd += cI.snd;
490  fI.rcv += cI.rcv;
491  for(auto & d:cI.countConsDrop) {
492  fI.countConsDrop[d.first] += d.second;
493  consDrops.insert(d.first);
494  }
495  }
496  }
497 
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";
501  out << endl;
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;
506  flowInfo &mI = dst_.second;
507 
508 
509  out << src <<
510  ","<< dst <<
511  ",," << mI.snd <<
512  "," << (mI.snd - mI.rcv) <<
513  "," << 100.0*(mI.snd - mI.rcv)/(double)mI.snd <<
514  ",," << 1000*mI.minDel.dbl() <<
515  "," << 1000*mI.sumDel.dbl()/(double)mI.countDel <<
516  "," << 1000*mI.maxDel.dbl() <<
517  ",," << 1000*mI.minJitter.dbl() <<
518  "," << 1000*mI.sumJit.dbl()/(double)mI.countJit <<
519  "," << 1000*mI.maxJitter.dbl() <<
520  endl;
521  }
522  }
523  }
524 
525 
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; }
530  outb << endl;
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;
535  flowInfo &mI = dst_.second;
536 
537  outb << src <<
538  ","<< dst <<
539  ",," << mI.snd <<
540  "," << (mI.snd - mI.rcv) <<
541  "," << 100.0*(mI.snd - mI.rcv)/(double)mI.snd <<
542  ",,";
543  for(auto & d : consDrops) {
544  outb << "," << mI.countConsDrop[d];
545  }
546  outb << endl;
547  }
548  }
549  }
550  }
551 
552  void IListenerModule::printPSTFlowInfo(ofstream &out) {
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";
556  out << endl;
557  for(auto & mI : QoSFlowInfo[qos]) {
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 <<
567  endl;
568  }
569  out << "QoS," << qos << endl << endl;
570  }
571  }
572 
574  map<string, map<string, map<string, flowInfo> > > qos_src_dst_fInfo;
575  set<int> delays;
576  set<int> consDrops;
577 
578  for(string qos : QoS) {
579  for(auto & mI : QoSFlowInfo[qos]) {
580  flowInfo &cI = mI.second;
581  flowInfo & fI = qos_src_dst_fInfo[qos][mI.first.src][mI.first.dst];
582 
583  if(cI.minPST < fI.minPST) { fI.minPST = cI.minPST; }
584  if(cI.maxPST > fI.maxPST) { fI.maxPST = cI.maxPST; }
585  fI.sumPST += cI.sumPST;
586  fI.countPST += cI.countPST;
587  for(auto & d:cI.distPST) {
588  fI.distPST[d.first] += d.second;
589  delays.insert(d.first);
590  }
591 
592  fI.snd += cI.snd;
593  fI.rcv += cI.rcv;
594  for(auto & d:cI.countConsDrop) {
595  fI.countConsDrop[d.first] += d.second;
596  consDrops.insert(d.first);
597  }
598  }
599  }
600 
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";
604  out << endl;
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;
609  flowInfo &mI = dst_.second;
610 
611 
612  out << src <<
613  ","<< dst <<
614  ",," << mI.snd <<
615  "," << (mI.snd - mI.rcv) <<
616  "," << 100.0*(mI.snd - mI.rcv)/(double)mI.snd <<
617  ",," << mI.minPST <<
618  "," << mI.sumPST/(double)mI.countPST <<
619  "," << mI.maxPST <<
620  endl;
621  }
622  }
623  }
624  }
625 
626 
627 
628  void IListenerModule::printQoSInfo(ofstream &out, ofstream &outb) {
629  map<string, flowInfo> qos_fInfo;
630  set<simtime_t> delays, jitters;
631  set<int> consDrops;
632 
633  for(string qos : QoS) {
634  for(auto & mI : QoSFlowInfo[qos]) {
635  flowInfo &cI = mI.second;
636  flowInfo & fI = qos_fInfo[qos];
637 
638  if(cI.minDel < fI.minDel) { fI.minDel = cI.minDel; }
639  if(cI.maxDel > fI.maxDel) { fI.maxDel = cI.maxDel; }
640  fI.sumDel += cI.sumDel;
641  fI.countDel += cI.countDel;
642  for(auto & d:cI.distDel) {
643  fI.distDel[d.first] += d.second;
644  delays.insert(d.first);
645  }
646 
647  if(cI.minJitter < fI.minJitter) { fI.minJitter = cI.minJitter; }
648  if(cI.maxJitter > fI.maxJitter) { fI.maxJitter = cI.maxJitter; }
649  fI.sumJit += cI.sumJit;
650  fI.countJit += cI.countJit;
651  for(auto & d:cI.distJit) {
652  fI.distJit[d.first] += d.second;
653  delays.insert(d.first);
654  }
655 
656  fI.snd += cI.snd;
657  fI.rcv += cI.rcv;
658  for(auto & d:cI.countConsDrop) {
659  fI.countConsDrop[d.first] += d.second;
660  consDrops.insert(d.first);
661  }
662  }
663  }
664 
665  out << "QoS,,SEND, DROP, DROP %,,MIN DELAY,AVG DELAY,MAX DELAY,,MIN JITTER,AVG JITTER,MAX JITTER";
666  out << endl;
667  for(string qos : QoS) {
668  flowInfo &mI = qos_fInfo[qos];
669  out << qos <<
670  ",," << mI.snd <<
671  "," << (mI.snd - mI.rcv) <<
672  "," << 100.0*(mI.snd - mI.rcv)/(double)mI.snd <<
673  ",," << 1000*mI.minDel.dbl() <<
674  "," << 1000*mI.sumDel.dbl()/(double)mI.countDel <<
675  "," << 1000*mI.maxDel.dbl() <<
676  ",," << 1000*mI.minJitter.dbl() <<
677  "," << 1000*mI.sumJit.dbl()/(double)mI.countJit <<
678  "," << 1000*mI.maxJitter.dbl() <<
679  endl;
680  }
681 
682 
683  outb << "QoS,,SEND, DROP, DROP %,, DROPs";
684  for(auto & d : consDrops) { outb << "," <<d; }
685  outb << endl;
686  for(string qos : QoS) {
687  flowInfo &mI = qos_fInfo[qos];
688  outb << qos <<
689  ",," <<mI.snd <<
690  "," << (mI.snd - mI.rcv) <<
691  "," << 100.0*(mI.snd - mI.rcv)/(double)mI.snd <<
692  ",,";
693  for(auto & d : consDrops) {
694  outb << "," << mI.countConsDrop[d];
695  }
696  outb << endl;
697  }
698  }
699 
700 
701  void IListener::finish() {
702  string config = par("configname").stdstringValue();
703  string run = par("runname").stdstringValue();
704 
705  string filename = "logs/" + config + "." + run;
706  EV << "outfile "<< filename << endl;
707 
708  ofstream out, outb;
709 
710  out.open (filename +".out");
711  out << "Config : "<< config << endl;
712  out << "Rate : "<< run << endl;
713  module.print(out);
714  out.close();
715 
716 
717  out.open (filename +".hopInfo.csv");
718  out << config << endl;
719  out << run << endl;
720  module.printHopInfo(out);
721  out.close();
722 
723  out.open (filename +".gHopInfo.csv");
724  out << config << endl;
725  out << run << endl;
726  module.printGHopInfo(out);
727  out.close();
728 
729 
730  out.open (filename +".FlowInfo.csv");
731  out << config << endl;
732  out << run << endl;
733  module.printFlowInfo(out);
734  out.close();
735 
736  out.open (filename +".jFlowInfo.csv");
737  outb.open (filename +".jFlowDrops.csv");
738  out << config << endl;
739  out << run << endl;
740  outb << config << endl;
741  outb << run << endl;
742  module.printJFlowInfo(out, outb);
743  out.close();
744  outb.close();
745 
746 
747  out.open (filename +".PSTFlowInfo.csv");
748  out << config << endl;
749  out << run << endl;
750  module.printPSTFlowInfo(out);
751  out.close();
752 
753  out.open (filename +".jPSTFlowInfo.csv");
754  out << config << endl;
755  out << run << endl;
756  outb << config << endl;
757  outb << run << endl;
758  module.printPSTJFlowInfo(out);
759  out.close();
760  outb.close();
761 
762 
763  out.open (filename +".QoSInfo.csv");
764  outb.open (filename +".QoSDrops.csv");
765  out << config << endl;
766  out << run << endl;
767  outb << config << endl;
768  outb << run << endl;
769  module.printQoSInfo(out, outb);
770  out.close();
771  outb.close();
772 
773  }
774 
775 
776  double Idround(double a, int ndigits) {
777 
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;
783 
784  rounded_remainder = rounded_remainder > 0.5 ? 1.0*factor : 0.0;
785 
786  return (truncated_man_base10 + rounded_remainder)*pow(10.0,exp_base10) ;
787  }
788 
789  simtime_t toDistIndex(simtime_t t) {
790  return Idround(t.dbl(), 2);
791  }
792 }
bool operator<(const flowId &o) const
Definition: IListener.cc:63
void printQoSInfo(ofstream &out, ofstream &outb)
Definition: IListener.cc:628
simtime_t minDel
Definition: IListener.h:63
double Idround(double a, int ndigits)
Definition: IListener.cc:776
simtime_t maxDel
Definition: IListener.h:63
virtual void receiveSignal(cComponent *source, simsignal_t signalID, cObject *obj)
Definition: IListener.cc:193
void printHopInfo(ofstream &out)
Definition: IListener.cc:233
flowId(string _src, string _dst, int _srcCepId, string _qos)
Definition: IListener.cc:57
map< string, modQoSInfo > hopQoSInfo
Definition: IListener.h:114
void printPSTFlowInfo(ofstream &out)
Definition: IListener.cc:552
simtime_t lastDelay
Definition: IListener.h:74
map< string, map< flowId, flowInfo > > QoSFlowInfo
Definition: IListener.h:119
map< int, int > distDel
Definition: IListener.h:41
simtime_t sumJit
Definition: IListener.h:78
simtime_t maxJitter
Definition: IListener.h:75
void printGHopInfo(ofstream &out)
Definition: IListener.cc:323
void printPSTJFlowInfo(ofstream &out)
Definition: IListener.cc:573
Define_Module(IListener::IListener)
void printFlowInfo(ofstream &out)
Definition: IListener.cc:437
simtime_t toDistIndex(simtime_t t)
Definition: IListener.cc:789
map< string, int > QoSsend
Definition: IListener.h:115
void ServeMsg(int t)
Definition: IListener.cc:50
map< int, int > countConsDrop
Definition: IListener.h:82
simtime_t minJitter
Definition: IListener.h:75
void RcvMsg(int nSec, simtime_t h_delay, simtime_t p_delay, int pst_delay)
Definition: IListener.cc:92
map< cModule *, modQoSInfo > modulesInfo
Definition: IListener.h:117
map< int, int > distPST
Definition: IListener.h:70
map< string, map< cModule *, modQoSInfo > > modulesQoSInfo
Definition: IListener.h:113
simtime_t sumDel
Definition: IListener.h:66
void printJFlowInfo(ofstream &out, ofstream &outb)
Definition: IListener.cc:461
map< simtime_t, int > distJit
Definition: IListener.h:76
void print(ofstream &out)
Definition: IListener.cc:216
map< simtime_t, int > distDel
Definition: IListener.h:64