|
INET Framework for OMNeT++/OMNEST
|
Generic server application.
More...
#include <TcpGenericServerApp.h>
Generic server application.
It serves requests coming in GenericAppMsg request messages. Clients are usually subclassed from TcpAppBase.
- See also
- GenericAppMsg, TcpAppBase
◆ finish()
| void inet::TcpGenericServerApp::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
159 EV_INFO << getFullPath() <<
": sent " <<
bytesSent <<
" bytes in " <<
msgsSent <<
" packets\n";
160 EV_INFO << getFullPath() <<
": received " <<
bytesRcvd <<
" bytes in " <<
msgsRcvd <<
" packets\n";
◆ handleMessage()
| void inet::TcpGenericServerApp::handleMessage |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
86 if (msg->isSelfMessage()) {
92 int connId = check_and_cast<Indication *>(msg)->getTag<SocketInd>()->getSocketId();
95 request->addTag<SocketReq>()->setSocketId(
connId);
99 Packet *packet = check_and_cast<Packet *>(msg);
100 int connId = packet->getTag<SocketInd>()->getSocketId();
102 auto chunk = packet->peekDataAt(
B(0), packet->getTotalLength());
106 bool doClose =
false;
109 bytesRcvd +=
B(appmsg->getChunkLength()).get();
110 B requestedBytes = appmsg->getExpectedReplyLength();
111 simtime_t msgDelay = appmsg->getReplyDelay();
115 if (requestedBytes >
B(0)) {
116 Packet *outPacket =
new Packet(msg->getName(),
TCP_C_SEND);
117 outPacket->addTag<SocketReq>()->setSocketId(
connId);
118 const auto& payload = makeShared<GenericAppMsg>();
119 payload->setChunkLength(requestedBytes);
120 payload->setExpectedReplyLength(
B(0));
121 payload->setReplyDelay(0);
122 payload->addTag<CreationTimeTag>()->setCreationTime(simTime());
123 outPacket->insertAtBack(payload);
126 if (appmsg->getServerClose()) {
135 TcpCommand *cmd =
new TcpCommand();
136 request->addTag<SocketReq>()->setSocketId(
connId);
137 request->setControlInfo(cmd);
145 EV_WARN <<
"drop msg: " << msg->getName() <<
", kind:" << msg->getKind() <<
"(" << cEnum::get(
"inet::TcpStatusInd")->getStringFor(msg->getKind()) <<
")\n";
◆ initialize()
| void inet::TcpGenericServerApp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
27 cSimpleModule::initialize(stage);
30 delay = par(
"replyDelay");
42 const char *localAddress = par(
"localAddress");
43 int localPort = par(
"localPort");
45 socket.
bind(localAddress[0] ? L3AddressResolver().resolve(localAddress) : L3Address(), localPort);
49 NodeStatus *nodeStatus = node ? check_and_cast_nullable<NodeStatus *>(node->getSubmodule(
"status")) : nullptr;
50 bool isOperational = (!nodeStatus) || nodeStatus->getState() ==
NodeStatus::UP;
52 throw cRuntimeError(
"This module doesn't support starting in node DOWN state");
◆ numInitStages()
| virtual int inet::TcpGenericServerApp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ refreshDisplay()
| void inet::TcpGenericServerApp::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
154 getDisplayString().setTagArg(
"t", 0, buf);
◆ sendBack()
| void inet::TcpGenericServerApp::sendBack |
( |
cMessage * |
msg | ) |
|
|
protectedvirtual |
66 Packet *packet =
dynamic_cast<Packet *
>(msg);
73 EV_INFO <<
"sending \"" << packet->getName() <<
"\" to TCP, " << packet->getByteLength() <<
" bytes\n";
76 EV_INFO <<
"sending \"" << msg->getName() <<
"\" to TCP\n";
79 auto&
tags = check_and_cast<ITaggedObject *>(msg)->getTags();
81 send(msg,
"socketOut");
Referenced by handleMessage(), and sendOrSchedule().
◆ sendOrSchedule()
| void inet::TcpGenericServerApp::sendOrSchedule |
( |
cMessage * |
msg, |
|
|
simtime_t |
delay |
|
) |
| |
|
protectedvirtual |
◆ bytesRcvd
| long inet::TcpGenericServerApp::bytesRcvd |
|
protected |
◆ bytesSent
| long inet::TcpGenericServerApp::bytesSent |
|
protected |
◆ delay
| simtime_t inet::TcpGenericServerApp::delay |
|
protected |
◆ maxMsgDelay
| simtime_t inet::TcpGenericServerApp::maxMsgDelay |
|
protected |
◆ msgsRcvd
| long inet::TcpGenericServerApp::msgsRcvd |
|
protected |
◆ msgsSent
| long inet::TcpGenericServerApp::msgsSent |
|
protected |
◆ socket
◆ socketQueue
| std::map<int, ChunkQueue> inet::TcpGenericServerApp::socketQueue |
|
protected |
The documentation for this class was generated from the following files:
@ PF_ALLOW_NULLPTR
Definition: Chunk.h:278
cModule * findContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:31
static const Protocol tcp
Definition: Protocol.h:112
simtime_t maxMsgDelay
Definition: TcpGenericServerApp.h:28
@ TCP_I_PEER_CLOSED
Definition: TcpCommand_m.h:129
@ TCP_I_AVAILABLE
Definition: TcpCommand_m.h:127
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
simtime_t delay
Definition: TcpGenericServerApp.h:27
virtual void sendOrSchedule(cMessage *msg, simtime_t delay)
Definition: TcpGenericServerApp.cc:56
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
az accept haszálja pcb új connId
Definition: lwip_tcp.txt:42
long msgsSent
Definition: TcpGenericServerApp.h:31
@ TCP_I_URGENT_DATA
Definition: TcpCommand_m.h:126
std::map< int, ChunkQueue > socketQueue
Definition: TcpGenericServerApp.h:35
@ TCP_C_SEND
Definition: TcpCommand_m.h:85
TcpSocket socket
Definition: TcpGenericServerApp.h:26
long msgsRcvd
Definition: TcpGenericServerApp.h:30
intscale< b, 1, 8 > B
Definition: Units.h:1168
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
void listen(bool fork)
Definition: TcpSocket.cc:95
void processMessage(cMessage *msg) override
Examines the message (which should have arrived from TCP), updates socket state, and if there is a ca...
Definition: TcpSocket.cc:281
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
value< int64_t, units::b > b
Definition: Units.h:1241
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
@ TCP_C_CLOSE
Definition: TcpCommand_m.h:86
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
virtual void sendBack(cMessage *msg)
Definition: TcpGenericServerApp.cc:64
@ UP
Definition: NodeStatus.h:28
* tags
Definition: IUdp-gates.txt:3
long bytesSent
Definition: TcpGenericServerApp.h:33
long bytesRcvd
Definition: TcpGenericServerApp.h:32
void bind(int localPort)
Bind the socket to a local port number.
Definition: TcpSocket.cc:69
void setOutputGate(cGate *toTcp)
Sets the gate on which to send to TCP.
Definition: TcpSocket.h:242
@ TCP_I_DATA
Definition: TcpCommand_m.h:125