TTEthernet Model for INET Framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
TTEthernetModel::QueueBuffer Class Reference

Base class for a queuing buffer class. More...

#include <QueueBuffer.h>

Inheritance diagram for TTEthernetModel::QueueBuffer:
TTEthernetModel::Buffer TTEthernetModel::BGQueueBuffer TTEthernetModel::RCQueueBuffer TTEthernetModel::TTQueueBuffer

Public Member Functions

 QueueBuffer ()
 Constructor for the class. More...
 
 ~QueueBuffer ()
 Destructor for the class. More...
 
- Public Member Functions inherited from TTEthernetModel::Buffer
 ~Buffer ()
 Destructor. More...
 
virtual void handleParameterChange (const char *parname)
 Indicates a parameter has changed. More...
 
EtherFrame * getFrame ()
 Wrapper function arround dequeue(). More...
 
void putFrame (EtherFrame *frame)
 Wrapper function arround enqueue(). More...
 
void addReceiveCallback (Callback *cb, TTEApplicationBase *application)
 Adds a receive callback for an application to the buffer. More...
 
CallbackgetReceiveCallback (TTEApplicationBase *application)
 Returns the currently registered receive callback for an application. More...
 
void addTransmitCallback (Callback *cb, TTEApplicationBase *application)
 Adds a transmit callback for an application to the buffer. More...
 
CallbackgetTransmitCallback (TTEApplicationBase *application)
 Returns the currently registered transmit callback for an application. More...
 

Protected Member Functions

virtual void enqueue (EtherFrame *newFrame)
 Inserts EtherFrame in the Queue and emits the queue length. More...
 
virtual EtherFrame * dequeue ()
 Removes and returns an EtherFrame from the Queue and emits the queue length. More...
 
- Protected Member Functions inherited from TTEthernetModel::Buffer
virtual void initialize (int stage)
 Initializes the module. More...
 
virtual int numInitStages () const
 Returns the numer of initializaiton stages this module needs. More...
 
void handleMessage (cMessage *msg)
 Is called when a new Frame is received in the buffer. More...
 
void recordPacketSent ()
 Emits a statistics signal that a frame was sent from the buffer. More...
 
void setIsEmpty (bool empty)
 Sets the status of the Buffer to empty or non-empty. More...
 

Static Protected Attributes

static simsignal_t queueLengthSignal = SIMSIGNAL_NULL
 Signal containing the queue length, that is emitted every time a frame was inserted or removed. More...
 
static simsignal_t ctDroppedSignal = SIMSIGNAL_NULL
 Signal that is emitted when a frame is dropped. More...
 
- Static Protected Attributes inherited from TTEthernetModel::Buffer
static simsignal_t txPkSignal = SIMSIGNAL_NULL
 Signal that is emitted every time a frame was sent. More...
 
static simsignal_t latencySignal = SIMSIGNAL_NULL
 Signal that contains the latency until the frame enters the buffer. More...
 

Private Member Functions

virtual void initializeStatistics ()
 Initializes the statistics for the Queue. More...
 

Private Attributes

cQueue frames
 Queue for the EtherFrames in the Buffer. More...
 

Additional Inherited Members

- Protected Attributes inherited from TTEthernetModel::Buffer
std::list< cGate * > destinationGates
 Stores the Gates to that the messages are delivered. More...
 
std::map< TTEApplicationBase
*, Callback * > 
receiveCallbacks
 Stores the callbacks that are executed when a frame is added to the buffer. More...
 
std::map< TTEApplicationBase
*, Callback * > 
transmitCallbacks
 Stores the callbacks that are executed when a frame is removed from the buffer. More...
 

Detailed Description

Base class for a queuing buffer class.

The queue is an endless fifo queue.

Use the implementations BGQueueBuffer, TTQueueBuffer, RCQueueBuffer.

See Also
BGQueueBuffer, TTQueueBuffer, RCQueueBuffer, Buffer

Definition at line 35 of file QueueBuffer.h.

Constructor & Destructor Documentation

TTEthernetModel::QueueBuffer::QueueBuffer ( )

Constructor for the class.

executes initializeStatistics()

See Also
initializeStatistics()

Definition at line 23 of file QueueBuffer.cc.

24 {
26 }
TTEthernetModel::QueueBuffer::~QueueBuffer ( )

Destructor for the class.

Definition at line 28 of file QueueBuffer.cc.

29 {
30  frames.clear();
31 }

Member Function Documentation

EtherFrame * TTEthernetModel::QueueBuffer::dequeue ( )
protectedvirtual

Removes and returns an EtherFrame from the Queue and emits the queue length.

Returns
Aa pointer to the EtherFrame removed from the queue.

Reimplemented from TTEthernetModel::Buffer.

Definition at line 68 of file QueueBuffer.cc.

69 {
70  if (frames.length() > 0)
71  {
72  setIsEmpty(frames.length() - 1 == 0);
73  emit(queueLengthSignal, frames.length() - 1);
74  return (EtherFrame*) frames.pop();
75  }
76  else
77  return NULL;
78 }
void TTEthernetModel::QueueBuffer::enqueue ( EtherFrame *  newFrame)
protectedvirtual

Inserts EtherFrame in the Queue and emits the queue length.

Parameters
newFramea pointer to the EtherFrame to insert in the queue.

Reimplemented from TTEthernetModel::Buffer.

Definition at line 40 of file QueueBuffer.cc.

41 {
42  int size = par("size").longValue();
43  if(size>=0 && frames.length()>=size){
44  emit(ctDroppedSignal, 1);
45  if(ev.isGUI()){
46  bubble("buffer overflow - dropping frame");
47  getDisplayString().setTagArg("i2", 0, "status/excl3");
48  getDisplayString().setTagArg("tt", 0, "WARNING: buffer overflow");
49  getParentModule()->getDisplayString().setTagArg("i2", 0, "status/excl3");
50  getParentModule()->getDisplayString().setTagArg("tt", 0, "WARNING: buffer overflow");
51  }
52  if(par("drop_new").boolValue())
53  {
54  delete newFrame;
55  return;
56  }
57  else
58  {
59  EtherFrame *oldFrame = (EtherFrame *)frames.pop();
60  delete oldFrame;
61  }
62  }
63  frames.insert(newFrame);
64  setIsEmpty(frames.length() == 0);
65  emit(queueLengthSignal, frames.length());
66 }
void TTEthernetModel::QueueBuffer::initializeStatistics ( )
privatevirtual

Initializes the statistics for the Queue.

Definition at line 33 of file QueueBuffer.cc.

Referenced by QueueBuffer().

34 {
35  queueLengthSignal = registerSignal("queueLength");
36  ctDroppedSignal = registerSignal("ctDropped");
37  frames.setName("frames");
38 }

Member Data Documentation

simsignal_t TTEthernetModel::QueueBuffer::ctDroppedSignal = SIMSIGNAL_NULL
staticprotected

Signal that is emitted when a frame is dropped.

Frames may be dropped when frame arrives at a full buffer.

Definition at line 88 of file QueueBuffer.h.

Referenced by enqueue(), and initializeStatistics().

cQueue TTEthernetModel::QueueBuffer::frames
private

Queue for the EtherFrames in the Buffer.

Definition at line 55 of file QueueBuffer.h.

Referenced by dequeue(), enqueue(), initializeStatistics(), and ~QueueBuffer().

simsignal_t TTEthernetModel::QueueBuffer::queueLengthSignal = SIMSIGNAL_NULL
staticprotected

Signal containing the queue length, that is emitted every time a frame was inserted or removed.

Definition at line 82 of file QueueBuffer.h.

Referenced by dequeue(), enqueue(), and initializeStatistics().


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