#include <UDPEchoApp.h>
Protected Member Functions | |
virtual cPacket * | createPacket () |
virtual void | processPacket (cPacket *msg) |
virtual void | initialize (int stage) |
virtual void | finish () |
UDP application. See NED for more info.
Definition at line 30 of file UDPEchoApp.h.
cPacket * UDPEchoApp::createPacket | ( | ) | [protected, virtual] |
Reimplemented from UDPBasicApp.
Definition at line 41 of file UDPEchoApp.cc.
{ char msgName[32]; sprintf(msgName,"UDPEcho-%d", counter++); UDPEchoAppMsg *message = new UDPEchoAppMsg(msgName); message->setByteLength(par("messageLength").longValue()); return message; }
void UDPEchoApp::finish | ( | ) | [protected, virtual] |
Definition at line 37 of file UDPEchoApp.cc.
{ }
void UDPEchoApp::initialize | ( | int | stage | ) | [protected, virtual] |
Reimplemented from UDPBasicApp.
Definition at line 27 of file UDPEchoApp.cc.
{ UDPBasicApp::initialize(stage); // because of IPAddressResolver, we need to wait until interfaces are registered, // address auto-assignment takes place etc. if (stage!=3) return; }
void UDPEchoApp::processPacket | ( | cPacket * | msg | ) | [protected, virtual] |
Reimplemented from UDPBasicApp.
Definition at line 52 of file UDPEchoApp.cc.
{ if (msg->getKind() == UDP_I_ERROR) { delete msg; return; } UDPEchoAppMsg *packet = check_and_cast<UDPEchoAppMsg *>(msg); if (packet->getIsRequest()) { UDPControlInfo *controlInfo = check_and_cast<UDPControlInfo *>(packet->getControlInfo()); // swap src and dest IPvXAddress srcAddr = controlInfo->getSrcAddr(); int srcPort = controlInfo->getSrcPort(); controlInfo->setSrcAddr(controlInfo->getDestAddr()); controlInfo->setSrcPort(controlInfo->getDestPort()); controlInfo->setDestAddr(srcAddr); controlInfo->setDestPort(srcPort); packet->setIsRequest(false); send(packet, "udpOut"); } else { simtime_t rtt = simTime() - packet->getCreationTime(); EV << "RTT: " << rtt << "\n"; delete msg; } numReceived++; }