Public Member Functions | Protected Member Functions

EtherMAC2 Class Reference

#include <EtherMAC2.h>

Inheritance diagram for EtherMAC2:
EtherMACBase INotifiable

List of all members.

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 ()

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 and sent out one by one.

Definition at line 32 of file EtherMAC2.h.


Constructor & Destructor Documentation

EtherMAC2::EtherMAC2 (  ) 

Definition at line 28 of file EtherMAC2.cc.

{
}


Member Function Documentation

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

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.

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

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, &notifDetails);
    }

    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, &notifDetails);
    }

    // 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]

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