|
INET Framework for OMNeT++/OMNEST
|
An example request-reply based client application.
More...
#include <TcpBasicClientApp.h>
|
| virtual void | sendRequest () |
| |
| virtual void | rescheduleAfterOrDeleteTimer (simtime_t d, short int msgKind) |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | initialize (int stage) override |
| |
| virtual void | handleTimer (cMessage *msg) override |
| |
| virtual void | socketEstablished (TcpSocket *socket) override |
| |
| virtual void | socketDataArrived (TcpSocket *socket, Packet *msg, bool urgent) override |
| | Notifies about data arrival, packet ownership is transferred to the callee. More...
|
| |
| virtual void | socketClosed (TcpSocket *socket) override |
| |
| virtual void | socketFailure (TcpSocket *socket, int code) override |
| |
| virtual void | handleStartOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleStopOperation (LifecycleOperation *operation) override |
| |
| virtual void | handleCrashOperation (LifecycleOperation *operation) override |
| |
| virtual void | close () override |
| |
| virtual void | handleMessageWhenUp (cMessage *msg) override |
| |
| virtual void | finish () override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | connect () |
| |
| virtual void | sendPacket (Packet *pkt) |
| |
| virtual void | socketAvailable (TcpSocket *socket, TcpAvailableInfo *availableInfo) override |
| |
| virtual void | socketPeerClosed (TcpSocket *socket) override |
| |
| virtual void | socketStatusArrived (TcpSocket *socket, TcpStatusInfo *status) override |
| |
| virtual void | socketDeleted (TcpSocket *socket) override |
| |
| virtual bool | isInitializeStage (int stage) const override |
| |
| virtual bool | isModuleStartStage (int stage) const override |
| |
| virtual bool | isModuleStopStage (int stage) const override |
| |
| virtual int | numInitStages () const override |
| |
| virtual void | refreshDisplay () const override |
| |
| virtual void | handleMessage (cMessage *msg) override |
| |
| virtual void | handleMessageWhenDown (cMessage *msg) |
| |
| virtual bool | handleOperationStage (LifecycleOperation *operation, IDoneCallback *doneCallback) override |
| | Perform one stage of a lifecycle operation. More...
|
| |
| virtual State | getInitialOperationalState () const |
| | Returns initial operational state: OPERATING or NOT_OPERATING. More...
|
| |
| virtual void | handleActiveOperationTimeout (cMessage *message) |
| |
| virtual bool | isUp () const |
| | utility functions More...
|
| |
| virtual bool | isDown () const |
| |
| virtual void | setOperationalState (State newState) |
| |
| virtual void | scheduleOperationTimeout (simtime_t timeout) |
| |
| virtual void | setupActiveOperation (LifecycleOperation *operation, IDoneCallback *doneCallback, State) |
| |
| virtual void | delayActiveOperationFinish (simtime_t timeout) |
| |
| virtual void | startActiveOperationExtraTime (simtime_t delay=SIMTIME_ZERO) |
| |
| virtual void | startActiveOperationExtraTimeOrFinish (simtime_t extraTime) |
| |
| virtual void | finishActiveOperation () |
| |
An example request-reply based client application.
◆ TcpBasicClientApp()
| inet::TcpBasicClientApp::TcpBasicClientApp |
( |
| ) |
|
|
inline |
◆ ~TcpBasicClientApp()
| inet::TcpBasicClientApp::~TcpBasicClientApp |
( |
| ) |
|
|
virtual |
◆ close()
| void inet::TcpBasicClientApp::close |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ handleCrashOperation()
◆ handleStartOperation()
◆ handleStopOperation()
◆ handleTimer()
| void inet::TcpBasicClientApp::handleTimer |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Implements inet::TcpAppBase.
94 switch (msg->getKind()) {
113 throw cRuntimeError(
"Invalid timer msg: kind=%d", msg->getKind());
◆ initialize()
| void inet::TcpBasicClientApp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::TcpAppBase.
40 throw cRuntimeError(
"Invalid startTime/stopTime parameters");
◆ numInitStages()
| virtual int inet::TcpBasicClientApp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ rescheduleAfterOrDeleteTimer()
| void inet::TcpBasicClientApp::rescheduleAfterOrDeleteTimer |
( |
simtime_t |
d, |
|
|
short int |
msgKind |
|
) |
| |
|
protectedvirtual |
◆ sendRequest()
| void inet::TcpBasicClientApp::sendRequest |
( |
| ) |
|
|
protectedvirtual |
71 long requestLength = par(
"requestLength");
72 long replyLength = par(
"replyLength");
73 if (requestLength < 1)
78 const auto& payload = makeShared<GenericAppMsg>();
79 Packet *packet =
new Packet(
"data");
80 payload->setChunkLength(
B(requestLength));
81 payload->setExpectedReplyLength(
B(replyLength));
82 payload->setServerClose(
false);
83 payload->addTag<CreationTimeTag>()->setCreationTime(simTime());
84 packet->insertAtBack(payload);
86 EV_INFO <<
"sending request with " << requestLength <<
" bytes, expected reply length " << replyLength <<
" bytes,"
Referenced by handleTimer(), and socketEstablished().
◆ socketClosed()
| void inet::TcpBasicClientApp::socketClosed |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived()
| void inet::TcpBasicClientApp::socketDataArrived |
( |
TcpSocket * |
socket, |
|
|
Packet * |
packet, |
|
|
bool |
urgent |
|
) |
| |
|
overrideprotectedvirtual |
Notifies about data arrival, packet ownership is transferred to the callee.
Reimplemented from inet::TcpAppBase.
150 EV_INFO <<
"reply arrived\n";
153 simtime_t d = par(
"thinkTime");
158 EV_INFO <<
"reply to last request arrived, closing session\n";
◆ socketEstablished()
| void inet::TcpBasicClientApp::socketEstablished |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketFailure()
| void inet::TcpBasicClientApp::socketFailure |
( |
TcpSocket * |
socket, |
|
|
int |
code |
|
) |
| |
|
overrideprotectedvirtual |
Reimplemented from inet::TcpAppBase.
186 simtime_t d = par(
"reconnectInterval");
◆ earlySend
| bool inet::TcpBasicClientApp::earlySend = false |
|
protected |
◆ numRequestsToSend
| int inet::TcpBasicClientApp::numRequestsToSend = 0 |
|
protected |
◆ startTime
| simtime_t inet::TcpBasicClientApp::startTime |
|
protected |
◆ stopTime
| simtime_t inet::TcpBasicClientApp::stopTime |
|
protected |
◆ timeoutMsg
| cMessage* inet::TcpBasicClientApp::timeoutMsg = nullptr |
|
protected |
The documentation for this class was generated from the following files:
simtime_t stopTime
Definition: TcpBasicClientApp.h:27
int numRequestsToSend
Definition: TcpBasicClientApp.h:25
simtime_t startTime
Definition: TcpBasicClientApp.h:26
virtual void close() override
Definition: TcpBasicClientApp.cc:163
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
virtual void initialize(int stage) override
Definition: TcpAppBase.cc:17
virtual void socketEstablished(TcpSocket *socket) override
Definition: TcpAppBase.cc:113
@ LOCALLY_CLOSED
Definition: TcpSocket.h:153
TcpSocket::State getState() const
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED,...
Definition: TcpSocket.h:218
virtual void sendPacket(Packet *pkt)
Definition: TcpAppBase.cc:97
#define MSGKIND_CONNECT
Definition: TcpBasicClientApp.cc:18
intscale< b, 1, 8 > B
Definition: Units.h:1168
virtual void connect()
Definition: TcpAppBase.cc:50
TcpSocket socket
Definition: TcpAppBase.h:25
virtual void socketDataArrived(TcpSocket *socket, Packet *msg, bool urgent) override
Notifies about data arrival, packet ownership is transferred to the callee.
Definition: TcpAppBase.cc:119
cMessage * timeoutMsg
Definition: TcpBasicClientApp.h:23
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
bool earlySend
Definition: TcpBasicClientApp.h:24
virtual void destroy() override
Destroy the connection.
Definition: TcpSocket.cc:186
virtual void socketFailure(TcpSocket *socket, int code) override
Definition: TcpAppBase.cc:144
double max(const double a, const double b)
Returns the maximum of a and b.
Definition: SctpAssociation.h:266
@ CONNECTED
Definition: TcpSocket.h:153
virtual void socketClosed(TcpSocket *socket) override
Definition: TcpAppBase.cc:138
virtual void sendRequest()
Definition: TcpBasicClientApp.cc:69
@ CONNECTING
Definition: TcpSocket.h:153
@ PEER_CLOSED
Definition: TcpSocket.h:153
#define MSGKIND_SEND
Definition: TcpBasicClientApp.cc:19
virtual void rescheduleAfterOrDeleteTimer(simtime_t d, short int msgKind)
Definition: TcpBasicClientApp.cc:133
virtual void close()
Definition: TcpAppBase.cc:90