INET Framework for OMNeT++/OMNEST
inet::TunLoopbackApp Class Reference

#include <TunLoopbackApp.h>

Inheritance diagram for inet::TunLoopbackApp:

Public Member Functions

 TunLoopbackApp ()
 
virtual ~TunLoopbackApp ()
 

Protected Member Functions

void initialize (int stage) override
 
void handleMessage (cMessage *msg) override
 
void finish () override
 

Protected Attributes

unsigned int packetsSent
 
unsigned int packetsReceived
 

Static Protected Attributes

static simsignal_t sentPkSignal = registerSignal("sentPk")
 
static simsignal_t rcvdPkSignal = registerSignal("rcvdPk")
 

Constructor & Destructor Documentation

inet::TunLoopbackApp::TunLoopbackApp ( )
32  :
33  packetsSent(0),
35 {
36 }
unsigned int packetsSent
Definition: TunLoopbackApp.h:28
unsigned int packetsReceived
Definition: TunLoopbackApp.h:29
inet::TunLoopbackApp::~TunLoopbackApp ( )
virtual
39 {
40 }

Member Function Documentation

void inet::TunLoopbackApp::finish ( )
overrideprotected
71 {
72  EV_INFO << "packets sent: " << packetsSent << endl;
73  EV_INFO << "packets received: " << packetsReceived << endl;
74 }
unsigned int packetsSent
Definition: TunLoopbackApp.h:28
unsigned int packetsReceived
Definition: TunLoopbackApp.h:29
void inet::TunLoopbackApp::handleMessage ( cMessage *  msg)
overrideprotected
52 {
53  if (message->getArrivalGate()->isName("tunIn")) {
54  EV_INFO << "Message " << message->getName() << " arrived from tun. " << packetsReceived + 1 << " packets received so far\n";
56  INetworkDatagram *networkDatagram = check_and_cast<INetworkDatagram *>(message);
57  ITransportPacket *transportPacket = check_and_cast<ITransportPacket *>(check_and_cast<cPacket *>(message)->getEncapsulatedPacket());
58  transportPacket->setDestinationPort(transportPacket->getSourcePort());
59  transportPacket->setSourcePort(transportPacket->getDestinationPort());
60  networkDatagram->setSourceAddress(networkDatagram->getDestinationAddress());
61  networkDatagram->setDestinationAddress(networkDatagram->getSourceAddress());
62  send(message, "tunOut");
63  packetsSent++;
64  }
65  else
66  throw cRuntimeError("Unknown message");
67 }
unsigned int packetsSent
Definition: TunLoopbackApp.h:28
unsigned int packetsReceived
Definition: TunLoopbackApp.h:29
void inet::TunLoopbackApp::initialize ( int  stage)
overrideprotected
43 {
44  cSimpleModule::initialize(stage);
45  if (stage == INITSTAGE_LOCAL) {
46  packetsSent = 0;
47  packetsReceived = 0;
48  }
49 }
unsigned int packetsSent
Definition: TunLoopbackApp.h:28
unsigned int packetsReceived
Definition: TunLoopbackApp.h:29
Local initializations.
Definition: InitStages.h:35

Member Data Documentation

unsigned int inet::TunLoopbackApp::packetsReceived
protected

Referenced by finish(), handleMessage(), and initialize().

unsigned int inet::TunLoopbackApp::packetsSent
protected

Referenced by finish(), handleMessage(), and initialize().

simsignal_t inet::TunLoopbackApp::rcvdPkSignal = registerSignal("rcvdPk")
staticprotected
simsignal_t inet::TunLoopbackApp::sentPkSignal = registerSignal("sentPk")
staticprotected

The documentation for this class was generated from the following files: