INET Framework for OMNeT++/OMNEST
inet::EtherMACFullDuplex Class Reference

A simplified version of EtherMAC. More...

#include <EtherMACFullDuplex.h>

Inheritance diagram for inet::EtherMACFullDuplex:
inet::EtherMACBase inet::MACBase inet::ILifecycle

Public Member Functions

 EtherMACFullDuplex ()
 
- Public Member Functions inherited from inet::EtherMACBase
 EtherMACBase ()
 
virtual ~EtherMACBase ()
 
virtual MACAddress getMACAddress ()
 
double getTxRate ()
 
bool isActive ()
 
MACTransmitState getTransmitState ()
 
MACReceiveState getReceiveState ()
 
virtual bool handleOperationStage (LifecycleOperation *operation, int stage, IDoneCallback *doneCallback) override
 Perform one stage of a lifecycle operation. More...
 
- Public Member Functions inherited from inet::MACBase
 MACBase ()
 
virtual ~MACBase ()
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 

Protected Member Functions

virtual int numInitStages () const override
 
virtual void initialize (int stage) override
 
virtual void initializeStatistics () override
 
virtual void initializeFlags () override
 
virtual void handleMessage (cMessage *msg) override
 
virtual void finish () override
 
virtual void handleEndIFGPeriod ()
 
virtual void handleEndTxPeriod ()
 
virtual void handleEndPausePeriod ()
 
virtual void handleSelfMessage (cMessage *msg)
 
virtual void startFrameTransmission ()
 
virtual void processFrameFromUpperLayer (EtherFrame *frame)
 
virtual void processMsgFromNetwork (cPacket *pk)
 
virtual void processReceivedDataFrame (EtherFrame *frame)
 
virtual void processPauseCommand (int pauseUnits)
 
virtual void scheduleEndIFGPeriod ()
 
virtual void scheduleEndPausePeriod (int pauseUnits)
 
virtual void beginSendFrames ()
 
- Protected Member Functions inherited from inet::EtherMACBase
virtual void initializeMACAddress ()
 
virtual void initializeQueueModule ()
 
virtual bool dropFrameNotForUs (EtherFrame *frame)
 Checks destination address and drops the frame when frame is not for us; returns true if frame is dropped. More...
 
virtual void readChannelParameters (bool errorWhenAsymmetric)
 Calculates datarates, etc. More...
 
virtual void printParameters ()
 
virtual void getNextFrameFromQueue ()
 
virtual void requestNextFrameFromExtQueue ()
 
virtual void processConnectDisconnect ()
 
virtual EtherPhyFrameencapsulate (EtherFrame *phyFrame)
 
virtual EtherFramedecapsulate (EtherPhyFrame *phyFrame)
 
virtual InterfaceEntrycreateInterfaceEntry () override
 should create InterfaceEntry More...
 
virtual void flushQueue () override
 should clear queue and emit signal "dropPkFromHLIfaceDown" with entire packets More...
 
virtual void clearQueue () override
 should clear queue silently More...
 
virtual bool isUpperMsg (cMessage *msg) override
 should return true if the msg arrived from upper layer, else return false More...
 
virtual void refreshDisplay () const override
 
virtual void receiveSignal (cComponent *src, simsignal_t signalId, cObject *obj, cObject *details) override
 
virtual void refreshConnection ()
 
- Protected Member Functions inherited from inet::MACBase
void registerInterface ()
 
virtual void updateOperationalFlag (bool isNodeUp)
 
virtual bool isNodeUp ()
 
virtual void handleMessageWhenDown (cMessage *msg)
 

Protected Attributes

simtime_t totalSuccessfulRxTime
 
- Protected Attributes inherited from inet::EtherMACBase
const EtherDescrcurEtherDescr = nullptr
 
MACAddress address
 
bool connected = false
 
bool disabled = false
 
bool promiscuous = false
 
bool duplexMode = false
 
bool frameBursting = false
 
MacQueue txQueue
 
cChannel * transmissionChannel = nullptr
 
cGate * physInGate = nullptr
 
cGate * physOutGate = nullptr
 
cGate * upperLayerInGate = nullptr
 
bool channelsDiffer = false
 
MACTransmitState transmitState = (MACTransmitState)-1
 
MACReceiveState receiveState = (MACReceiveState)-1
 
simtime_t lastTxFinishTime
 
int pauseUnitsRequested = 0
 
EtherFramecurTxFrame = nullptr
 
cMessage * endTxMsg = nullptr
 
cMessage * endIFGMsg = nullptr
 
cMessage * endPauseMsg = nullptr
 
unsigned long numFramesSent = 0
 
unsigned long numFramesReceivedOK = 0
 
unsigned long numBytesSent = 0
 
unsigned long numBytesReceivedOK = 0
 
unsigned long numFramesFromHL = 0
 
unsigned long numDroppedPkFromHLIfaceDown = 0
 
unsigned long numDroppedIfaceDown = 0
 
unsigned long numDroppedBitError = 0
 
unsigned long numDroppedNotForUs = 0
 
unsigned long numFramesPassedToHL = 0
 
unsigned long numPauseFramesRcvd = 0
 
unsigned long numPauseFramesSent = 0
 
- Protected Attributes inherited from inet::MACBase
cModule * hostModule = nullptr
 
bool isOperational = false
 
InterfaceEntryinterfaceEntry = nullptr
 

Additional Inherited Members

- Public Types inherited from inet::EtherMACBase
enum  MACTransmitState {
  TX_IDLE_STATE = 1, WAIT_IFG_STATE, SEND_IFG_STATE, TRANSMITTING_STATE,
  JAMMING_STATE, BACKOFF_STATE, PAUSE_STATE
}
 
enum  MACReceiveState { RX_IDLE_STATE = 1, RECEIVING_STATE, RX_COLLISION_STATE, RX_RECONNECT_STATE }
 
- Static Public Attributes inherited from inet::EtherMACBase
static const double SPEED_OF_LIGHT_IN_CABLE = 200000000.0
 
static simsignal_t dropPkIfaceDownSignal = registerSignal("dropPkIfaceDown")
 
static simsignal_t dropPkFromHLIfaceDownSignal = registerSignal("dropPkFromHLIfaceDown")
 
- Protected Types inherited from inet::EtherMACBase
enum  SelfMsgKindValues {
  ENDIFG = 100, ENDRECEPTION, ENDBACKOFF, ENDTRANSMISSION,
  ENDJAMMING, ENDPAUSE
}
 
enum  { NUM_OF_ETHERDESCRS = 6 }
 
- Static Protected Attributes inherited from inet::EtherMACBase
static const EtherDescr etherDescrs [NUM_OF_ETHERDESCRS]
 
static const EtherDescr nullEtherDescr
 
static simsignal_t txPkSignal = registerSignal("txPk")
 
static simsignal_t rxPkOkSignal = registerSignal("rxPkOk")
 
static simsignal_t txPausePkUnitsSignal = registerSignal("txPausePkUnits")
 
static simsignal_t rxPausePkUnitsSignal = registerSignal("rxPausePkUnits")
 
static simsignal_t rxPkFromHLSignal = registerSignal("rxPkFromHL")
 
static simsignal_t dropPkNotForUsSignal = registerSignal("dropPkNotForUs")
 
static simsignal_t dropPkBitErrorSignal = registerSignal("dropPkBitError")
 
static simsignal_t packetSentToLowerSignal = registerSignal("packetSentToLower")
 
static simsignal_t packetReceivedFromLowerSignal = registerSignal("packetReceivedFromLower")
 
static simsignal_t packetSentToUpperSignal = registerSignal("packetSentToUpper")
 
static simsignal_t packetReceivedFromUpperSignal = registerSignal("packetReceivedFromUpper")
 
static simsignal_t transmitStateSignal = registerSignal("transmitState")
 
static simsignal_t receiveStateSignal = registerSignal("receiveState")
 

Detailed Description

A simplified version of EtherMAC.

Since modern Ethernets typically operate over duplex links where's no contention, the original CSMA/CD algorithm is no longer needed. This simplified implementation doesn't contain CSMA/CD, frames are just simply queued up and sent out one by one.

Constructor & Destructor Documentation

inet::EtherMACFullDuplex::EtherMACFullDuplex ( )
34 {
35 }

Member Function Documentation

void inet::EtherMACFullDuplex::beginSendFrames ( )
protectedvirtual

Referenced by handleEndIFGPeriod(), handleEndPausePeriod(), and initialize().

377 {
378  if (curTxFrame) {
379  // Other frames are queued, transmit next frame
380  EV_DETAIL << "Transmit next frame in output queue\n";
382  }
383  else {
384  // No more frames set transmitter to idle
387  if (!txQueue.extQueue) {
388  // Output only for internal queue (we cannot be shure that there
389  //are no other frames in external queue)
390  EV_DETAIL << "No more frames to send, transmitter set to idle\n";
391  }
392  }
393 }
MacQueue txQueue
Definition: EtherMACBase.h:141
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
static simsignal_t transmitStateSignal
Definition: EtherMACBase.h:186
IPassiveQueue * extQueue
Definition: EtherMACBase.h:116
Definition: EtherMACBase.h:47
MACTransmitState transmitState
Definition: EtherMACBase.h:149
virtual void startFrameTransmission()
Definition: EtherMACFullDuplex.cc:100
void inet::EtherMACFullDuplex::finish ( )
overrideprotectedvirtual

Reimplemented from inet::EtherMACBase.

299 {
301 
302  simtime_t t = simTime();
303  simtime_t totalRxChannelIdleTime = t - totalSuccessfulRxTime;
304  recordScalar("rx channel idle (%)", 100 * (totalRxChannelIdleTime / t));
305  recordScalar("rx channel utilization (%)", 100 * (totalSuccessfulRxTime / t));
306 }
simtime_t totalSuccessfulRxTime
Definition: EtherMACFullDuplex.h:65
virtual void finish() override
Definition: EtherMACBase.cc:600
void inet::EtherMACFullDuplex::handleEndIFGPeriod ( )
protectedvirtual

Referenced by handleSelfMessage().

245 {
246  ASSERT(nullptr == curTxFrame);
248  throw cRuntimeError("Not in WAIT_IFG_STATE at the end of IFG period");
249 
250  // End of IFG period, okay to transmit
251  EV_DETAIL << "IFG elapsed" << endl;
252 
254  beginSendFrames();
255 }
virtual void getNextFrameFromQueue()
Definition: EtherMACBase.cc:578
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
virtual void beginSendFrames()
Definition: EtherMACFullDuplex.cc:376
MACTransmitState transmitState
Definition: EtherMACBase.h:149
Definition: EtherMACBase.h:48
void inet::EtherMACFullDuplex::handleEndPausePeriod ( )
protectedvirtual

Referenced by handleSelfMessage().

309 {
310  ASSERT(nullptr == curTxFrame);
311  if (transmitState != PAUSE_STATE)
312  throw cRuntimeError("End of PAUSE event occurred when not in PAUSE_STATE!");
313 
314  EV_DETAIL << "Pause finished, resuming transmissions\n";
316  beginSendFrames();
317 }
virtual void getNextFrameFromQueue()
Definition: EtherMACBase.cc:578
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
virtual void beginSendFrames()
Definition: EtherMACFullDuplex.cc:376
Definition: EtherMACBase.h:53
MACTransmitState transmitState
Definition: EtherMACBase.h:149
void inet::EtherMACFullDuplex::handleEndTxPeriod ( )
protectedvirtual

Referenced by handleSelfMessage().

258 {
259  // we only get here if transmission has finished successfully
261  throw cRuntimeError("End of transmission, and incorrect state detected");
262 
263  if (nullptr == curTxFrame)
264  throw cRuntimeError("Frame under transmission cannot be found");
265 
266  emit(packetSentToLowerSignal, curTxFrame); //consider: emit with start time of frame
267 
268  if (dynamic_cast<EtherPauseFrame *>(curTxFrame) != nullptr) {
270  emit(txPausePkUnitsSignal, ((EtherPauseFrame *)curTxFrame)->getPauseTime());
271  }
272  else {
273  unsigned long curBytes = curTxFrame->getByteLength();
274  numFramesSent++;
275  numBytesSent += curBytes;
276  emit(txPkSignal, curTxFrame);
277  }
278 
279  EV_INFO << "Transmission of " << curTxFrame << " successfully completed.\n";
280  delete curTxFrame;
281  curTxFrame = nullptr;
282  lastTxFinishTime = simTime();
283 
284 
285  if (pauseUnitsRequested > 0) {
286  // if we received a PAUSE frame recently, go into PAUSE state
287  EV_DETAIL << "Going to PAUSE mode for " << pauseUnitsRequested << " time units\n";
288 
289  scheduleEndPausePeriod(pauseUnitsRequested);
290  pauseUnitsRequested = 0;
291  }
292  else {
293  EV_DETAIL << "Start IFG period\n";
295  }
296 }
simtime_t lastTxFinishTime
Definition: EtherMACBase.h:151
unsigned long numPauseFramesSent
Definition: EtherMACBase.h:170
unsigned long numFramesSent
Definition: EtherMACBase.h:159
static simsignal_t txPausePkUnitsSignal
Definition: EtherMACBase.h:174
virtual void scheduleEndPausePeriod(int pauseUnits)
Definition: EtherMACFullDuplex.cc:366
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
virtual void scheduleEndIFGPeriod()
Definition: EtherMACFullDuplex.cc:357
int pauseUnitsRequested
Definition: EtherMACBase.h:152
static simsignal_t packetSentToLowerSignal
Definition: EtherMACBase.h:181
unsigned long numBytesSent
Definition: EtherMACBase.h:161
MACTransmitState transmitState
Definition: EtherMACBase.h:149
static simsignal_t txPkSignal
Definition: EtherMACBase.h:172
Definition: EtherMACBase.h:50
void inet::EtherMACFullDuplex::handleMessage ( cMessage *  msg)
overrideprotectedvirtual
67 {
68  if (!isOperational) {
70  return;
71  }
72 
73  if (channelsDiffer)
75 
76  if (msg->isSelfMessage())
77  handleSelfMessage(msg);
78  else if (msg->getArrivalGate() == upperLayerInGate)
79  processFrameFromUpperLayer(check_and_cast<EtherFrame *>(msg));
80  else if (msg->getArrivalGate() == physInGate)
82  else
83  throw cRuntimeError("Message received from unknown gate!");
84 }
bool channelsDiffer
Definition: EtherMACBase.h:148
virtual void handleSelfMessage(cMessage *msg)
Definition: EtherMACFullDuplex.cc:86
cGate * physInGate
Definition: EtherMACBase.h:143
virtual void processFrameFromUpperLayer(EtherFrame *frame)
Definition: EtherMACFullDuplex.cc:124
bool isOperational
Definition: MACBase.h:37
virtual void handleMessageWhenDown(cMessage *msg)
Definition: MACBase.cc:108
virtual void readChannelParameters(bool errorWhenAsymmetric)
Calculates datarates, etc.
Definition: EtherMACBase.cc:495
cGate * upperLayerInGate
Definition: EtherMACBase.h:145
#define PK(msg)
Definition: INETDefs.h:92
virtual void processMsgFromNetwork(cPacket *pk)
Definition: EtherMACFullDuplex.cc:186
void inet::EtherMACFullDuplex::handleSelfMessage ( cMessage *  msg)
protectedvirtual

Referenced by handleMessage().

87 {
88  EV_TRACE << "Self-message " << msg << " received\n";
89 
90  if (msg == endTxMsg)
92  else if (msg == endIFGMsg)
94  else if (msg == endPauseMsg)
96  else
97  throw cRuntimeError("Unknown self message received!");
98 }
virtual void handleEndPausePeriod()
Definition: EtherMACFullDuplex.cc:308
cMessage * endIFGMsg
Definition: EtherMACBase.h:156
cMessage * endTxMsg
Definition: EtherMACBase.h:156
cMessage * endPauseMsg
Definition: EtherMACBase.h:156
virtual void handleEndIFGPeriod()
Definition: EtherMACFullDuplex.cc:244
virtual void handleEndTxPeriod()
Definition: EtherMACFullDuplex.cc:257
void inet::EtherMACFullDuplex::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::EtherMACBase.

38 {
40 
41  if (stage == INITSTAGE_LOCAL) {
42  if (!par("duplexMode").boolValue())
43  throw cRuntimeError("Half duplex operation is not supported by EtherMACFullDuplex, use the EtherMAC module for that! (Please enable csmacdSupport on EthernetInterface)");
44  }
45  else if (stage == INITSTAGE_LINK_LAYER) {
46  beginSendFrames(); //FIXME choose an another stage for it
47  }
48 }
Local initializations.
Definition: InitStages.h:35
Initialization of link-layer protocols.
Definition: InitStages.h:59
virtual void beginSendFrames()
Definition: EtherMACFullDuplex.cc:376
virtual void initialize(int stage) override
Definition: EtherMACBase.cc:152
void inet::EtherMACFullDuplex::initializeFlags ( )
overrideprotectedvirtual

Reimplemented from inet::EtherMACBase.

59 {
61 
62  duplexMode = true;
63  physInGate->setDeliverOnReceptionStart(false);
64 }
bool duplexMode
Definition: EtherMACBase.h:137
cGate * physInGate
Definition: EtherMACBase.h:143
virtual void initializeFlags()
Definition: EtherMACBase.cc:233
void inet::EtherMACFullDuplex::initializeStatistics ( )
overrideprotectedvirtual

Reimplemented from inet::EtherMACBase.

51 {
53 
54  // initialize statistics
56 }
simtime_t totalSuccessfulRxTime
Definition: EtherMACFullDuplex.h:65
virtual void initializeStatistics()
Definition: EtherMACBase.cc:260
virtual int inet::EtherMACFullDuplex::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::EtherMACBase.

39 { return NUM_INIT_STAGES; }
The number of initialization stages.
Definition: InitStages.h:116
void inet::EtherMACFullDuplex::processFrameFromUpperLayer ( EtherFrame frame)
protectedvirtual

Referenced by handleMessage().

125 {
126  ASSERT(frame->getByteLength() >= MIN_ETHERNET_FRAME_BYTES);
127 
128  EV_INFO << "Received " << frame << " from upper layer." << endl;
129 
130  emit(packetReceivedFromUpperSignal, frame);
131 
132  if (frame->getDest().equals(address)) {
133  throw cRuntimeError("logic error: frame %s from higher layer has local MAC address as dest (%s)",
134  frame->getFullName(), frame->getDest().str().c_str());
135  }
136 
137  if (frame->getByteLength() > MAX_ETHERNET_FRAME_BYTES) { //FIXME two MAX FRAME BYTES in specif...
138  throw cRuntimeError("packet from higher layer (%d bytes) exceeds maximum Ethernet frame size (%d)",
139  (int)(frame->getByteLength()), MAX_ETHERNET_FRAME_BYTES);
140  }
141 
142  if (!connected || disabled) {
143  EV_WARN << (!connected ? "Interface is not connected" : "MAC is disabled") << " -- dropping packet " << frame << endl;
144  emit(dropPkFromHLIfaceDownSignal, frame);
146  delete frame;
147 
149  return;
150  }
151 
152  // fill in src address if not set
153  if (frame->getSrc().isUnspecified())
154  frame->setSrc(address);
155 
156  bool isPauseFrame = (dynamic_cast<EtherPauseFrame *>(frame) != nullptr);
157 
158  if (!isPauseFrame) {
159  numFramesFromHL++;
160  emit(rxPkFromHLSignal, frame);
161  }
162 
163  if (txQueue.extQueue) {
164  ASSERT(curTxFrame == nullptr);
166  curTxFrame = frame;
167  }
168  else {
169  if (txQueue.innerQueue->isFull())
170  throw cRuntimeError("txQueue length exceeds %d -- this is probably due to "
171  "a bogus app model generating excessive traffic "
172  "(or if this is normal, increase txQueueLimit!)",
174  // store frame and possibly begin transmitting
175  EV_DETAIL << "Frame " << frame << " arrived from higher layers, enqueueing\n";
177 
179  curTxFrame = (EtherFrame *)txQueue.innerQueue->pop();
180  }
181 
184 }
bool connected
Definition: EtherMACBase.h:134
bool disabled
Definition: EtherMACBase.h:135
int getQueueLimit() const
Definition: EtherMACBase.h:106
MacQueue txQueue
Definition: EtherMACBase.h:141
InnerQueue * innerQueue
Definition: EtherMACBase.h:115
cObject * pop()
Definition: EtherMACBase.h:104
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
MACAddress address
Definition: EtherMACBase.h:133
#define MIN_ETHERNET_FRAME_BYTES
Definition: Ethernet.h:31
void insertFrame(cObject *obj)
Definition: EtherMACBase.h:103
unsigned long numFramesFromHL
Definition: EtherMACBase.h:163
static simsignal_t dropPkFromHLIfaceDownSignal
Definition: EtherMACBase.h:192
unsigned long numDroppedPkFromHLIfaceDown
Definition: EtherMACBase.h:164
IPassiveQueue * extQueue
Definition: EtherMACBase.h:116
static simsignal_t packetReceivedFromUpperSignal
Definition: EtherMACBase.h:184
static simsignal_t rxPkFromHLSignal
Definition: EtherMACBase.h:176
Definition: EtherMACBase.h:47
Definition: EtherMACBase.h:53
MACTransmitState transmitState
Definition: EtherMACBase.h:149
bool isFull() const
Definition: EtherMACBase.h:107
virtual void requestNextFrameFromExtQueue()
Definition: EtherMACBase.cc:591
bool isEmpty() const
Definition: EtherMACBase.h:105
virtual void startFrameTransmission()
Definition: EtherMACFullDuplex.cc:100
#define MAX_ETHERNET_FRAME_BYTES
Definition: Ethernet.h:30
void inet::EtherMACFullDuplex::processMsgFromNetwork ( cPacket *  pk)
protectedvirtual

Referenced by handleMessage().

187 {
188  EtherTraffic *msg = check_and_cast<EtherTraffic *>(pk);
189 
190  EV_INFO << msg << " received." << endl;
191 
192  if (!connected || disabled) {
193  EV_WARN << (!connected ? "Interface is not connected" : "MAC is disabled") << " -- dropping msg " << msg << endl;
194  if (EtherPhyFrame *phyFrame = dynamic_cast<EtherPhyFrame *>(msg)) { // do not count JAM and IFG packets
195  EtherFrame *frame = decapsulate(phyFrame);
196  emit(dropPkIfaceDownSignal, frame);
197  delete frame;
199  }
200  else
201  delete msg;
202 
203  return;
204  }
205 
206  EtherPhyFrame *phyFrame = dynamic_cast<EtherPhyFrame *>(msg);
207  if (!phyFrame) {
208  if (dynamic_cast<EtherFilledIFG *>(msg))
209  throw cRuntimeError("There is no burst mode in full-duplex operation: EtherFilledIFG is unexpected");
210  else
211  throw cRuntimeError("Unexpected ethernet traffic: %s", msg->getClassName());
212  }
213 
214  totalSuccessfulRxTime += phyFrame->getDuration();
215 
216  bool hasBitError = msg->hasBitError();
217 
218  EtherFrame *frame = decapsulate(phyFrame);
219  emit(packetReceivedFromLowerSignal, frame);
220 
221  if (hasBitError) {
223  emit(dropPkBitErrorSignal, frame);
224  delete frame;
225  return;
226  }
227 
228  if (dropFrameNotForUs(frame))
229  return;
230 
231  if (dynamic_cast<EtherPauseFrame *>(frame) != nullptr) {
232  int pauseUnits = ((EtherPauseFrame *)frame)->getPauseTime();
233  delete frame;
235  emit(rxPausePkUnitsSignal, pauseUnits);
236  processPauseCommand(pauseUnits);
237  }
238  else {
239  EV_INFO << "Reception of " << frame << " successfully completed." << endl;
240  processReceivedDataFrame((EtherFrame *)frame);
241  }
242 }
simtime_t totalSuccessfulRxTime
Definition: EtherMACFullDuplex.h:65
bool connected
Definition: EtherMACBase.h:134
bool disabled
Definition: EtherMACBase.h:135
static simsignal_t packetReceivedFromLowerSignal
Definition: EtherMACBase.h:182
virtual EtherFrame * decapsulate(EtherPhyFrame *phyFrame)
Definition: EtherMACBase.cc:399
unsigned long numDroppedIfaceDown
Definition: EtherMACBase.h:165
unsigned long numPauseFramesRcvd
Definition: EtherMACBase.h:169
virtual bool dropFrameNotForUs(EtherFrame *frame)
Checks destination address and drops the frame when frame is not for us; returns true if frame is dro...
Definition: EtherMACBase.cc:458
virtual void processPauseCommand(int pauseUnits)
Definition: EtherMACFullDuplex.cc:334
static simsignal_t dropPkBitErrorSignal
Definition: EtherMACBase.h:178
static simsignal_t dropPkIfaceDownSignal
Definition: EtherMACBase.h:191
static simsignal_t rxPausePkUnitsSignal
Definition: EtherMACBase.h:175
unsigned long numDroppedBitError
Definition: EtherMACBase.h:166
virtual void processReceivedDataFrame(EtherFrame *frame)
Definition: EtherMACFullDuplex.cc:319
void inet::EtherMACFullDuplex::processPauseCommand ( int  pauseUnits)
protectedvirtual

Referenced by processMsgFromNetwork().

335 {
336  if (transmitState == TX_IDLE_STATE) {
337  EV_DETAIL << "PAUSE frame received, pausing for " << pauseUnitsRequested << " time units\n";
338  if (pauseUnits > 0)
339  scheduleEndPausePeriod(pauseUnits);
340  }
341  else if (transmitState == PAUSE_STATE) {
342  EV_DETAIL << "PAUSE frame received, pausing for " << pauseUnitsRequested
343  << " more time units from now\n";
344  cancelEvent(endPauseMsg);
345 
346  if (pauseUnits > 0)
347  scheduleEndPausePeriod(pauseUnits);
348  }
349  else {
350  // transmitter busy -- wait until it finishes with current frame (endTx)
351  // and then it'll go to PAUSE state
352  EV_DETAIL << "PAUSE frame received, storing pause request\n";
353  pauseUnitsRequested = pauseUnits;
354  }
355 }
virtual void scheduleEndPausePeriod(int pauseUnits)
Definition: EtherMACFullDuplex.cc:366
cMessage * endPauseMsg
Definition: EtherMACBase.h:156
int pauseUnitsRequested
Definition: EtherMACBase.h:152
Definition: EtherMACBase.h:47
Definition: EtherMACBase.h:53
MACTransmitState transmitState
Definition: EtherMACBase.h:149
void inet::EtherMACFullDuplex::processReceivedDataFrame ( EtherFrame frame)
protectedvirtual

Referenced by processMsgFromNetwork().

320 {
321  // statistics
322  unsigned long curBytes = frame->getByteLength();
324  numBytesReceivedOK += curBytes;
325  emit(rxPkOkSignal, frame);
326 
328  emit(packetSentToUpperSignal, frame);
329  // pass up to upper layer
330  EV_INFO << "Sending " << frame << " to upper layer.\n";
331  send(frame, "upperLayerOut");
332 }
static simsignal_t rxPkOkSignal
Definition: EtherMACBase.h:173
unsigned long numFramesReceivedOK
Definition: EtherMACBase.h:160
static simsignal_t packetSentToUpperSignal
Definition: EtherMACBase.h:183
unsigned long numBytesReceivedOK
Definition: EtherMACBase.h:162
unsigned long numFramesPassedToHL
Definition: EtherMACBase.h:168
void inet::EtherMACFullDuplex::scheduleEndIFGPeriod ( )
protectedvirtual

Referenced by handleEndTxPeriod().

358 {
359  ASSERT(nullptr == curTxFrame);
362  simtime_t endIFGTime = simTime() + (INTERFRAME_GAP_BITS / curEtherDescr->txrate);
363  scheduleAt(endIFGTime, endIFGMsg);
364 }
cMessage * endIFGMsg
Definition: EtherMACBase.h:156
const EtherDescr * curEtherDescr
Definition: EtherMACBase.h:132
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
static simsignal_t transmitStateSignal
Definition: EtherMACBase.h:186
MACTransmitState transmitState
Definition: EtherMACBase.h:149
double txrate
Definition: EtherMACBase.h:80
#define INTERFRAME_GAP_BITS
Definition: Ethernet.h:33
Definition: EtherMACBase.h:48
void inet::EtherMACFullDuplex::scheduleEndPausePeriod ( int  pauseUnits)
protectedvirtual

Referenced by handleEndTxPeriod(), and processPauseCommand().

367 {
368  ASSERT(nullptr == curTxFrame);
369  // length is interpreted as 512-bit-time units
370  simtime_t pausePeriod = ((pauseUnits * PAUSE_UNIT_BITS) / curEtherDescr->txrate);
371  scheduleAt(simTime() + pausePeriod, endPauseMsg);
374 }
const EtherDescr * curEtherDescr
Definition: EtherMACBase.h:132
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
#define PAUSE_UNIT_BITS
Definition: Ethernet.h:47
cMessage * endPauseMsg
Definition: EtherMACBase.h:156
static simsignal_t transmitStateSignal
Definition: EtherMACBase.h:186
Definition: EtherMACBase.h:53
MACTransmitState transmitState
Definition: EtherMACBase.h:149
double txrate
Definition: EtherMACBase.h:80
void inet::EtherMACFullDuplex::startFrameTransmission ( )
protectedvirtual

Referenced by beginSendFrames(), and processFrameFromUpperLayer().

101 {
102  ASSERT(curTxFrame);
103  EV_DETAIL << "Transmitting a copy of frame " << curTxFrame << endl;
104 
105  EtherFrame *frame = curTxFrame->dup(); // note: we need to duplicate the frame because we emit a signal with it in endTxPeriod()
106  if (frame->getSrc().isUnspecified())
107  frame->setSrc(address);
108 
109  if (frame->getByteLength() < curEtherDescr->frameMinBytes)
110  frame->setByteLength(curEtherDescr->frameMinBytes); // extra padding
111 
112  // add preamble and SFD (Starting Frame Delimiter), then send out
113  EtherPhyFrame *phyFrame = encapsulate(frame);
114 
115  // send
116  EV_INFO << "Transmission of " << frame << " started.\n";
117  send(phyFrame, physOutGate);
118 
119  scheduleAt(transmissionChannel->getTransmissionFinishTime(), endTxMsg);
122 }
int64 frameMinBytes
Definition: EtherMACBase.h:82
const EtherDescr * curEtherDescr
Definition: EtherMACBase.h:132
cChannel * transmissionChannel
Definition: EtherMACBase.h:142
virtual EtherPhyFrame * encapsulate(EtherFrame *phyFrame)
Definition: EtherMACBase.cc:391
cMessage * endTxMsg
Definition: EtherMACBase.h:156
EtherFrame * curTxFrame
Definition: EtherMACBase.h:153
MACAddress address
Definition: EtherMACBase.h:133
static simsignal_t transmitStateSignal
Definition: EtherMACBase.h:186
virtual EtherFrame * dup() const override
Definition: EtherFrame_m.h:267
virtual void setSrc(const MACAddress &src)
MACTransmitState transmitState
Definition: EtherMACBase.h:149
Definition: EtherMACBase.h:50
cGate * physOutGate
Definition: EtherMACBase.h:144

Member Data Documentation

simtime_t inet::EtherMACFullDuplex::totalSuccessfulRxTime
protected

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