TODO.
More...
#include <EchoProtocol.h>
|
typedef std::map< long, int > | PingMap |
|
void inet::EchoProtocol::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
40 cGate *arrivalGate = msg->getArrivalGate();
41 if (!strcmp(arrivalGate->getName(),
"localIn"))
43 else if (!strcmp(arrivalGate->getName(),
"pingIn"))
virtual void sendEchoRequest(PingPayload *packet)
Definition: EchoProtocol.cc:96
virtual void processPacket(EchoPacket *packet)
Definition: EchoProtocol.cc:47
void inet::EchoProtocol::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
30 cSimpleModule::initialize(stage);
33 IPSocket socket(gate(
"sendOut"));
Definition: IPProtocolId_m.h:77
Initialization of network-layer protocols, stage 2.
Definition: InitStages.h:78
virtual int inet::EchoProtocol::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
The number of initialization stages.
Definition: InitStages.h:116
void inet::EchoProtocol::processEchoReply |
( |
EchoPacket * |
packet | ) |
|
|
protectedvirtual |
Referenced by processPacket().
82 cObject *controlInfo = reply->removeControlInfo();
83 PingPayload *payload = check_and_cast<PingPayload *>(reply->decapsulate());
84 payload->setControlInfo(controlInfo);
86 long originatorId = payload->getOriginatorId();
87 auto i =
pingMap.find(originatorId);
89 send(payload,
"pingOut", i->second);
91 EV_INFO <<
"Received ECHO REPLY has an unknown originator ID: " << originatorId <<
", packet dropped." << endl;
PingMap pingMap
Definition: EchoProtocol.h:36
void inet::EchoProtocol::processEchoRequest |
( |
EchoPacket * |
packet | ) |
|
|
protectedvirtual |
Referenced by processPacket().
66 EchoPacket *reply = request;
67 reply->setName((std::string(request->getName()) +
"-reply").c_str());
71 INetworkProtocolControlInfo *ctrl = check_and_cast<INetworkProtocolControlInfo *>(reply->getControlInfo());
72 L3Address src = ctrl->getSourceAddress();
73 L3Address dest = ctrl->getDestinationAddress();
74 ctrl->setInterfaceId(-1);
75 ctrl->setSourceAddress(dest);
76 ctrl->setDestinationAddress(src);
77 send(reply,
"sendOut");
Definition: EchoPacket_m.h:53
void inet::EchoProtocol::processPacket |
( |
EchoPacket * |
packet | ) |
|
|
protectedvirtual |
Referenced by handleMessage().
49 switch (msg->getType()) {
59 throw cRuntimeError(
"Unknown type %d", msg->getType());
Definition: EchoPacket_m.h:52
virtual void processEchoRequest(EchoPacket *packet)
Definition: EchoProtocol.cc:63
Definition: EchoPacket_m.h:53
virtual void processEchoReply(EchoPacket *packet)
Definition: EchoProtocol.cc:80
void inet::EchoProtocol::sendEchoRequest |
( |
PingPayload * |
packet | ) |
|
|
protectedvirtual |
Referenced by handleMessage().
98 cGate *arrivalGate = msg->getArrivalGate();
99 int i = arrivalGate->getIndex();
100 pingMap[msg->getOriginatorId()] = i;
101 cObject *controlInfo = msg->removeControlInfo();
102 INetworkProtocolControlInfo *networkControlInfo = check_and_cast<INetworkProtocolControlInfo *>(controlInfo);
105 EchoPacket *request =
new EchoPacket(msg->getName());
107 request->encapsulate(msg);
108 request->setControlInfo(controlInfo);
109 send(request,
"sendOut");
Definition: EchoPacket_m.h:52
Definition: IPProtocolId_m.h:77
PingMap pingMap
Definition: EchoProtocol.h:36
PingMap inet::EchoProtocol::pingMap |
|
protected |
The documentation for this class was generated from the following files: