Public Member Functions | Public Attributes | Protected Member Functions

AlohaMacLayer Class Reference
[IEEE 802.15.4A - Classes that implement the IEEE 802.15.4A UWB PHY.macLayer - MAC layer modules]

this class implements a basic Aloha MAC protocol for an UWB-IR IEEE 802.15.4A transceiver to allow testing the PHY layer. More...

#include <AlohaMacLayer.h>

Inherits UWBIRMac.

Collaboration diagram for AlohaMacLayer:
Collaboration graph
[legend]

List of all members.

Public Member Functions

virtual void initialize (int stage)
 Initialization of the module and some variables.
virtual void finish ()
 Called when the simulation has finished.

Public Attributes

int minBE
int maxBE

Protected Member Functions

virtual MacPkt * encapsMsg (cPacket *msg)
 Encapsulate the NetwPkt into an MacPkt.
virtual void handleLowerMsg (cMessage *msg)

Detailed Description

this class implements a basic Aloha MAC protocol for an UWB-IR IEEE 802.15.4A transceiver to allow testing the PHY layer.

This is not a complete implementation of the IEEE 802.15.4A non beacon enabled mode !

Definition at line 38 of file AlohaMacLayer.h.


Member Function Documentation

MacPkt * AlohaMacLayer::encapsMsg ( cPacket *  netwPkt  )  [protected, virtual]

Encapsulate the NetwPkt into an MacPkt.

Encapsulates the received NetwPkt into a MacPkt and set all needed header fields.

Reimplemented from BaseMacLayer.

Definition at line 56 of file AlohaMacLayer.cc.

References NetwToMacControlInfo::getNextHopMac(), BaseMacLayer::headerLength, and BaseMacLayer::myMacAddr.

                                             {
    UWBIRMacPkt* encaps = new UWBIRMacPkt(msg->getName(), msg->getKind());
    encaps->setByteLength(headerLength);

    // copy dest address from the Control Info attached to the network
    // mesage by the network layer
    NetwToMacControlInfo* cInfo = static_cast<NetwToMacControlInfo*>(msg->removeControlInfo());

    debugEV <<"CInfo removed, mac addr="<< cInfo->getNextHopMac()<<endl;
    encaps->setDestAddr(cInfo->getNextHopMac());

    //delete the control info
    delete cInfo;

    //set the src address to own mac address
    encaps->setSrcAddr(myMacAddr);

    //encapsulate the network packet
    encaps->encapsulate(msg);

    prepareData(encaps);

    nbSentPackets++;

  return encaps;
}

void AlohaMacLayer::handleLowerMsg ( cMessage *  msg  )  [protected, virtual]

If message arrives from lower layer, check whether it is for us. Send it up if yes.

This basic implementation just forwards all message that are broadcast (destAddr = L2BROADCAST) or destined for this node (destAddr = nic module getId()) to the network layer

See also:
sendUp

Reimplemented from BaseMacLayer.

Definition at line 89 of file AlohaMacLayer.cc.

References BaseMacLayer::decapsMsg(), BaseMacLayer::myMacAddr, and BaseLayer::sendUp().

                                                {
    UWBIRMacPkt *mac = static_cast<UWBIRMacPkt *>(msg);

    if(validatePacket(mac)) {
        int dest = mac->getDestAddr();
        int src = mac->getSrcAddr();
        if ((dest == myMacAddr)) {
          debugEV << "message with mac addr " << src
                    << " for me (dest=" << dest
                    << ") -> forward packet to upper layer\n";
            sendUp(decapsMsg(mac));
        } else {
          debugEV << "message with mac addr " << src
                    << " not for me (dest=" << dest
                    << ") -> delete (my MAC=" << myMacAddr << ")\n";
            delete mac;
        }
    } else {
      debugEV << "Errors in message ; dropping mac packet." << endl;
        delete mac;
    }
}

void AlohaMacLayer::initialize ( int  stage  )  [virtual]

Initialization of the module and some variables.

First we have to initialize the module from which we derived ours, in this case BaseLayer.

Reimplemented from UWBIRMac.

Definition at line 30 of file AlohaMacLayer.cc.

References BaseMacLayer::myMacAddr, UWBIRMac::phy, Radio::RX, MacToPhyInterface::setRadioState(), and Radio::TX.

                                        {
  UWBIRMac::initialize(stage);
  if(stage == 1 && myMacAddr != 0) {
            phy->setRadioState(Radio::TX);
    } else if(stage == 1 && myMacAddr == 0) {
            phy->setRadioState(Radio::RX);
    }
}


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