EPONImplementationforOMNet++  0.8Beta
ONUMacCtlBase Class Reference

#include <ONUMacCtlBase.h>

Inheritance diagram for ONUMacCtlBase:
ONUMacCtl_NP ONUMacCtl_P

List of all members.

Public Member Functions

 ONUMacCtlBase ()
virtual ~ONUMacCtlBase ()

Protected Member Functions

virtual void initialize ()
virtual void finish ()
 Log Scalars.
virtual void startTxOnPON ()=0
virtual void processFrameFromMAC (cMessage *msg)
virtual void processMPCP (EthernetIIFrame *frame)=0
virtual cModule * getNeighbourOnGate (const char *gate)
virtual void dumpReg ()
std::string getStateStr ()

Protected Attributes

uint64_t txrate
 Tx Rate TODO: make it a parameter.
EPON_macemac
 Pointer to the mac layer for some control and use of MAC address.
uint32_t clock_reg
uint32_t start_reg
uint32_t len_reg
int transmitState
int RTT
uint16_t slotLength
uint16_t slotNumber
int numGates
IPassiveQueue * queue_mod
cQueue tmp_queue
int numFramesFromHL
int numFramesFromLL
int numFramesFromHLDropped
simtime_t fragmentedTime
cMessage * startTxMsg

Constructor & Destructor Documentation

                             {
      // TODO Auto-generated constructor stub

}
                              {
      // TODO Auto-generated destructor stub
}

Member Function Documentation

void ONUMacCtlBase::dumpReg ( ) [protected, virtual]
                           {
      EV << "Sim(ns16): "<<MPCPTools::simTimeToNS16()<<endl;
      EV << "Clock: "<<clock_reg<<endl;
      EV << "Start: "<<start_reg<<endl;
      EV << "Length: "<<len_reg<<endl;
}
void ONUMacCtlBase::finish ( ) [protected, virtual]

Log Scalars.

{
    simtime_t t = simTime();
    recordScalar("simulated time", t);
    recordScalar("messages handled", numFramesFromHL+numFramesFromLL);
    recordScalar("Dropped Frames From HL", numFramesFromHLDropped);
    double fragBits = fragmentedTime.dbl()/(1/GIGABIT_ETHERNET_TXRATE);
    recordScalar("FragmentedBits", fragBits);
    if (t>0) {
        recordScalar("frames/sec", (numFramesFromHL+numFramesFromLL)/t);
        recordScalar("drops/sec", numFramesFromHLDropped/t);
        recordScalar("FragmentedBits/sec", fragBits/t);
    }
}
cModule * ONUMacCtlBase::getNeighbourOnGate ( const char *  gate) [protected, virtual]
                                                         {
      return gate(g)->getNextGate()->getOwnerModule();
}
std::string ONUMacCtlBase::getStateStr ( ) [protected]
                                    {
      switch (transmitState){
      case TX_ON: return "TX_ON";
      case TX_OFF: return "TX_OFF";
      case TX_INIT: return "TX_INIT";
      case TX_IDLE: return "TX_IDLE";
      case TX_SLEEP: return "TX_SLEEP";
      default: return "UNKNOWN!";
      }
}
void ONUMacCtlBase::initialize ( ) [protected, virtual]

Reimplemented in ONUMacCtl_NP, and ONUMacCtl_P.

{
      clock_reg=0;
      start_reg=0;
      len_reg=0;
      numGates = 0;

      // Link to MAC layer
      emac = dynamic_cast<EPON_mac *>(getNeighbourOnGate("lowerLayerOut"));
      if (!emac)
            opp_error("No MAC layer found connected under ONU MAC Control Layer");


      transmitState = TX_OFF;
      txrate=GIGABIT_ETHERNET_TXRATE;



      startTxMsg = new cMessage("startTxMsg", STARTTXMSG);


      // Init Stats
      numFramesFromHL=0;
      numFramesFromLL=0;
      numFramesFromHLDropped=0;
      fragmentedTime=0;

    WATCH(numFramesFromHL);
    WATCH(numFramesFromLL);
    WATCH(numFramesFromHLDropped);
    WATCH(fragmentedTime);

    WATCH(clock_reg);
    WATCH(start_reg);
    WATCH(len_reg);
    WATCH(transmitState);


      // MPCP
    transmitState = TX_INIT;


    // Initialize the Q mgmt module
      queue_mod = dynamic_cast<IPassiveQueue *>(getNeighbourOnGate("upperLayerOut"));
      if (!queue_mod)
            opp_error("ONUMacCtlBase: An IPassiveQueue is needed above mac control");

}
void ONUMacCtlBase::processFrameFromMAC ( cMessage *  msg) [protected, virtual]
                                                    {


      EV << "ONUMacCtlBase: Incoming message from PON\n";
      EthernetIIFrame * frame = dynamic_cast<EthernetIIFrame *>(msg);


      if (frame && frame->getEtherType() == MPCP_TYPE){

            // Check that the frame is for us...
            if (frame->getDest() != emac->getMACAddress() && !frame->getDest().isBroadcast()){
                  EV << "MPCP not for us... dropping\n";
                  delete frame;
                  return;
            }

            processMPCP(frame );
      }


      send(msg,"upperLayerOut");
      numFramesFromLL++;
}
virtual void ONUMacCtlBase::processMPCP ( EthernetIIFrame *  frame) [protected, pure virtual]

Implemented in ONUMacCtl_NP, and ONUMacCtl_P.

virtual void ONUMacCtlBase::startTxOnPON ( ) [protected, pure virtual]

Implemented in ONUMacCtl_NP, and ONUMacCtl_P.


Member Data Documentation

uint32_t ONUMacCtlBase::clock_reg [protected]

Pointer to the mac layer for some control and use of MAC address.

simtime_t ONUMacCtlBase::fragmentedTime [protected]
uint32_t ONUMacCtlBase::len_reg [protected]
int ONUMacCtlBase::numGates [protected]
IPassiveQueue* ONUMacCtlBase::queue_mod [protected]
int ONUMacCtlBase::RTT [protected]
uint16_t ONUMacCtlBase::slotLength [protected]
uint16_t ONUMacCtlBase::slotNumber [protected]
uint32_t ONUMacCtlBase::start_reg [protected]
cMessage* ONUMacCtlBase::startTxMsg [protected]
cQueue ONUMacCtlBase::tmp_queue [protected]
uint64_t ONUMacCtlBase::txrate [protected]

Tx Rate TODO: make it a parameter.


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Typedefs Friends Defines