RINASim  October 2016
Documentation of framework for OMNeT++
TailDrop.cc
Go to the documentation of this file.
1 //
2 // The MIT License (MIT)
3 //
4 // Copyright (c) 2014-2016 Brno University of Technology, PRISTINE project
5 //
6 // Permission is hereby granted, free of charge, to any person obtaining a copy
7 // of this software and associated documentation files (the "Software"), to deal
8 // in the Software without restriction, including without limitation the rights
9 // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 // copies of the Software, and to permit persons to whom the Software is
11 // furnished to do so, subject to the following conditions:
12 //
13 // The above copyright notice and this permission notice shall be included in
14 // all copies or substantial portions of the Software.
15 //
16 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 // THE SOFTWARE.
23 
24 #include <TailDrop.h>
25 
26 #include <iostream>
27 
29 
30 bool TailDrop::run(RMTQueue* queue)
31 {
32  count[queue]++;
33  if (queue->getLength() >= queue->getMaxLength()) {
34  drop[queue]++;
35  EV << "TailDrop: dropping message for queue " << queue->getName() << "!" << endl;
36  return true;
37  } else {
38  accepted[queue]++;
39  return false;
40  }
41 }
42 
44  if(par("printAtEnd").boolValue()) {
45  std::cout << "TailDrop::finish" << endl;
46  std::cout << this->getFullPath() << endl;
47  for(auto & ql : count) {
48  RMTQueue * q = ql.first;
49  std::cout << "\tQueue : "<< q->getFullPath()<<endl;
50  std::cout << "\t\tReceived : "<< count[q]<<endl;
51  std::cout << "\t\tAccepted : "<< accepted[q]<<endl;
52  std::cout << "\t\tRefused : "<< drop[q]<<endl;
53 
54  }
55  }
56 }
57 
std::map< RMTQueue *, long > count
Definition: TailDrop.h:37
void finish()
Definition: TailDrop.cc:43
int getMaxLength() const
Definition: RMTQueue.cc:215
virtual bool run(RMTQueue *queue)
Definition: TailDrop.cc:30
std::map< RMTQueue *, long > drop
Definition: TailDrop.h:37
int getLength() const
Definition: RMTQueue.cc:210
Define_Module(TailDrop)
std::map< RMTQueue *, long > accepted
Definition: TailDrop.h:37