TTEthernet Model for INET Framework
|
Base class for all buffer classes. More...
#include <Buffer.h>
Public Member Functions | |
~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... | |
Callback * | getReceiveCallback (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... | |
Callback * | getTransmitCallback (TTEApplicationBase *application) |
Returns the currently registered transmit callback for an application. More... | |
Protected Member Functions | |
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... | |
virtual void | enqueue (EtherFrame *newFrame) |
Is called to store an EtherFrame in the buffer. More... | |
virtual EtherFrame * | dequeue () |
Is called to get an EtherFrame from 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... | |
Protected Attributes | |
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... | |
Static Protected Attributes | |
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 | |
void | initializeStatistics () |
caches ct_mask parameter More... | |
Base class for all buffer classes.
Buffer, although packed with buffer-related functionality, does not do anything useful by itself: one has to subclass from it and redefine one or more virtual member functions to make it do useful work. These functions are:
enqueue(EtherFrame *newFrame) is called to queue a message in the buffer. It must be implemented according to the correct buffer behaviour.
dequeue() is called to get a frame from the buffer.
Buffer::~Buffer | ( | ) |
Destructor.
void Buffer::addReceiveCallback | ( | Callback * | cb, |
TTEApplicationBase * | application | ||
) |
Adds a receive callback for an application to the buffer.
The callback is registered for a specific application. Each application is allowed to only register one receive callback per buffer. Further calls overwrite the registered callback.
cb | the receive callback to be added. |
the | corresponding application that registers the callback |
Definition at line 75 of file Buffer.cc.
Referenced by TTEthernetModel::TTEAPIApplicationBase::tte_set_buf_var().
void Buffer::addTransmitCallback | ( | Callback * | cb, |
TTEApplicationBase * | application | ||
) |
Adds a transmit callback for an application to the buffer.
The callback is registered for a specific application. Each application is allowed to only register one transmit callback per buffer. Further calls overwrite the registered callback.
cb | the transmit callback to be added. |
the | corresponding application that registers the callback |
Definition at line 87 of file Buffer.cc.
Referenced by TTEthernetModel::TTEAPIApplicationBase::tte_set_buf_var().
|
protectedvirtual |
Is called to get an EtherFrame from the buffer.
This method must be implemented according to the buffer strategy.
Reimplemented in TTEthernetModel::QueueBuffer, and TTEthernetModel::DoubleBuffer.
Definition at line 154 of file Buffer.cc.
Referenced by getFrame(), and TTEthernetModel::BGBuffer::handleMessage().
|
protectedvirtual |
Is called to store an EtherFrame in the buffer.
This method must be implemented according to the buffer strategy.
newFrame | a pointer to the new EtherFrame to be saved in the buffer |
Reimplemented in TTEthernetModel::QueueBuffer, and TTEthernetModel::DoubleBuffer.
Definition at line 148 of file Buffer.cc.
Referenced by TTEthernetModel::CTBuffer::putFrame(), and putFrame().
EtherFrame * Buffer::getFrame | ( | ) |
Wrapper function arround dequeue().
Definition at line 99 of file Buffer.cc.
Referenced by TTEthernetModel::TTBuffer::handleMessage(), TTEthernetModel::RCBuffer::handleMessage(), and TTEthernetModel::TTEAPIApplicationBase::tte_open_input_buf().
Callback * Buffer::getReceiveCallback | ( | TTEApplicationBase * | application | ) |
Returns the currently registered receive callback for an application.
the | corresponding application that registered callbacks |
Definition at line 80 of file Buffer.cc.
Referenced by TTEthernetModel::TTEAPIApplicationBase::tte_get_buf_var(), and TTEthernetModel::TTEAPIApplicationBase::tte_set_buf_var().
Callback * Buffer::getTransmitCallback | ( | TTEApplicationBase * | application | ) |
Returns the currently registered transmit callback for an application.
the | corresponding application that registered callbacks |
Definition at line 92 of file Buffer.cc.
Referenced by TTEthernetModel::TTEAPIApplicationBase::tte_get_buf_var(), and TTEthernetModel::TTEAPIApplicationBase::tte_set_buf_var().
|
protected |
Is called when a new Frame is received in the buffer.
When a frame is received on the in-Gate it is processed. If the destination address is unspecified it is set according to the ct marker of the buffer. Afterwards it is enqueued using the buffer specific enqueue(EtherFrame *newFrame) method. In the end all registered receive callbacks are executed.
msg | The incoming message |
Definition at line 107 of file Buffer.cc.
Referenced by TTEthernetModel::BGBuffer::handleMessage(), and TTEthernetModel::CTBuffer::handleMessage().
|
virtual |
Indicates a parameter has changed.
parname | Name of the changed parameter or NULL if multiple parameter changed. |
Reimplemented in TTEthernetModel::RCBuffer, TTEthernetModel::TTBuffer, and TTEthernetModel::CTBuffer.
Definition at line 122 of file Buffer.cc.
Referenced by TTEthernetModel::CTBuffer::handleParameterChange().
|
protectedvirtual |
Initializes the module.
stage | the stages. Module initializes when stage==0 |
Reimplemented in TTEthernetModel::RCBuffer, and TTEthernetModel::TTBuffer.
Definition at line 40 of file Buffer.cc.
Referenced by TTEthernetModel::TTBuffer::initialize(), and TTEthernetModel::RCBuffer::initialize().
|
private |
caches ct_mask parameter
caches ct_marker parameter caches ct_id parameter Initializes the statistics for the module
Definition at line 48 of file Buffer.cc.
Referenced by initialize().
|
protectedvirtual |
Returns the numer of initializaiton stages this module needs.
Reimplemented in TTEthernetModel::RCBuffer, and TTEthernetModel::TTBuffer.
Definition at line 35 of file Buffer.cc.
Referenced by TTEthernetModel::RCBuffer::numInitStages().
void Buffer::putFrame | ( | EtherFrame * | frame | ) |
|
protected |
Emits a statistics signal that a frame was sent from the buffer.
Definition at line 54 of file Buffer.cc.
Referenced by TTEthernetModel::BGBuffer::handleMessage(), TTEthernetModel::TTBuffer::handleMessage(), and TTEthernetModel::RCBuffer::handleMessage().
|
protected |
Sets the status of the Buffer to empty or non-empty.
This method changes the GUI according to the buffer status.
Definition at line 59 of file Buffer.cc.
Referenced by TTEthernetModel::QueueBuffer::dequeue(), TTEthernetModel::QueueBuffer::enqueue(), TTEthernetModel::BGBuffer::initialize(), TTEthernetModel::TTBuffer::initialize(), and TTEthernetModel::RCBuffer::initialize().
|
protected |
Stores the Gates to that the messages are delivered.
Definition at line 66 of file Buffer.h.
Referenced by TTEthernetModel::BGBuffer::handleMessage(), TTEthernetModel::TTBuffer::handleMessage(), TTEthernetModel::RCBuffer::handleMessage(), handleParameterChange(), TTEthernetModel::RCBuffer::resetBag(), and ~Buffer().
|
staticprotected |
Signal that contains the latency until the frame enters the buffer.
Definition at line 224 of file Buffer.h.
Referenced by handleMessage(), and initializeStatistics().
|
protected |
Stores the callbacks that are executed when a frame is added to the buffer.
Definition at line 70 of file Buffer.h.
Referenced by addReceiveCallback(), getReceiveCallback(), handleMessage(), and ~Buffer().
|
protected |
Stores the callbacks that are executed when a frame is removed from the buffer.
Definition at line 74 of file Buffer.h.
Referenced by addTransmitCallback(), getTransmitCallback(), TTEthernetModel::BGBuffer::handleMessage(), TTEthernetModel::TTBuffer::handleMessage(), TTEthernetModel::RCBuffer::resetBag(), and ~Buffer().
|
staticprotected |
Signal that is emitted every time a frame was sent.
Definition at line 219 of file Buffer.h.
Referenced by initializeStatistics(), and recordPacketSent().