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 cPacket * createPacket ()
virtual void processPacket (cPacket *msg)
virtual void initialize (int stage)
virtual void finish ()

Member Function Documentation

cPacket * UDPEchoApp::createPacket (  )  [protected, virtual]

Reimplemented from UDPBasicApp.

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

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

Reimplemented from UDPBasicApp.

00053 {
00054     if (msg->getKind() == UDP_I_ERROR)
00055     {
00056         delete msg;
00057         return;
00058     }
00059 
00060     UDPEchoAppMsg *packet = check_and_cast<UDPEchoAppMsg *>(msg);
00061 
00062     if (packet->getIsRequest())
00063     {
00064         UDPControlInfo *controlInfo = check_and_cast<UDPControlInfo *>(packet->getControlInfo());
00065 
00066         // swap src and dest
00067         IPvXAddress srcAddr = controlInfo->getSrcAddr();
00068         int srcPort = controlInfo->getSrcPort();
00069         controlInfo->setSrcAddr(controlInfo->getDestAddr());
00070         controlInfo->setSrcPort(controlInfo->getDestPort());
00071         controlInfo->setDestAddr(srcAddr);
00072         controlInfo->setDestPort(srcPort);
00073 
00074         packet->setIsRequest(false);
00075         send(packet, "udpOut");
00076     }
00077     else
00078     {
00079         simtime_t rtt = simTime() - packet->getCreationTime();
00080         EV << "RTT: " << rtt << "\n";
00081         delete msg;
00082     }
00083     numReceived++;
00084 }

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

Reimplemented from UDPBasicApp.

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

void UDPEchoApp::finish (  )  [protected, virtual]

00038 {
00039 }


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

Generated on Fri Mar 20 18:51:23 2009 for INET Framework for OMNeT++/OMNEST by  doxygen 1.5.5