EPONImplementationforOMNet++
0.8Beta
|
PON_Splitter is a fairly simple module to forward frames from ONU side to OLT side and the opposite. More...
#include <PON_Splitter.h>
Protected Member Functions | |
virtual void | initialize () |
virtual void | handleMessage (cMessage *msg) |
virtual void | finish () |
virtual void | printUpStreamDebug (cMessage *msg) |
Protected Attributes | |
int | ports |
uint32_t | col_upstream |
uint32_t | col_downstream |
long | numMessages |
cMessage * | previousMsg |
uint32_t | haltOn |
PON_Splitter is a fairly simple module to forward frames from ONU side to OLT side and the opposite.
This module thought allow you to see the collision counters, which are really useful if you change the timing and synchronization functions.
void PON_Splitter::finish | ( | ) | [protected, virtual] |
{ simtime_t t = simTime(); recordScalar("simulated time", t); recordScalar("messages handled", numMessages); recordScalar("downstream collisions", col_downstream); recordScalar("upstream collisions", col_upstream); if (t>0) { recordScalar("messages/sec", numMessages/t); recordScalar("downstream collisions/sec", col_downstream/t); recordScalar("upstream collisions/sec", col_upstream/t); } }
void PON_Splitter::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
{ // Handle frame sent down from the network entity: send out on every other port cGate *ingate = msg->getArrivalGate(); EV << "Frame " << msg << " arrived on port " << ingate->getName() << "...\n"; if (ingate->getId() == gate( "portu$i")->getId()){ EV << "sending to clients\n"; // DownStream if (ports==0) { delete msg; return; } for (int i=0; i<ports; i++) { // if it is the last port to send, do NOT duplicate bool isLast = (ingate->getIndex() ==ports-1) ? (i==ports-2) : (i==ports-1); // Check if we have 1 port to ONU... if (ports==1) isLast=true; cMessage *msg2 = isLast ? msg : (cMessage*) msg->dup(); if (gate("portg$o",i)->getTransmissionChannel()->isBusy() ) { EV << "PON_Splitter: DOWNSTREAM COLLISION (#: "<<col_downstream<<")" << endl; EV << "PON_Splitter: Tx Finish time: " << gate("portg$o",i)->getTransmissionChannel()->getTransmissionFinishTime() <<endl; EV << "PON_Splitter: Diff: " << gate("portg$o",i)->getTransmissionChannel()->getTransmissionFinishTime() -simTime() <<endl; col_downstream++; delete msg2; delete msg; return; } else { send(msg2,"portg$o",i); } } } else{ EV << "sending to UpLink\n"; if (gate("portu$o")->getTransmissionChannel()->isBusy() ) { printUpStreamDebug(msg); col_upstream++; if (col_upstream >= haltOn) error("Simulation HALTED DUE TO COLLISIONS ON THE SPLITTER... " "To disable this error change the 'haltOn' parameter..."); delete msg; // Notify if this could be a registration message if (simTime()<1) opp_error("Registration message collision... \n - You can increase the registration interval\n - RNG may also fail"); return; }else send(msg,"portu$o"); } // Here only if message sent previousMsg=msg; numMessages++; }
void PON_Splitter::initialize | ( | ) | [protected, virtual] |
{ numMessages = 0; col_downstream = 0; col_upstream = 0; previousMsg = 0; WATCH(numMessages); WATCH(col_downstream); WATCH(col_upstream); ports = gateSize("portg"); haltOn = par("haltOn"); // Put the gates on instant transmission // (or suffer from collisions) gate("portu$i")->setDeliverOnReceptionStart(true); for (int i=0; i<ports; i++) gate("portg$i",i)->setDeliverOnReceptionStart(true); // Display analogy char tmp[20]; sprintf(tmp,"1:%d",ports); getDisplayString().setTagArg("t",0,tmp); }
void PON_Splitter::printUpStreamDebug | ( | cMessage * | msg | ) | [protected, virtual] |
{ EV << "PON_Splitter: UPSTREAM COLLISION (#: "<<col_upstream<<")" << endl; EV << "PON_Splitter: Tx Finish time: " << gate("portu$o")->getTransmissionChannel()->getTransmissionFinishTime() << " simTime: "<<simTime()<<endl; EV << "PON_Splitter: Diff: " << gate("portu$o")->getTransmissionChannel()->getTransmissionFinishTime() -simTime()<<endl; EV << "PON_Splitter: Message Info:" << endl<< "\tFirst : "<<previousMsg->getArrivalGate()->getIndex() <<" Time: "<<MPCPTools::simTimeToNS16(previousMsg->getSendingTime().raw())<<endl<< "\tSecond: "<<msg->getArrivalGate()->getIndex() <<" Time: "<<MPCPTools::simTimeToNS16(msg->getSendingTime().raw()); }
uint32_t PON_Splitter::col_downstream [protected] |
uint32_t PON_Splitter::col_upstream [protected] |
uint32_t PON_Splitter::haltOn [protected] |
long PON_Splitter::numMessages [protected] |
int PON_Splitter::ports [protected] |
cMessage* PON_Splitter::previousMsg [protected] |