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

Represents the part of a port that receives messages (RX) More...

#include <TTEInput.h>

Inheritance diagram for TTEthernetModel::TTEInput:

Public Member Functions

 TTEInput ()
 Constructor. More...
 
virtual void handleParameterChange (const char *parname)
 Indicates a parameter has changed. More...
 

Protected Member Functions

virtual void initialize ()
 Adds an incoming module to the list. More...
 
virtual void handleMessage (cMessage *msg)
 Forwards frames to the appropriate incoming modules. More...
 

Protected Attributes

bool hadError
 set to true if there was an error during runtime More...
 

Static Protected Attributes

static simsignal_t ctDroppedSignal = SIMSIGNAL_NULL
 Signal that is emitted when a frame is dropped. More...
 

Private Member Functions

virtual bool isCT (EtherFrame *frame)
 Helper function checks whether a Frame is critical traffic. More...
 
virtual uint16_t getCTID (EtherFrame *frame)
 Returns the critical traffic id for a given frame. More...
 

Private Attributes

std::map< uint16_t, std::list
< Incoming * > > 
incomings
 Lists of incoming modules for each critical traffic id. More...
 
uint32_t ctMask
 caches ct_mask parameter More...
 
uint32_t ctMarker
 caches ct_marker parameter More...
 
bool promiscuous
 caches promiscuous parameter More...
 

Detailed Description

Represents the part of a port that receives messages (RX)

*Critical traffic arriving on in-gate is forwarded to the incoming modules or dropped if there is no module configured. Best-effort frames are forwarded through the out-gate.

Definition at line 39 of file TTEInput.h.

Constructor & Destructor Documentation

TTEInput::TTEInput ( )

Constructor.

Definition at line 29 of file TTEInput.cc.

29  {
30  hadError=false;
31 }

Member Function Documentation

uint16_t TTEInput::getCTID ( EtherFrame *  frame)
privatevirtual

Returns the critical traffic id for a given frame.

Warning
does not check if it is really critical traffic. If you need to be sure use isCT(EtherFrame *frame)
Parameters
framePointer to the frame to get critical traffic id from.
Returns
critical traffic id
See Also
isCT(EtherFrame *frame)

Definition at line 168 of file TTEInput.cc.

Referenced by handleMessage().

169 {
170  unsigned char macBytes[6];
171  frame->getDest().getAddressBytes(macBytes);
172  return (macBytes[4] << 8) | macBytes[5];
173 }
void TTEInput::handleMessage ( cMessage *  msg)
protectedvirtual

Forwards frames to the appropriate incoming modules.

Critical traffic arriving on in-gate is forwarded to the incoming modules or dropped if there is no module configured. Best-effort frames are forwarded through the out-gate. The function timestamps messages using the received and received_total parameters.

Parameters
msgincoming message

Definition at line 43 of file TTEInput.cc.

44 {
45  if (msg->arrivedOn("in"))
46  {
47  EtherFrame *frame = (EtherFrame*) msg;
48 
49  int i = msg->findPar("received");
50  cMsgPar* par;
51  if( i >=0 )
52  par = &msg->par(i);
53  else
54  par = &msg->addPar("received");
55  par->setLongValue(((TTEScheduler*)getParentModule()->getParentModule()->getSubmodule("tteScheduler"))->getTicks());
56 
57  i = msg->findPar("received_total");
58  if( i >=0 )
59  par = &msg->par(i);
60  else
61  par = &msg->addPar("received_total");
62  par->setLongValue(((TTEScheduler*)getParentModule()->getParentModule()->getSubmodule("tteScheduler"))->getTotalTicks());
63 
64 
65  i = msg->findPar("received_port");
66  if( i >=0 )
67  par = &msg->par(i);
68  else
69  par = &msg->addPar("received_port");
70  par->setLongValue(getParentModule()->getIndex());
71 
72  //Auf CTCs verteilen oder BE traffic
73  if (isCT(frame))
74  {
75  std::map<uint16_t, std::list<Incoming *> >::iterator incomingList = incomings.find(getCTID(frame));
76  if (incomingList != incomings.end())
77  {
78  //Send to all CTCs for the CT-ID
79  for (std::list<Incoming*>::iterator incoming = incomingList->second.begin(); incoming
80  != incomingList->second.end(); incoming++)
81  {
82  sendDirect(frame->dup(), (*incoming)->gate("in"));
83  }
84  delete frame;
85  }
86  else
87  {
88  emit(ctDroppedSignal, 1);
89  hadError=true;
90  if(ev.isGUI()){
91  bubble("No matching buffer configured");
92  getDisplayString().setTagArg("i2", 0, "status/excl3");
93  getDisplayString().setTagArg("tt", 0, "WARNING: Input configuration problem - No matching buffer configured");
94  getParentModule()->getDisplayString().setTagArg("i2", 0, "status/excl3");
95  getParentModule()->getDisplayString().setTagArg("tt", 0, "WARNING: Input configuration problem - No matching buffer configured");
96  getParentModule()->getParentModule()->getDisplayString().setTagArg("i2", 0, "status/excl3");
97  getParentModule()->getParentModule()->getDisplayString().setTagArg("tt", 0, "WARNING: Input configuration problem - No matching buffer configured");
98  }
99  delete frame;
100  }
101  }
102  //Sonst BE
103  else
104  {
105  if(promiscuous || frame->getDest().isMulticast()){
106  send(msg, "out");
107  }
108  else{
109  MACAddress address;
110  address.setAddress(frame->getArrivalGate()->getPathStartGate()->getOwnerModule()->par("address"));
111  if(frame->getDest().equals(address)){
112  send(msg, "out");
113  }
114  else{
115  delete msg;
116  }
117  }
118  }
119  }
120 }
void TTEInput::handleParameterChange ( const char *  parname)
virtual

Indicates a parameter has changed.

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

Definition at line 122 of file TTEInput.cc.

122  {
123  ctMask = (uint32_t)par("ct_mask").longValue();
124  ctMarker = (uint32_t)par("ct_marker").longValue();
125  promiscuous = par("promiscuous").boolValue();
126 
127  incomings.clear();
128 
129  std::string incomingsString = par("incomings").stdstringValue();
130  std::vector<std::string> incomingPaths;
131  split(incomingsString,',',incomingPaths);
132  for(std::vector<std::string>::iterator incomingPath = incomingPaths.begin();
133  incomingPath!=incomingPaths.end();incomingPath++){
134  cModule* module = simulation.getModuleByPath((*incomingPath).c_str());
135  if(module){
136  Incoming *incoming = dynamic_cast<Incoming*> (module);
137  if(incoming){
138  Buffer *buffer = dynamic_cast<Buffer*> (incoming->gate("out")->getPathEndGate()->getOwner());
139  if(buffer && buffer->hasPar("ct_id")){
140  incomings[buffer->par("ct_id").longValue()].push_back(incoming);
141  }
142  }
143  }
144  else{
145  if(ev.isGUI()){
146  ev<<"Configuration problem: Module "<<(*incomingPath)<<" could not be resolved or is no Incoming CTC Module, or module is not connected to a buffer!"<<endl;
147  getDisplayString().setTagArg("i2", 0, "status/excl3");
148  getDisplayString().setTagArg("tt", 0, "WARNING: Configuration Problem Input Buffers!");
149  }
150  }
151  }
152 }
void TTEInput::initialize ( )
protectedvirtual

Adds an incoming module to the list.

Parameters
ctIDcritical traffic id of the incoming module
incomingPointer to the Incoming module Initialization of the module

Definition at line 33 of file TTEInput.cc.

34 {
35  ctDroppedSignal = registerSignal("ctDropped");
36 }
bool TTEInput::isCT ( EtherFrame *  frame)
privatevirtual

Helper function checks whether a Frame is critical traffic.

Parameters
framePointer to the frame to check.
Returns
true if frame is critical, else false

Definition at line 154 of file TTEInput.cc.

Referenced by handleMessage().

155 {
156  unsigned char macBytes[6];
157  frame->getDest().getAddressBytes(macBytes);
158  //Check for ct
159  if ((((macBytes[0] << 24) | (macBytes[1] << 16) | (macBytes[2] << 8) | (macBytes[3])) & ctMask) == (ctMarker
160  & ctMask))
161  {
162  return true;
163  }
164  //TODO More checking ?
165  return false;
166 }

Member Data Documentation

simsignal_t TTEInput::ctDroppedSignal = SIMSIGNAL_NULL
staticprotected

Signal that is emitted when a frame is dropped.

Frames may be dropped when no incoming module is configured.

Definition at line 69 of file TTEInput.h.

Referenced by handleMessage(), and initialize().

uint32_t TTEthernetModel::TTEInput::ctMarker
private

caches ct_marker parameter

Definition at line 54 of file TTEInput.h.

Referenced by handleParameterChange(), and isCT().

uint32_t TTEthernetModel::TTEInput::ctMask
private

caches ct_mask parameter

Definition at line 50 of file TTEInput.h.

Referenced by handleParameterChange(), and isCT().

bool TTEthernetModel::TTEInput::hadError
protected

set to true if there was an error during runtime

Definition at line 63 of file TTEInput.h.

Referenced by handleMessage(), and TTEInput().

std::map<uint16_t, std::list<Incoming*> > TTEthernetModel::TTEInput::incomings
private

Lists of incoming modules for each critical traffic id.

Definition at line 45 of file TTEInput.h.

Referenced by handleMessage(), and handleParameterChange().

bool TTEthernetModel::TTEInput::promiscuous
private

caches promiscuous parameter

Definition at line 58 of file TTEInput.h.

Referenced by handleMessage(), and handleParameterChange().


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