RINASim  October 2016
Documentation of framework for OMNeT++
WeightedFairQMonitor.cc
Go to the documentation of this file.
1 //
2 // Copyright © 2014 - 2015 PRISTINE Consortium (http://ict-pristine.eu)
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU Lesser General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU Lesser General Public License for more details.
13 //
14 // You should have received a copy of the GNU Lesser General Public License
15 // along with this program. If not, see http://www.gnu.org/licenses/.
16 //
17 
18 #include <WeightedFairQMonitor.h>
19 
21 
22 namespace FWQ {
23 
24 using namespace std;
25 
27  // Default Bandwith for Queues not linked to flows or with undefined bandwith
28  defBW = par("defBW").longValue();
29 
30  // Queue sizes for lock and release EFCPi
31  stopQAt = par("stopQAt").longValue();
32  startQAt = par("startQAt").longValue();
33 }
34 
36  int bw = 0;
37 
38  if(queue->getFlow() != NULL) {
39  bw = queue->getFlow()->getQosCube().getAvgBand();
40  }
41 
42  queueTimes[queue] = FlowParams( bw > 0 ? bw : defBW );
43 }
45  /*
46  * Release the lock on the EFCPi of the flow related to the queue.
47  *
48  * if(queue->getFlow() != NULL) {
49  * ReleaseEFCPiByFlow( queue->getFlow(), queue->getId() );
50  * }
51  */
52  queueTimes.erase(queue);
53 }
54 
56  if(queue->getType() == RMTQueue::INPUT){ return; }
57 
58  if(queueTimes.find(queue) != queueTimes.end()) {
59  queueTimes[queue].insert( queue->getLastPDU()->getBitLength() );
60  }
61 
62  /*
63  * Add lock on the EFCPi of the flow related to the queue.
64  *
65  * if( queue->getLength() => stopQAt ) {
66  * if(queue->getFlow() != NULL) {
67  * LockEFCPiByFlow( queue->getFlow(), queue->getId() );
68  * }
69  * }
70  */
71 }
72 
74  if(queue->getType() == RMTQueue::INPUT){ return; }
75 
76  if(queueTimes.find(queue) != queueTimes.end()) {
77  queueTimes[queue].removeFirst();
78  }
79 
80  /*
81  * Release the lock on the EFCPi of the flow related to the queue.
82  *
83  * if( queue->getLength() <= startQAt ) {
84  * if(queue->getFlow() != NULL) {
85  * ReleaseEFCPiByFlow( queue->getFlow(), queue->getId() );
86  * }
87  * }
88  */
89 }
90 
91 void WeightedFairQMonitor::onMessageDrop(RMTQueue* queue, const cPacket* pdu) {
92  if(queue->getType() == RMTQueue::INPUT){ return; }
93 
94  if(queueTimes.find(queue) != queueTimes.end()) {
95  queueTimes[queue].removeLast();
96  }
97 
98  /*
99  * Release the lock on the EFCPi of the flow related to the queue.
100  *
101  * if( queue->getLength() <= startQAt ) {
102  * if(queue->getFlow() != NULL) {
103  * ReleaseEFCPiByFlow( queue->getFlow(), queue->getId() );
104  * }
105  * }
106  */
107 }
108 
109 
111  simtime_t vFinTime = DBL_MAX;
112  RMTQueue * ret = NULL;
113 
114  for(queue2FpIt it = queueTimes.begin(); it != queueTimes.end(); it++) {
115  simtime_t qvFinTime = it->second.getFirstFinTime();
116  if(qvFinTime < vFinTime) {
117  vFinTime = qvFinTime;
118  ret = it->first;
119  }
120  }
121 
122  return ret;
123 }
124 
125 
126 } /* namespace FWQ */
virtual void postQueueCreation(RMTQueue *queue)
queueType getType() const
Definition: RMTQueue.cc:241
Define_Module(FWQ::WeightedFairQMonitor)
int getAvgBand() const
Gets Average Bandwidth parameter.
Definition: QoSCube.cc:252
virtual void preQueueRemoval(RMTQueue *queue)
virtual void postPDURelease(RMTQueue *queue)
virtual void postPDUInsertion(RMTQueue *queue)
const cPacket * getLastPDU() const
Definition: RMTQueue.cc:276
const Flow * getFlow() const
Definition: RMTQueue.cc:84
virtual RMTQueue * getNextQueue()
const QoSCube & getQosCube() const
Definition: Flow.cc:171
queue2Fp::iterator queue2FpIt
virtual void onMessageDrop(RMTQueue *queue, const cPacket *pdu)