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

Base class for all critical traffic buffer classes. More...

#include <CTBuffer.h>

Inheritance diagram for TTEthernetModel::CTBuffer:
TTEthernetModel::Buffer TTEthernetModel::RCBuffer TTEthernetModel::TTBuffer TTEthernetModel::RCDoubleBuffer TTEthernetModel::RCQueueBuffer TTEthernetModel::TTDoubleBuffer TTEthernetModel::TTQueueBuffer

Public Member Functions

 ~CTBuffer ()
 Destructor. More...
 
virtual void handleParameterChange (const char *parname)
 Indicates a parameter has changed. More...
 
void putFrame (EtherFrame *frame)
 Wrapper function arround enqueue(). More...
 
- Public Member Functions inherited from TTEthernetModel::Buffer
 ~Buffer ()
 Destructor. 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

void handleMessage (cMessage *msg)
 Is called when a new Frame is received in the buffer. 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...
 
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

uint32_t ctMask
 caches ct_mask parameter More...
 
uint32_t ctMarker
 caches ct_marker parameter More...
 
uint16_t ctId
 caches ct_id parameter More...
 
- 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...
 

Additional Inherited Members

- 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...
 

Detailed Description

Base class for all critical traffic buffer classes.

CTBuffer, 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:

  • void enqueue(EtherFrame <em>newFrame)
  • EtherFrame dequeue()

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.

Definition at line 44 of file CTBuffer.h.

Constructor & Destructor Documentation

CTBuffer::~CTBuffer ( )

Destructor.

Definition at line 27 of file CTBuffer.cc.

27  {
28 }

Member Function Documentation

void CTBuffer::handleMessage ( cMessage *  msg)
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.

Parameters
msgThe incoming message

Definition at line 38 of file CTBuffer.cc.

Referenced by TTEthernetModel::TTBuffer::handleMessage(), and TTEthernetModel::RCBuffer::handleMessage().

39 {
40  if (msg->arrivedOn("in"))
41  {
42  CTFrame *ctframe = dynamic_cast<CTFrame *>(msg);
43  //Try to correct destination mac
44  if(ctframe != NULL){
45  if(ctframe->getDest().isUnspecified()){
46  ctframe->setCtID(ctId);
47  ctframe->setCtMarker(ctMarker & ctMask);
48  }
49  else if(ctframe->getCtMarker()==0){
50  ctframe->setCtMarker(ctMarker & ctMask);
51  }
52  }
54  }
55 }
void CTBuffer::handleParameterChange ( const char *  parname)
virtual

Indicates a parameter has changed.

Parameters
parnameName of the changed parameter or NULL if multiple parameter changed.

Reimplemented from TTEthernetModel::Buffer.

Reimplemented in TTEthernetModel::RCBuffer, and TTEthernetModel::TTBuffer.

Definition at line 57 of file CTBuffer.cc.

Referenced by TTEthernetModel::TTBuffer::handleParameterChange(), and TTEthernetModel::RCBuffer::handleParameterChange().

57  {
58  ctMask = (uint32_t)par("ct_mask").longValue();
59  ctMarker = (uint32_t)par("ct_marker").longValue();
60  ctId = (uint16_t)par("ct_id").longValue();
61 
63 }
void CTBuffer::putFrame ( EtherFrame *  frame)

Wrapper function arround enqueue().

Parameters
framethe EtherFrame to put in the buffer.
See Also
enqueue();

Definition at line 30 of file CTBuffer.cc.

30  {
31  int priority = par("priority").longValue();
32  if(frame && priority>=0){
33  frame->setSchedulingPriority(priority);
34  }
35  enqueue(frame);
36 }

Member Data Documentation

uint16_t TTEthernetModel::CTBuffer::ctId
protected

caches ct_id parameter

Definition at line 71 of file CTBuffer.h.

Referenced by handleMessage(), and handleParameterChange().

uint32_t TTEthernetModel::CTBuffer::ctMarker
protected

caches ct_marker parameter

Definition at line 67 of file CTBuffer.h.

Referenced by handleMessage(), and handleParameterChange().

uint32_t TTEthernetModel::CTBuffer::ctMask
protected

caches ct_mask parameter

Definition at line 63 of file CTBuffer.h.

Referenced by handleMessage(), and handleParameterChange().


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