#include <IPTrafGen.h>
Protected Member Functions | |
virtual void | printPacket (cPacket *msg) |
virtual void | processPacket (cPacket *msg) |
virtual void | initialize () |
virtual void | handleMessage (cMessage *msg) |
Protected Attributes | |
int | numReceived |
Consumes and prints packets received from the IP module. See NED for more info.
Definition at line 32 of file IPTrafGen.h.
void IPTrafSink::handleMessage | ( | cMessage * | msg | ) | [protected, virtual] |
Reimplemented in IPTrafGen.
Definition at line 36 of file IPTrafGen.cc.
{ processPacket(check_and_cast<cPacket *>(msg)); if (ev.isGUI()) { char buf[32]; sprintf(buf, "rcvd: %d pks", numReceived); getDisplayString().setTagArg("t",0,buf); } }
void IPTrafSink::initialize | ( | ) | [protected, virtual] |
Definition at line 30 of file IPTrafGen.cc.
Referenced by IPTrafGen::initialize().
{ numReceived = 0; WATCH(numReceived); }
void IPTrafSink::printPacket | ( | cPacket * | msg | ) | [protected, virtual] |
Definition at line 49 of file IPTrafGen.cc.
Referenced by processPacket(), and IPTrafGen::sendPacket().
{ IPvXAddress src, dest; int protocol = -1; if (dynamic_cast<IPControlInfo *>(msg->getControlInfo())!=NULL) { IPControlInfo *ctrl = (IPControlInfo *)msg->getControlInfo(); src = ctrl->getSrcAddr(); dest = ctrl->getDestAddr(); protocol = ctrl->getProtocol(); } else if (dynamic_cast<IPv6ControlInfo *>(msg->getControlInfo())!=NULL) { IPv6ControlInfo *ctrl = (IPv6ControlInfo *)msg->getControlInfo(); src = ctrl->getSrcAddr(); dest = ctrl->getDestAddr(); protocol = ctrl->getProtocol(); } ev << msg << endl; ev << "Payload length: " << msg->getByteLength() << " bytes" << endl; if (protocol!=-1) ev << "src: " << src << " dest: " << dest << " protocol=" << protocol << "\n"; }
void IPTrafSink::processPacket | ( | cPacket * | msg | ) | [protected, virtual] |
Definition at line 74 of file IPTrafGen.cc.
Referenced by IPTrafGen::handleMessage(), and handleMessage().
{ EV << "Received packet: "; printPacket(msg); delete msg; numReceived++; }
int IPTrafSink::numReceived [protected] |
Definition at line 35 of file IPTrafGen.h.
Referenced by IPTrafGen::handleMessage(), handleMessage(), initialize(), and processPacket().