Forwarder Class Reference

#include <Forwarder.h>

Inheritance diagram for Forwarder:
cSimpleModule cModule cComponent cDefaultList cNoncopyableOwnedObject cOwnedObject noncopyable cNamedObject cObject

List of all members.

Public Member Functions

 Forwarder ()

Protected Member Functions

virtual void initialize (int stage)
virtual int numInitStages () const
virtual void handleMessage (cMessage *msg)
virtual void handlePSMsg (PSEtherAppMsg *msg)

Protected Attributes

FwTablefwt
 Pointer to the Forwarding Table of the Router.
IInterfaceTable * ift
 Pointer to the Interface Table of the Router.
int numMulticast
 Number of multicast packets forwarded.
int numLocalDeliver
 Number of local packets delivered.
int numDropped
 Number of Packets dropped.
int numUnroutable
 Number of Packets unable to be routed.
int numForwarded
 Number of forwarded packets.
int numFalsePositives
 Number of the palse positives in the forwarded packets.

Detailed Description

The Publish Subscribe Forwarder class header Implements the Forwarder for the publish-subscribe network router. This module, on receiving a network message, just checks with the forwarding table if there is any link towards another network interface, with LID matching the received message's FID. If this check returns a number of matching interfaces, the received message is forwarded to all these interfaces.


Constructor & Destructor Documentation

Forwarder::Forwarder (  )  [inline]

Constructor

00063 {}


Member Function Documentation

void Forwarder::handleMessage ( cMessage msg  )  [protected, virtual]

Processing of messages, received from the link layer.

Reimplemented from cSimpleModule.

00060 {
00061         //Check is received message is a pub-sub message
00062         if (dynamic_cast<PSEtherAppMsg *>(msg)) {
00063                 PSEtherAppMsg *PSmsg =  check_and_cast <PSEtherAppMsg *> (msg);
00064 
00065                 handlePSMsg(PSmsg);
00066         }
00067         //...else delete received message
00068         else {
00069                 numUnroutable++;
00070                 ev << "Packet with invalid format received... being discarted!!!" << endl;
00071                 delete msg;
00072         }
00073         return;
00074 }

void Forwarder::handlePSMsg ( PSEtherAppMsg msg  )  [protected, virtual]

If a message is a pub-sub message, apply the forwarding functions.

00077                                               {
00078         ev << "Handling Pub-Sub message... Checking forwarding table..." << endl;
00079 
00080         //Get the list of the network interface gate index that match the message's FID
00081         list<int> interfaceIDs=fwt->findMatchingRoute(msg->getFID());
00082 
00083         //If we are checking for false positives, record any such occurrence by checking
00084         //the result given by the Forwarding Table.
00085         if(simulation.getSystemModule()->par("FP_check").boolValue()==true && msg->getPathArraySize()>0) {
00086 
00087                 //Check if the link used for forwarding is inside the messages list
00088                 for(list<int>::iterator it = interfaceIDs.begin(); it != interfaceIDs.end(); it++) {
00089 
00090                         bool found = false;
00091 
00092                         //For all the lids in the message path
00093                         for(uint i=0;i<msg->getPathArraySize();i++) {
00094                                 //If the searched LID is found in the path, change the flag
00095                                 if(strcmp(msg->getPath(i),fwt->getLID(*it))==0)
00096                                         found=true;
00097                         }
00098 
00099                         //If a false positive is found, record it and remove the forwarding link from the list
00100                         if(!found) {
00101                                 ev << "ATTENTION: False-positive found in the forwarding process!" << endl;
00102                                 numFalsePositives++;
00103                                 //Remove the link from the forwarding list
00104                                 it = interfaceIDs.erase(it);
00105                                 it--;
00106                         }
00107                 }
00108         }
00109 
00110         //If the list is not empty
00111         if(!interfaceIDs.empty()) {
00112 
00113                 for (list<int>::iterator it = interfaceIDs.begin(); it != interfaceIDs.end(); it++) {
00114 
00115                         //We shound't send the message back from where it came
00116                         if(msg->getArrivalGate()->getIndex()!=*it) {
00117                                 ev << "Found a matching LID for interface eth[" <<  *it << "]" << endl;
00118 
00119                                 //Creating new copies of the message for each interface and copying the Control Info
00120                                 PSEtherAppMsg *msgcopy=(PSEtherAppMsg *)msg->dup();
00121                                 msgcopy->setControlInfo(new Ieee802Ctrl(*check_and_cast<Ieee802Ctrl *>(msg->getControlInfo())));
00122 
00123                                 ev << "Forwarding the message to the interface..." << endl;
00124 
00125                                 //Sending message down to the correct interface
00126                                 numForwarded++;
00127                                 send(msgcopy,"ifOut",*it);
00128                         }
00129                 }
00130         }
00131         else {
00132                 numDropped++;
00133                 ev << "No Ethernet interface with matching LID found. Dropping packet." << endl;
00134         }
00135 
00136         delete msg;
00137 }

void Forwarder::initialize ( int  stage  )  [protected, virtual]

Initialization

Reimplemented from cComponent.

00037 {
00038         if(stage==1) {
00039                 //Initialize parent class
00040                 cSimpleModule::initialize(stage);
00041 
00042                 //Access Interface and Forwarding Table
00043                 ift = InterfaceTableAccess().get();
00044                 fwt = FwTableAccess().get();
00045 
00046                 //Initialize and watch statistics
00047                 numMulticast = numLocalDeliver = numDropped = numUnroutable = numForwarded = numFalsePositives = 0;
00048 
00049                 WATCH(numMulticast);
00050                 WATCH(numLocalDeliver);
00051                 WATCH(numDropped);
00052                 WATCH(numUnroutable);
00053                 WATCH(numForwarded);
00054                 WATCH(numFalsePositives);
00055         }
00056 }

virtual int Forwarder::numInitStages (  )  const [inline, protected, virtual]

Returns the number of initialization stages.

Reimplemented from cComponent.

00074 {return 4;}


Member Data Documentation

FwTable* Forwarder::fwt [protected]

Pointer to the Forwarding Table of the Router.

IInterfaceTable* Forwarder::ift [protected]

Pointer to the Interface Table of the Router.

int Forwarder::numDropped [protected]

Number of Packets dropped.

Number of the palse positives in the forwarded packets.

int Forwarder::numForwarded [protected]

Number of forwarded packets.

int Forwarder::numLocalDeliver [protected]

Number of local packets delivered.

int Forwarder::numMulticast [protected]

Number of multicast packets forwarded.

int Forwarder::numUnroutable [protected]

Number of Packets unable to be routed.


The documentation for this class was generated from the following files:
Generated on Thu Jun 14 17:12:42 2012 for PAL by  doxygen 1.6.3