|
INET Framework for OMNeT++/OMNEST
|
Single-connection TCP application.
More...
#include <TcpSessionApp.h>
Single-connection TCP application.
◆ CommandVector
◆ TcpSessionApp()
| inet::TcpSessionApp::TcpSessionApp |
( |
| ) |
|
|
inline |
◆ ~TcpSessionApp()
| inet::TcpSessionApp::~TcpSessionApp |
( |
| ) |
|
|
virtual |
◆ createDataPacket()
| Packet * inet::TcpSessionApp::createDataPacket |
( |
long |
sendBytes | ) |
|
|
protectedvirtual |
121 const char *dataTransferMode = par(
"dataTransferMode");
123 if (!strcmp(dataTransferMode,
"bytecount")) {
124 payload = makeShared<ByteCountChunk>(
B(
sendBytes));
126 else if (!strcmp(dataTransferMode,
"object")) {
127 const auto& applicationPacket = makeShared<ApplicationPacket>();
128 applicationPacket->setChunkLength(
B(
sendBytes));
129 payload = applicationPacket;
131 else if (!strcmp(dataTransferMode,
"bytestream")) {
132 const auto& bytesChunk = makeShared<BytesChunk>();
133 std::vector<uint8_t> vec;
137 bytesChunk->setBytes(vec);
138 payload = bytesChunk;
141 throw cRuntimeError(
"Invalid data transfer mode: %s", dataTransferMode);
142 payload->addTag<CreationTimeTag>()->setCreationTime(simTime());
143 Packet *packet =
new Packet(
"data1");
144 packet->insertAtBack(payload);
Referenced by sendData().
◆ finish()
| void inet::TcpSessionApp::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
◆ handleCrashOperation()
◆ handleStartOperation()
◆ handleStopOperation()
◆ handleTimer()
| void inet::TcpSessionApp::handleTimer |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
Implements inet::TcpAppBase.
82 switch (msg->getKind()) {
87 throw cRuntimeError(
"TODO");
99 throw cRuntimeError(
"Invalid timer msg: kind=%d", msg->getKind());
◆ initialize()
| void inet::TcpSessionApp::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
Reimplemented from inet::TcpAppBase.
44 const char *script = par(
"sendScript");
48 throw cRuntimeError(
"Cannot use both sendScript and tSend+sendBytes");
52 throw cRuntimeError(
"sendScript is empty");
◆ numInitStages()
| virtual int inet::TcpSessionApp::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ parseScript()
| void inet::TcpSessionApp::parseScript |
( |
const char * |
script | ) |
|
|
protectedvirtual |
179 const char *
s = script;
181 EV_DEBUG <<
"parse script \"" << script <<
"\"\n";
187 if (!*
s || *
s ==
';')
191 simtime_t
tSend = strtod(
s, &
const_cast<char *&
>(
s));
194 throw cRuntimeError(
"Syntax error in script: simulation time expected");
201 throw cRuntimeError(
"Syntax error in script: number of bytes expected");
203 long numBytes = strtol(
s,
nullptr, 10);
209 EV_DEBUG <<
" add command (" <<
tSend <<
"s, " << numBytes <<
"B)\n";
220 throw cRuntimeError(
"Syntax error in script: separator ';' missing");
227 EV_DEBUG <<
"parser finished\n";
Referenced by initialize().
◆ refreshDisplay()
| void inet::TcpSessionApp::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
Reimplemented from inet::TcpAppBase.
241 std::ostringstream os;
243 getDisplayString().setTagArg(
"t", 0, os.str().c_str());
◆ sendData()
| void inet::TcpSessionApp::sendData |
( |
| ) |
|
|
protectedvirtual |
106 EV_INFO <<
"sending data with " << numBytes <<
" bytes\n";
Referenced by handleTimer().
◆ socketClosed()
| void inet::TcpSessionApp::socketClosed |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived()
| void inet::TcpSessionApp::socketDataArrived |
( |
TcpSocket * |
socket, |
|
|
Packet * |
packet, |
|
|
bool |
urgent |
|
) |
| |
|
overrideprotectedvirtual |
Notifies about data arrival, packet ownership is transferred to the callee.
Reimplemented from inet::TcpAppBase.
◆ socketEstablished()
| void inet::TcpSessionApp::socketEstablished |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketFailure()
| void inet::TcpSessionApp::socketFailure |
( |
TcpSocket * |
socket, |
|
|
int |
code |
|
) |
| |
|
overrideprotectedvirtual |
◆ activeOpen
| bool inet::TcpSessionApp::activeOpen = false |
|
protected |
◆ commandIndex
| int inet::TcpSessionApp::commandIndex = -1 |
|
protected |
◆ commands
◆ sendBytes
| int inet::TcpSessionApp::sendBytes = 0 |
|
protected |
◆ tClose
| simtime_t inet::TcpSessionApp::tClose |
|
protected |
◆ timeoutMsg
| cMessage* inet::TcpSessionApp::timeoutMsg = nullptr |
|
protected |
◆ tOpen
| simtime_t inet::TcpSessionApp::tOpen |
|
protected |
◆ tSend
| simtime_t inet::TcpSessionApp::tSend |
|
protected |
The documentation for this class was generated from the following files:
#define MSGKIND_SEND
Definition: TcpSessionApp.cc:25
State operationalState
Definition: OperationalMixin.h:23
virtual void parseScript(const char *script)
Definition: TcpSessionApp.cc:177
static const char * stateName(TcpSocket::State state)
Returns name of socket state code returned by getState().
Definition: TcpSocket.cc:372
cModule * getContainingNode(const cModule *from)
Find the node containing the given module.
Definition: ModuleAccess.cc:40
virtual bool isOpen() const override
Definition: TcpSocket.cc:257
virtual void initialize(int stage) override
Definition: TcpAppBase.cc:17
#define MSGKIND_CLOSE
Definition: TcpSessionApp.cc:26
virtual Packet * createDataPacket(long sendBytes)
Definition: TcpSessionApp.cc:119
cMessage * timeoutMsg
Definition: TcpSessionApp.h:41
virtual void socketEstablished(TcpSocket *socket) override
Definition: TcpAppBase.cc:113
simtime_t tClose
Definition: TcpSessionApp.h:36
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
simtime_t tSend
Definition: TcpSessionApp.h:35
value< double, units::s > s
Definition: Units.h:1235
virtual void sendData()
Definition: TcpSessionApp.cc:103
intscale< b, 1, 8 > B
Definition: Units.h:1168
virtual void connect()
Definition: TcpAppBase.cc:50
int bytesSent
Definition: TcpAppBase.h:32
TcpSocket socket
Definition: TcpAppBase.h:25
virtual void refreshDisplay() const override
Definition: TcpAppBase.cc:107
int sendBytes
Definition: TcpSessionApp.h:37
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
int commandIndex
Definition: TcpSessionApp.h:40
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
CommandVector commands
Definition: TcpSessionApp.h:31
simtime_t tOpen
Definition: TcpSessionApp.h:34
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
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
virtual void delayActiveOperationFinish(simtime_t timeout)
Definition: OperationalMixinImpl.h:161
virtual void startActiveOperationExtraTimeOrFinish(simtime_t extraTime)
Definition: OperationalMixinImpl.h:179
virtual void socketClosed(TcpSocket *socket) override
Definition: TcpAppBase.cc:138
int bytesRcvd
Definition: TcpAppBase.h:33
virtual void close()
Definition: TcpAppBase.cc:90
bool activeOpen
Definition: TcpSessionApp.h:33
#define MSGKIND_CONNECT
Definition: TcpSessionApp.cc:24
int packetsRcvd
Definition: TcpAppBase.h:31