EPONImplementationforOMNet++  0.8Beta
EPON_ONU_relayDefault Class Reference

The default relay way. More...

#include <EPON_ONU_relayDefault.h>

Inheritance diagram for EPON_ONU_relayDefault:
EPON_ONU_vlanBridgeRelay

List of all members.

Protected Types

typedef std::vector< uint16_t > llidTable

Protected Member Functions

virtual void initialize ()
virtual void handleMessage (cMessage *msg)
virtual void handleFromPON (EtherFrame *frame)
virtual void handleFromLAN (EtherFrame *frame)
virtual cModule * findModuleUp (const char *name)

Protected Attributes

long numProcessedFrames
long numDroppedFrames
llidTable llids
SrvListserviceList

Detailed Description

The default relay way.

As mentioned in the MACVlanRelayUnitBase this module is responsible for packet differentiation. The specific module is based on the destination MAC address and is going to forward the frame to all the known LLIDs. If the LLID is -1 (UNDEFINED) then the frame is going to be broadcasted. The same will happen if we do not know any LLID for that MAC address or if the ONU doesn't have any LLID assigned.

NOTE here that mapping to LLIDs could be done with various ways based on the VLAN or on the DSCP in the IP header or even per-port or pre-defined per destination. Depending on the scenario, someone can extend the MACVlanRelayUnitBase and change the relay's behavior.


Member Typedef Documentation

typedef std::vector<uint16_t> EPON_ONU_relayDefault::llidTable [protected]

Member Function Documentation

cModule * EPON_ONU_relayDefault::findModuleUp ( const char *  name) [protected, virtual]
                                                              {
      cModule *mod = NULL;
      for (cModule *curmod=this; !mod && curmod; curmod=curmod->getParentModule())
           mod = curmod->getSubmodule(name);
      return mod;
}
void EPON_ONU_relayDefault::handleFromLAN ( EtherFrame *  frame) [protected, virtual]

6-Feb-2011: Do NOT BC... send to the default LLiD

Reimplemented in EPON_ONU_vlanBridgeRelay.

                                                          {
      updateTableFromFrame(frame);

      mac_llid ml;

      ml.mac = frame->getDest();
      // Check table ... if port is the same as incoming drop
      std::string port = getPortForAddress(ml);
      if (port == "ethOut") {
            delete frame;
            return;
      }


      // Do MAPINGS HERE (vlan or anything other to LLID)
      // currently use the default

      /*
       *  NOTE: The following code works... but is logically wrong.
       *  It is based on the EtherSwitch code... but we don't have
       *  multiple Ethernet (copper) interfaces yet (Increases complexity)
       *
       *  On extended versions you could only bridge vlan <-> llid.
       *  (vlan zero (0) -> Default)
       */


      // If we don't have any llid, drop
      if (llids.size() == 0 ){
            EV << "No LLiD Assigned, droping frame"<<frame<<endl;
            delete frame;
            return;
      }
      // If we have 1 llid, sent through there
      else if (llids.size() == 1 ){
            frame->setControlInfo(new EPON_LLidCtrlInfo(llids[0]) );
            send(frame, "toPONout");
            return;
      }
      // We have more than 1 assigned LLiDs
      else {
            std::vector<port_llid> vec = getLLIDsForAddress(frame->getDest());

            if (vec.size()!=0){
                  // Send to the known llids only
                  for (uint32_t i = 0; i<vec.size(); i++){
                        EtherFrame *frame_tmp = frame->dup();

                        // Get this llid and this port, duplicate and send
                        port_llid tmp_pl = (port_llid)vec[i];
                        // If we don't know ... lets BC
                        if (tmp_pl.llid == -1) tmp_pl.llid = LLID_EPON_BC;
                        frame_tmp->setControlInfo(new EPON_LLidCtrlInfo(tmp_pl.llid) );
                        send(frame_tmp, tmp_pl.port.c_str());

                        // If BC, we break;
                        if (tmp_pl.llid == LLID_EPON_BC) break;
                  }
            }else{
                  // DO NOT Send to all the llids assigned
                  //          for (uint32_t i=0; i<llids.size(); i++){
                  //                EtherFrame *frame_tmp = frame->dup();
                  //
                  //                // Get this llid and this port, duplicate and send
                  //                frame_tmp->setControlInfo(new EPON_LLidCtrlInfo(llids[i]) );
                  //                send(frame_tmp, "toPONout");
                  //          }
                  // INSTEAD BROADCAST IT...
                  // ENABLE THE ABOVE TO TEST PON (Generates X-times more traffic)

                  EtherFrame *frame_tmp = frame->dup();

                  // Get this llid and this port, duplicate and send
                  //frame_tmp->setControlInfo(new EPON_LLidCtrlInfo(LLID_EPON_BC) );
                  send(frame_tmp, "toPONout");


                  // TODO: Normally it would be sent only to the
                  // LLID bridged with the vlan that the source host
                  // belongs. OR alternatively traffic can be differentiated
                  // on the network layer

            }
      }


      // delete the original frame
      delete frame;


}
void EPON_ONU_relayDefault::handleFromPON ( EtherFrame *  frame) [protected, virtual]
                                                          {
      mac_llid ml;
      ml.mac = frame->getSrc();
      ml.llid = -1;

      //Check frame preamble (dist between ONUs ONLY)
      EPON_LLidCtrlInfo * nfo = dynamic_cast<EPON_LLidCtrlInfo *>(frame->removeControlInfo());
      if (nfo!=NULL){
            if (nfo->llid != LLID_EPON_BC) ml.llid = nfo->llid;
      }
      updateTableWithAddress(ml, "toPONout");

      // If it is a register update the LLIDs table
      MPCPRegister * reg = dynamic_cast<MPCPRegister *>(frame);
      if (reg){
            //EV<< "Assigned LLIDs:" <<LLID_num<<endl;
            for (uint8_t i=0; i<reg->getLLIDsArraySize(); i++){
                  // 0xFFF = 4095 intrand -> [0-4095)
                  llids.push_back(reg->getLLIDs(i));
            }

            // Do not forward further
            delete frame;
            return;
      }

      // We do not need to scan the table since we still
      // have no vlans. Each ONU is considered to be a different
      // net (subnet) so the frame must go directly to wire.
      send(frame, "ethOut");
}
void EPON_ONU_relayDefault::handleMessage ( cMessage *  msg) [protected, virtual]
{

      // Self Message
      if (msg->isSelfMessage())
      {
            EV << "Self-message " << msg << " received\n";
            error("Unknown self message received!");
            return;
      }

      // Network Message
      cGate *ingate = msg->getArrivalGate();
      EV << "Frame " << msg << " arrived on port " << ingate->getName() << "...\n";

      EtherFrame *frame = check_and_cast<EtherFrame *>(msg);

      if (ingate->getId() ==  gate( "toPONin")->getId()){
            handleFromPON(frame);
      }
      else if (ingate->getId() ==  gate( "ethIn")->getId()){
            handleFromLAN(frame);
      }
      else{
            EV << "Message received in UNKNOWN PORT\n";
            return;
      }

}
void EPON_ONU_relayDefault::initialize ( ) [protected, virtual]

Reimplemented in EPON_ONU_vlanBridgeRelay.

{
      MACVlanRelayUnitBase::initialize();

      if (dynamic_cast<ServiceConfig *>( findModuleUp("serviceConfig")) != NULL){
            serviceList = &(dynamic_cast<ServiceConfig *>( findModuleUp("serviceConfig"))->srvs);
      }

      numProcessedFrames = numDroppedFrames = 0;
      WATCH(numProcessedFrames);
      WATCH(numDroppedFrames);
      WATCH_VECTOR(llids);
}

Member Data Documentation


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