RINASim  October 2016
Documentation of framework for OMNeT++
WeightedFairQ.cc
Go to the documentation of this file.
1 //
2 // This program is free software: you can redistribute it and/or modify
3 // it under the terms of the GNU Lesser General Public License as published by
4 // the Free Software Foundation, either version 3 of the License, or
5 // (at your option) any later version.
6 //
7 // This program is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 // GNU Lesser General Public License for more details.
11 //
12 // You should have received a copy of the GNU Lesser General Public License
13 // along with this program. If not, see http://www.gnu.org/licenses/.
14 //
15 
17 
19 
20 namespace FWQ {
21 
22 using namespace std;
23 
24 
26  monitor = getRINAModule<WeightedFairQMonitor*>(this, 1, {MOD_POL_RMT_QMONITOR});
27  if (monitor == NULL) {
28  EV << "!!! WeightedFairQMaxQ has to be used in conjecture with WeightedFairQ!" << endl;
29  }
30 }
31 
32 
34  Enter_Method("processQueues()");
35 
36  switch(direction){
37  case RMTQueue::INPUT:
38  if (port->isInputReady() && port->getWaiting(RMTQueue::INPUT)) {
40  inQ->releasePDU();
41  }
42  break;
43  case RMTQueue::OUTPUT:
44  if (port->isOutputReady() && port->getWaiting(RMTQueue::OUTPUT)) {
45  RMTQueue* outQ = monitor->getNextQueue();
46  if(outQ && outQ->getLength() > 0) {
47  outQ->releasePDU();
48  }
49  }
50  break;
51  }
52 }
53 
54 } /* namespace FWQ */
55 
virtual void onPolicyInit()
virtual void processQueues(RMTPort *port, RMTQueueType direction)
RMTQueue * getLongestQueue(RMTQueueType type) const
Definition: RMTPort.cc:226
void releasePDU()
Definition: RMTQueue.cc:162
const char * MOD_POL_RMT_QMONITOR
Definition: ExternConsts.cc:74
int getLength() const
Definition: RMTQueue.cc:210
unsigned long getWaiting(RMTQueueType direction)
Definition: RMTPort.cc:315
bool isOutputReady()
Definition: RMTPort.cc:261
Define_Module(FWQ::WeightedFairQ)
bool isInputReady()
Definition: RMTPort.cc:282