RINASim  October 2016
Documentation of framework for OMNeT++
REDUpstreamNotifier.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 
16 #include <REDUpstreamNotifier.h>
17 
19 
21 {
22  sigStatUpstreamNotifierSeqNum = registerSignal("REDUpstreamNotifierSeqNum");
23 }
24 
26 {
27  // simple version:
28  // Send out the notification when an output (N-1)-port is overflowing.
29  double notifyProb = 0;
30  double len = queue->getLength();
31  double thrLen = queue->getThreshLength();
32  double maxLen = queue->getMaxLength();
33 
34  if(len >= maxLen)
35  notifyProb = 1;
36 
37  if ((len < maxLen) && (len >= thrLen) ) {
38  notifyProb = 1 / (maxLen - thrLen) * (len - thrLen);
39  }
40 
41  const double rand = dblrand();
42  if(rand < notifyProb){
43  if (queue->getType() == RMTQueue::OUTPUT)
44  { // (N-1)-port output queues are filling up => stop accepting more PDUs
45  PDU_Base* pdu = (PDU_Base*)queue->getLastPDU();
48  }
49  }
50 
51  return false;
52 }
53 
virtual void onPolicyInit()
queueType getType() const
Definition: RMTQueue.cc:241
int getMaxLength() const
Definition: RMTQueue.cc:215
Define_Module(REDUpstreamNotifier)
virtual bool run(RMTQueue *queue)
int getLength() const
Definition: RMTQueue.cc:210
const cPacket * getLastPDU() const
Definition: RMTQueue.cc:276
virtual unsigned int getSeqNum() const
Definition: PDU_m.cc:376
int getThreshLength() const
Definition: RMTQueue.cc:226
simsignal_t sigStatUpstreamNotifierSeqNum
void notifySenderOfCongestion(const cPacket *pdu)
Definition: RMTMaxQBase.cc:61