EtherMAC2 Class Reference

#include <EtherMAC2.h>

Inheritance diagram for EtherMAC2:

EtherMACBase List of all members.

Detailed Description

EtherMAC2 implementation.


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 (cMessage *msg)
virtual void handleEndIFGPeriod ()
virtual void handleEndTxPeriod ()


Constructor & Destructor Documentation

EtherMAC2::EtherMAC2 (  ) 

00030 {
00031 }


Member Function Documentation

void EtherMAC2::handleEndIFGPeriod (  )  [protected, virtual]

Reimplemented from EtherMACBase.

00148 {
00149     EtherMACBase::handleEndIFGPeriod();
00150 
00151     startFrameTransmission();
00152 }

void EtherMAC2::handleEndTxPeriod (  )  [protected, virtual]

Reimplemented from EtherMACBase.

00155 {
00156     fireChangeNotification(NF_PP_TX_END, (cMessage *)txQueue.tail());
00157 
00158     if (checkAndScheduleEndPausePeriod())
00159         return;
00160 
00161     EtherMACBase::handleEndTxPeriod();
00162 
00163     beginSendFrames();
00164 }

void EtherMAC2::handleMessage ( cMessage *  msg  )  [protected, virtual]

00070 {
00071     if (!connected)
00072         processMessageWhenNotConnected(msg);
00073     else if (disabled)
00074         processMessageWhenDisabled(msg);
00075     else if (msg->isSelfMessage())
00076     {
00077         EV << "Self-message " << msg << " received\n";
00078 
00079         if (msg == endTxMsg)
00080             handleEndTxPeriod();
00081         else if (msg == endIFGMsg)
00082             handleEndIFGPeriod();
00083         else if (msg == endPauseMsg)
00084             handleEndPausePeriod();
00085         else
00086             error("Unknown self message received!");
00087     }
00088     else
00089     {
00090         if (msg->arrivalGate() == gate("upperLayerIn"))
00091             processFrameFromUpperLayer(check_and_cast<EtherFrame *>(msg));
00092         else if (msg->arrivalGate() == gate("physIn"))
00093             processMsgFromNetwork(check_and_cast<EtherFrame *>(msg));
00094         else
00095             error("Message received from unknown gate!");
00096     }
00097 
00098     if (ev.isGUI())  updateDisplayString();
00099 }

void EtherMAC2::initialize (  )  [protected, virtual]

Reimplemented from EtherMACBase.

00034 {
00035     EtherMACBase::initialize();
00036 
00037     duplexMode = true;
00038     calculateParameters();
00039 
00040     beginSendFrames();
00041 }

void EtherMAC2::initializeTxrate (  )  [protected, virtual]

Implements EtherMACBase.

00044 {
00045     // if we're connected, find the gate with transmission rate
00046     cGate *g = gate("physOut");
00047     txrate = 0;
00048 
00049     if (connected)
00050     {
00051         // obtain txrate from channel. As a side effect, this also asserts
00052         // that the other end is an EtherMAC2, since normal EtherMAC
00053         // insists that the connection has *no* datarate set.
00054         while (g)
00055         {
00056             // does this gate have data rate?
00057             cSimpleChannel *chan = dynamic_cast<cSimpleChannel*>(g->channel());
00058             if (chan && (txrate=chan->datarate())>0)
00059                 break;
00060             // otherwise just check next connection in path
00061             g = g->toGate();
00062         }
00063 
00064         if (!g)
00065             error("gate physOut must be connected (directly or indirectly) to a link with data rate");
00066     }
00067 }

void EtherMAC2::processFrameFromUpperLayer ( EtherFrame frame  )  [protected, virtual]

Reimplemented from EtherMACBase.

00129 {
00130     EtherMACBase::processFrameFromUpperLayer(frame);
00131 
00132     if (transmitState == TX_IDLE_STATE)
00133         startFrameTransmission();
00134 }

void EtherMAC2::processMsgFromNetwork ( cMessage *  msg  )  [protected, virtual]

Reimplemented from EtherMACBase.

00137 {
00138     EtherMACBase::processMsgFromNetwork(msg);
00139     EtherFrame *frame = check_and_cast<EtherFrame *>(msg);
00140 
00141     fireChangeNotification(NF_PP_RX_END, frame);
00142 
00143     if (checkDestinationAddress(frame))
00144         frameReceptionComplete(frame);
00145 }

void EtherMAC2::startFrameTransmission (  )  [protected, virtual]

00102 {
00103     EtherFrame *origFrame = (EtherFrame *)txQueue.tail();
00104     EV << "Transmitting a copy of frame " << origFrame << endl;
00105 
00106     EtherFrame *frame = (EtherFrame *) origFrame->dup();
00107     frame->addByteLength(PREAMBLE_BYTES+SFD_BYTES);
00108 
00109     fireChangeNotification(NF_PP_TX_BEGIN, frame);
00110 
00111     // fill in src address if not set
00112     if (frame->getSrc().isUnspecified())
00113         frame->setSrc(address);
00114 
00115     // send
00116     EV << "Starting transmission of " << frame << endl;
00117     send(frame, "physOut");
00118     scheduleEndTxPeriod(frame);
00119 
00120     // update burst variables
00121     if (frameBursting)
00122     {
00123         bytesSentInBurst = frame->byteLength();
00124         framesSentInBurst++;
00125     }
00126 }


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:19 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7