INET Framework for OMNeT++/OMNEST
inet::AlgorithmicDropperBase Class Referenceabstract

Base class for algorithmic droppers (RED, DropTail, etc.). More...

#include <AlgorithmicDropperBase.h>

Inheritance diagram for inet::AlgorithmicDropperBase:
inet::IQueueAccess inet::REDDropper inet::ThresholdDropper

Public Member Functions

 AlgorithmicDropperBase ()
 
virtual ~AlgorithmicDropperBase ()
 
- Public Member Functions inherited from inet::IQueueAccess
virtual ~IQueueAccess ()
 

Protected Member Functions

virtual void initialize () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual bool shouldDrop (cPacket *packet)=0
 
virtual void dropPacket (cPacket *packet)
 
virtual void sendOut (cPacket *packet)
 
virtual int getLength () const override
 Returns the number of frames in the queue. More...
 
virtual int getByteLength () const override
 Returns the number of bytes in the queue. More...
 

Protected Attributes

int numGates
 
std::vector< IQueueAccess * > outQueues
 
std::set< IQueueAccess * > outQueueSet
 

Detailed Description

Base class for algorithmic droppers (RED, DropTail, etc.).

Constructor & Destructor Documentation

inet::AlgorithmicDropperBase::AlgorithmicDropperBase ( )
inline
38 : numGates(0) {};
int numGates
Definition: AlgorithmicDropperBase.h:33
virtual inet::AlgorithmicDropperBase::~AlgorithmicDropperBase ( )
inlinevirtual
39 {};

Member Function Documentation

void inet::AlgorithmicDropperBase::dropPacket ( cPacket *  packet)
protectedvirtual

Referenced by handleMessage().

49 {
50  // TODO statistics
51  delete packet;
52 }
int inet::AlgorithmicDropperBase::getByteLength ( ) const
overrideprotectedvirtual

Returns the number of bytes in the queue.

Implements inet::IQueueAccess.

Referenced by inet::ThresholdDropper::shouldDrop().

69 {
70  int len = 0;
71  for (const auto & elem : outQueueSet)
72  len += (elem)->getByteLength();
73  return len;
74 }
virtual int getByteLength() const override
Returns the number of bytes in the queue.
Definition: AlgorithmicDropperBase.cc:68
uint16_t len
Definition: TCP_NSC.cc:85
std::set< IQueueAccess * > outQueueSet
Definition: AlgorithmicDropperBase.h:35
int inet::AlgorithmicDropperBase::getLength ( ) const
overrideprotectedvirtual

Returns the number of frames in the queue.

Implements inet::IQueueAccess.

Referenced by inet::REDDropper::sendOut(), inet::ThresholdDropper::shouldDrop(), and inet::REDDropper::shouldDrop().

61 {
62  int len = 0;
63  for (const auto & elem : outQueueSet)
64  len += (elem)->getLength();
65  return len;
66 }
uint16_t len
Definition: TCP_NSC.cc:85
std::set< IQueueAccess * > outQueueSet
Definition: AlgorithmicDropperBase.h:35
virtual int getLength() const override
Returns the number of frames in the queue.
Definition: AlgorithmicDropperBase.cc:60
void inet::AlgorithmicDropperBase::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
40 {
41  cPacket *packet = check_and_cast<cPacket *>(msg);
42  if (shouldDrop(packet))
43  dropPacket(packet);
44  else
45  sendOut(packet);
46 }
virtual void dropPacket(cPacket *packet)
Definition: AlgorithmicDropperBase.cc:48
virtual bool shouldDrop(cPacket *packet)=0
virtual void sendOut(cPacket *packet)
Definition: AlgorithmicDropperBase.cc:54
void inet::AlgorithmicDropperBase::initialize ( )
overrideprotectedvirtual

Reimplemented in inet::REDDropper, and inet::ThresholdDropper.

Referenced by inet::ThresholdDropper::initialize(), and inet::REDDropper::initialize().

24 {
25  numGates = gateSize("out");
26  for (int i = 0; i < numGates; ++i) {
27  cGate *outGate = gate("out", i);
28  cGate *connectedGate = outGate->getPathEndGate();
29  if (!connectedGate)
30  throw cRuntimeError("ThresholdDropper out gate %d is not connected", i);
31  IQueueAccess *outModule = dynamic_cast<IQueueAccess *>(connectedGate->getOwnerModule());
32  if (!outModule)
33  throw cRuntimeError("ThresholdDropper out gate %d should be connected a simple module implementing IQueueAccess", i);
34  outQueues.push_back(outModule);
35  outQueueSet.insert(outModule);
36  }
37 }
std::set< IQueueAccess * > outQueueSet
Definition: AlgorithmicDropperBase.h:35
int numGates
Definition: AlgorithmicDropperBase.h:33
std::vector< IQueueAccess * > outQueues
Definition: AlgorithmicDropperBase.h:34
void inet::AlgorithmicDropperBase::sendOut ( cPacket *  packet)
protectedvirtual

Reimplemented in inet::REDDropper.

Referenced by handleMessage(), and inet::REDDropper::sendOut().

55 {
56  int index = packet->getArrivalGate()->getIndex();
57  send(packet, "out", index);
58 }
virtual bool inet::AlgorithmicDropperBase::shouldDrop ( cPacket *  packet)
protectedpure virtual

Implemented in inet::REDDropper, and inet::ThresholdDropper.

Referenced by handleMessage().

Member Data Documentation

int inet::AlgorithmicDropperBase::numGates
protected
std::vector<IQueueAccess *> inet::AlgorithmicDropperBase::outQueues
protected

Referenced by initialize().

std::set<IQueueAccess *> inet::AlgorithmicDropperBase::outQueueSet
protected

The documentation for this class was generated from the following files: