IPTrafSink Class Reference

#include <IPTrafGen.h>

Inheritance diagram for IPTrafSink:

IPTrafGen List of all members.

Detailed Description

Consumes and prints packets received from the IP module. See NED for more info.


Protected Member Functions

virtual void printPacket (cMessage *msg)
virtual void processPacket (cMessage *msg)
virtual void initialize ()
virtual void handleMessage (cMessage *msg)

Protected Attributes

int numReceived


Member Function Documentation

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

Reimplemented in IPTrafGen.

00038 {
00039     processPacket(msg);
00040 
00041     if (ev.isGUI())
00042     {
00043         char buf[32];
00044         sprintf(buf, "rcvd: %d pks", numReceived);
00045         displayString().setTagArg("t",0,buf);
00046     }
00047 
00048 }

void IPTrafSink::initialize (  )  [protected, virtual]

00032 {
00033     numReceived = 0;
00034     WATCH(numReceived);
00035 }

void IPTrafSink::printPacket ( cMessage *  msg  )  [protected, virtual]

00051 {
00052     IPvXAddress src, dest;
00053     int protocol = -1;
00054     if (dynamic_cast<IPControlInfo *>(msg->controlInfo())!=NULL)
00055     {
00056         IPControlInfo *ctrl = (IPControlInfo *)msg->controlInfo();
00057         src = ctrl->srcAddr();
00058         dest = ctrl->destAddr();
00059         protocol = ctrl->protocol();
00060     }
00061     else if (dynamic_cast<IPv6ControlInfo *>(msg->controlInfo())!=NULL)
00062     {
00063         IPv6ControlInfo *ctrl = (IPv6ControlInfo *)msg->controlInfo();
00064         src = ctrl->srcAddr();
00065         dest = ctrl->destAddr();
00066         protocol = ctrl->protocol();
00067     }
00068 
00069     ev  << msg << endl;
00070     ev  << "Payload length: " << msg->byteLength() << " bytes" << endl;
00071     if (protocol!=-1)
00072         ev  << "src: " << src << "  dest: " << dest << "  protocol=" << protocol << "\n";
00073 }

void IPTrafSink::processPacket ( cMessage *  msg  )  [protected, virtual]

00076 {
00077     EV << "Received packet: ";
00078     printPacket(msg);
00079     delete msg;
00080 
00081     numReceived++;
00082 }


Member Data Documentation

int IPTrafSink::numReceived [protected]


The documentation for this class was generated from the following files:
Generated on Wed Apr 4 13:20:21 2007 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.7