#include <EtherMAC2.h>
Public Member Functions | |
EtherMAC2 () | |
Protected Member Functions | |
virtual void | initialize () |
virtual void | initializeTxrate () |
virtual void | handleMessage (cMessage *msg) |
virtual void | startFrameTransmission () |
virtual void | processFrameFromUpperLayer (EtherFrame *frame) |
virtual void | processMsgFromNetwork (cPacket *msg) |
virtual void | handleEndIFGPeriod () |
virtual void | handleEndTxPeriod () |
virtual void | updateHasSubcribers () |
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 and sent out one by one.
Definition at line 32 of file EtherMAC2.h.
EtherMAC2::EtherMAC2 | ( | ) |
Definition at line 28 of file EtherMAC2.cc.
{ }
void EtherMAC2::handleEndIFGPeriod | ( | ) | [protected, virtual] |
Reimplemented from EtherMACBase.
Definition at line 146 of file EtherMAC2.cc.
Referenced by handleMessage().
void EtherMAC2::handleEndTxPeriod | ( | ) | [protected, virtual] |
Reimplemented from EtherMACBase.
Definition at line 153 of file EtherMAC2.cc.
Referenced by handleMessage().
{ if (hasSubscribers) { // fire notification notifDetails.setPacket((cPacket *)txQueue.front()); nb->fireChangeNotification(NF_PP_TX_END, ¬ifDetails); } if (checkAndScheduleEndPausePeriod()) return; EtherMACBase::handleEndTxPeriod(); beginSendFrames(); }
void EtherMAC2::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Definition at line 58 of file EtherMAC2.cc.
{ if (!connected) processMessageWhenNotConnected(msg); else if (disabled) processMessageWhenDisabled(msg); else if (msg->isSelfMessage()) { EV << "Self-message " << msg << " received\n"; if (msg == endTxMsg) handleEndTxPeriod(); else if (msg == endIFGMsg) handleEndIFGPeriod(); else if (msg == endPauseMsg) handleEndPausePeriod(); else error("Unknown self message received!"); } else { if (msg->getArrivalGate() == gate("upperLayerIn")) processFrameFromUpperLayer(check_and_cast<EtherFrame *>(msg)); else if (msg->getArrivalGate() == gate("phys$i")) processMsgFromNetwork(check_and_cast<EtherFrame *>(msg)); else error("Message received from unknown gate!"); } if (ev.isGUI()) updateDisplayString(); }
void EtherMAC2::initialize | ( | ) | [protected, virtual] |
Reimplemented from EtherMACBase.
Definition at line 32 of file EtherMAC2.cc.
{ EtherMACBase::initialize(); duplexMode = true; calculateParameters(); beginSendFrames(); }
void EtherMAC2::initializeTxrate | ( | ) | [protected, virtual] |
Implements EtherMACBase.
Definition at line 42 of file EtherMAC2.cc.
{ // if we're connected, find the gate with transmission rate txrate = 0; if (connected) { // obtain txrate from channel. As a side effect, this also asserts // that the other end is an EtherMAC2, since normal EtherMAC // insists that the connection has *no* datarate set. // if we're connected, get the gate with transmission rate cChannel *datarateChannel = physOutGate->getTransmissionChannel(); txrate = datarateChannel->par("datarate").doubleValue(); } }
void EtherMAC2::processFrameFromUpperLayer | ( | EtherFrame * | frame | ) | [protected, virtual] |
Reimplemented from EtherMACBase.
Definition at line 122 of file EtherMAC2.cc.
Referenced by handleMessage().
{ EtherMACBase::processFrameFromUpperLayer(frame); if (transmitState == TX_IDLE_STATE) startFrameTransmission(); }
void EtherMAC2::processMsgFromNetwork | ( | cPacket * | msg | ) | [protected, virtual] |
Reimplemented from EtherMACBase.
Definition at line 130 of file EtherMAC2.cc.
Referenced by handleMessage().
{ EtherMACBase::processMsgFromNetwork(msg); EtherFrame *frame = check_and_cast<EtherFrame *>(msg); if (hasSubscribers) { // fire notification notifDetails.setPacket(frame); nb->fireChangeNotification(NF_PP_RX_END, ¬ifDetails); } if (checkDestinationAddress(frame)) frameReceptionComplete(frame); }
void EtherMAC2::startFrameTransmission | ( | ) | [protected, virtual] |
Definition at line 90 of file EtherMAC2.cc.
Referenced by handleEndIFGPeriod(), and processFrameFromUpperLayer().
{ EtherFrame *origFrame = (EtherFrame *)txQueue.front(); EV << "Transmitting a copy of frame " << origFrame << endl; EtherFrame *frame = (EtherFrame *) origFrame->dup(); frame->addByteLength(PREAMBLE_BYTES+SFD_BYTES); if (hasSubscribers) { // fire notification notifDetails.setPacket(frame); nb->fireChangeNotification(NF_PP_TX_BEGIN, ¬ifDetails); } // fill in src address if not set if (frame->getSrc().isUnspecified()) frame->setSrc(address); // send EV << "Starting transmission of " << frame << endl; send(frame, physOutGate); scheduleEndTxPeriod(frame); // update burst variables if (frameBursting) { bytesSentInBurst = frame->getByteLength(); framesSentInBurst++; } }
void EtherMAC2::updateHasSubcribers | ( | ) | [protected, virtual] |
Implements EtherMACBase.
Definition at line 170 of file EtherMAC2.cc.
{ hasSubscribers = nb->hasSubscribers(NF_PP_TX_BEGIN) || nb->hasSubscribers(NF_PP_TX_END) || nb->hasSubscribers(NF_PP_RX_END); }