#include <PassiveQueueBase.h>
Public Member Functions | |
| virtual void | requestPacket () |
Protected Member Functions | |
| virtual void | initialize () |
| virtual void | handleMessage (cMessage *msg) |
| virtual void | finish () |
| virtual bool | enqueue (cMessage *msg)=0 |
| virtual cMessage * | dequeue ()=0 |
| virtual void | sendOut (cMessage *msg)=0 |
Protected Attributes | |
| int | packetRequested |
| int | numQueueReceived |
| int | numQueueDropped |
Abstract base class for passive queues. Implements IPassiveQueue. Enqueue/dequeue have to be implemented in virtual functions in subclasses; the actual queue or piority queue data structure also goes into subclasses.
Definition at line 32 of file PassiveQueueBase.h.
| virtual cMessage* PassiveQueueBase::dequeue | ( | ) | [protected, pure virtual] |
Returns a packet from the queue, or NULL if the queue is empty.
Implemented in DropTailQoSQueue, DropTailQueue, and REDQueue.
Referenced by requestPacket().
| virtual bool PassiveQueueBase::enqueue | ( | cMessage * | msg | ) | [protected, pure virtual] |
Inserts packet into the queue or the priority queue, or drops it (or another packet). Returns true if a packet was dropped.
Implemented in DropTailQoSQueue, DropTailQueue, and REDQueue.
Referenced by handleMessage().
| void PassiveQueueBase::finish | ( | ) | [protected, virtual] |
Reimplemented in REDQueue.
Definition at line 74 of file PassiveQueueBase.cc.
{
recordScalar("packets received by queue", numQueueReceived);
recordScalar("packets dropped by queue", numQueueDropped);
}
| void PassiveQueueBase::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Definition at line 36 of file PassiveQueueBase.cc.
{
numQueueReceived++;
if (packetRequested>0)
{
packetRequested--;
sendOut(msg);
}
else
{
bool dropped = enqueue(msg);
if (dropped)
numQueueDropped++;
}
if (ev.isGUI())
{
char buf[40];
sprintf(buf, "q rcvd: %d\nq dropped: %d", numQueueReceived, numQueueDropped);
getDisplayString().setTagArg("t",0,buf);
}
}
| void PassiveQueueBase::initialize | ( | ) | [protected, virtual] |
Reimplemented in DropTailQoSQueue, DropTailQueue, and REDQueue.
Definition at line 23 of file PassiveQueueBase.cc.
{
// state
packetRequested = 0;
WATCH(packetRequested);
// statistics
numQueueReceived = 0;
numQueueDropped = 0;
WATCH(numQueueReceived);
WATCH(numQueueDropped);
}
| void PassiveQueueBase::requestPacket | ( | ) | [virtual] |
The queue should send a packet whenever this method is invoked. If the queue is currently empty, it should send a packet when when one becomes available.
Implements IPassiveQueue.
Definition at line 59 of file PassiveQueueBase.cc.
{
Enter_Method("requestPacket()");
cMessage *msg = dequeue();
if (msg==NULL)
{
packetRequested++;
}
else
{
sendOut(msg);
}
}
| virtual void PassiveQueueBase::sendOut | ( | cMessage * | msg | ) | [protected, pure virtual] |
Should be redefined to send out the packet; e.g. send(msg,"out").
Implemented in DropTailQoSQueue, DropTailQueue, and REDQueue.
Referenced by handleMessage(), and requestPacket().
int PassiveQueueBase::numQueueDropped [protected] |
Definition at line 40 of file PassiveQueueBase.h.
Referenced by finish(), handleMessage(), and initialize().
int PassiveQueueBase::numQueueReceived [protected] |
Definition at line 39 of file PassiveQueueBase.h.
Referenced by finish(), handleMessage(), and initialize().
int PassiveQueueBase::packetRequested [protected] |
Definition at line 36 of file PassiveQueueBase.h.
Referenced by handleMessage(), initialize(), and requestPacket().
1.7.1