Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

UDPEchoApp Class Reference

#include <UDPEchoApp.h>

Inheritance diagram for UDPEchoApp:

UDPBasicApp UDPAppBase List of all members.

Detailed Description

UDP application. See NED for more info.


Protected Member Functions

virtual cMessage * createPacket ()
virtual void processPacket (cMessage *msg)
virtual void initialize (int stage)
virtual void finish ()


Member Function Documentation

cMessage * UDPEchoApp::createPacket  )  [protected, virtual]
 

Reimplemented from UDPBasicApp.

00043 {
00044     char msgName[32];
00045     sprintf(msgName,"UDPEcho-%d", counter++);
00046 
00047     cMessage *message = new UDPEchoAppMsg(msgName);
00048     message->setByteLength(msgByteLength);
00049 
00050     return message;
00051 }

void UDPEchoApp::finish  )  [protected, virtual]
 

00039 {
00040 }

void UDPEchoApp::initialize int  stage  )  [protected, virtual]
 

Reimplemented from UDPBasicApp.

00029 {
00030     UDPBasicApp::initialize(stage);
00031 
00032     // because of IPAddressResolver, we need to wait until interfaces are registered,
00033     // address auto-assignment takes place etc.
00034     if (stage!=3)
00035         return;
00036 }

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

Reimplemented from UDPBasicApp.

00054 {
00055     UDPEchoAppMsg *packet = check_and_cast<UDPEchoAppMsg *>(msg);
00056 
00057     if (packet->isRequest())
00058     {
00059         UDPControlInfo *controlInfo = check_and_cast<UDPControlInfo *>(packet->controlInfo());
00060 
00061         // swap src and dest
00062         IPvXAddress srcAddr = controlInfo->srcAddr();
00063         int srcPort = controlInfo->srcPort();
00064         controlInfo->setSrcAddr(controlInfo->destAddr());
00065         controlInfo->setSrcPort(controlInfo->destPort());
00066         controlInfo->setDestAddr(srcAddr);
00067         controlInfo->setDestPort(srcPort);
00068 
00069         packet->setIsRequest(false);
00070         send(packet, "to_udp");
00071     }
00072     else
00073     {
00074         simtime_t rtt = simTime() - packet->creationTime();
00075         EV << "RTT: " << rtt << "\n";
00076         delete msg;
00077     }
00078     numReceived++;
00079 }


The documentation for this class was generated from the following files:
Generated on Sat Apr 1 20:52:25 2006 for INET Framework for OMNeT++/OMNEST by  doxygen 1.4.1