|
INET Framework for OMNeT++/OMNEST
|
Base class for clients app for TCP-based request-reply protocols or apps.
More...
#include <TcpAppBase.h>
Base class for clients app for TCP-based request-reply protocols or apps.
Handles a single session (and TCP connection) at a time.
It needs the following NED parameters: localAddress, localPort, connectAddress, connectPort.
◆ close()
| void inet::TcpAppBase::close |
( |
| ) |
|
|
protectedvirtual |
◆ connect()
| void inet::TcpAppBase::connect |
( |
| ) |
|
|
protectedvirtual |
55 const char *localAddress = par(
"localAddress");
56 int localPort = par(
"localPort");
57 socket.
bind(*localAddress ? L3AddressResolver().resolve(localAddress) : L3Address(), localPort);
59 int timeToLive = par(
"timeToLive");
63 int dscp = par(
"dscp");
72 const char *connectAddress = par(
"connectAddress");
73 int connectPort = par(
"connectPort");
75 L3Address destination;
76 L3AddressResolver().tryResolve(connectAddress, destination);
77 if (destination.isUnspecified()) {
78 EV_ERROR <<
"Connecting to " << connectAddress <<
" port=" << connectPort <<
": cannot resolve destination address\n";
81 EV_INFO <<
"Connecting to " << connectAddress <<
"(" << destination <<
") port=" << connectPort << endl;
Referenced by inet::TelnetApp::handleTimer(), inet::TcpBasicClientApp::handleTimer(), and inet::TcpSessionApp::handleTimer().
◆ finish()
| void inet::TcpAppBase::finish |
( |
| ) |
|
|
overrideprotectedvirtual |
Reimplemented in inet::TcpSessionApp.
153 std::string modulePath = getFullPath();
155 EV_INFO << modulePath <<
": opened " <<
numSessions <<
" sessions\n";
157 EV_INFO << modulePath <<
": received " <<
bytesRcvd <<
" bytes in " <<
packetsRcvd <<
" packets\n";
◆ handleMessageWhenUp()
| void inet::TcpAppBase::handleMessageWhenUp |
( |
cMessage * |
msg | ) |
|
|
overrideprotectedvirtual |
◆ handleTimer()
| virtual void inet::TcpAppBase::handleTimer |
( |
cMessage * |
msg | ) |
|
|
protectedpure virtual |
◆ initialize()
| void inet::TcpAppBase::initialize |
( |
int |
stage | ) |
|
|
overrideprotectedvirtual |
◆ numInitStages()
| virtual int inet::TcpAppBase::numInitStages |
( |
| ) |
const |
|
inlineoverrideprotectedvirtual |
◆ refreshDisplay()
| void inet::TcpAppBase::refreshDisplay |
( |
| ) |
const |
|
overrideprotectedvirtual |
◆ sendPacket()
| void inet::TcpAppBase::sendPacket |
( |
Packet * |
pkt | ) |
|
|
protectedvirtual |
◆ socketAvailable()
|
|
inlineoverrideprotectedvirtual |
◆ socketClosed()
| void inet::TcpAppBase::socketClosed |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketDataArrived()
| void inet::TcpAppBase::socketDataArrived |
( |
TcpSocket * |
socket, |
|
|
Packet * |
packet, |
|
|
bool |
urgent |
|
) |
| |
|
overrideprotectedvirtual |
◆ socketDeleted()
| virtual void inet::TcpAppBase::socketDeleted |
( |
TcpSocket * |
socket | ) |
|
|
inlineoverrideprotectedvirtual |
◆ socketEstablished()
| void inet::TcpAppBase::socketEstablished |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketFailure()
| void inet::TcpAppBase::socketFailure |
( |
TcpSocket * |
socket, |
|
|
int |
code |
|
) |
| |
|
overrideprotectedvirtual |
◆ socketPeerClosed()
| void inet::TcpAppBase::socketPeerClosed |
( |
TcpSocket * |
socket | ) |
|
|
overrideprotectedvirtual |
◆ socketStatusArrived()
|
|
inlineoverrideprotectedvirtual |
◆ bytesRcvd
| int inet::TcpAppBase::bytesRcvd |
|
protected |
◆ bytesSent
| int inet::TcpAppBase::bytesSent |
|
protected |
◆ connectSignal
| simsignal_t inet::TcpAppBase::connectSignal = registerSignal("connect") |
|
staticprotected |
◆ numBroken
| int inet::TcpAppBase::numBroken |
|
protected |
◆ numSessions
| int inet::TcpAppBase::numSessions |
|
protected |
◆ packetsRcvd
| int inet::TcpAppBase::packetsRcvd |
|
protected |
◆ packetsSent
| int inet::TcpAppBase::packetsSent |
|
protected |
◆ socket
Referenced by close(), connect(), inet::TelnetApp::handleCrashOperation(), inet::TcpBasicClientApp::handleCrashOperation(), inet::TcpSessionApp::handleCrashOperation(), handleMessageWhenUp(), inet::TelnetApp::handleStopOperation(), inet::TcpBasicClientApp::handleStopOperation(), inet::TcpSessionApp::handleStopOperation(), initialize(), refreshDisplay(), inet::TcpSessionApp::refreshDisplay(), sendPacket(), inet::TelnetApp::socketClosed(), inet::TcpBasicClientApp::socketClosed(), inet::TcpSessionApp::socketClosed(), inet::TelnetApp::socketDataArrived(), inet::TcpBasicClientApp::socketDataArrived(), inet::TcpSessionApp::socketDataArrived(), inet::TelnetApp::socketEstablished(), inet::TcpBasicClientApp::socketEstablished(), inet::TcpSessionApp::socketEstablished(), inet::TelnetApp::socketFailure(), inet::TcpBasicClientApp::socketFailure(), inet::TcpSessionApp::socketFailure(), and socketPeerClosed().
The documentation for this class was generated from the following files:
virtual void send(Packet *msg) override
Sends data packet.
Definition: TcpSocket.cc:147
static simsignal_t connectSignal
Definition: TcpAppBase.h:36
int packetsSent
Definition: TcpAppBase.h:30
void setCallback(ICallback *cb)
Sets a callback object, to be used with processMessage().
Definition: TcpSocket.cc:276
static const char * stateName(TcpSocket::State state)
Returns name of socket state code returned by getState().
Definition: TcpSocket.cc:372
virtual void handleTimer(cMessage *msg)=0
virtual void initialize(int stage) override
Definition: OperationalMixinImpl.h:26
void connect(L3Address remoteAddr, int remotePort)
Active OPEN to the given remote socket.
Definition: TcpSocket.cc:122
void accept(int socketId)
Accepts a new incoming connection reported as available.
Definition: TcpSocket.cc:114
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
void setTos(short tos)
Sets the Ipv4 Type of Service / Ipv6 Traffic Class fields of packets sent from the TCP socket.
Definition: TcpSocket.cc:225
TcpSocket::State getState() const
Returns the socket state, one of NOT_BOUND, CLOSED, LISTENING, CONNECTING, CONNECTED,...
Definition: TcpSocket.h:218
simsignal_t packetReceivedSignal
Definition: Simsignals.cc:97
int bytesSent
Definition: TcpAppBase.h:32
TcpSocket socket
Definition: TcpAppBase.h:25
int numBroken
Definition: TcpAppBase.h:29
int numSessions
Definition: TcpAppBase.h:28
void setDscp(short dscp)
Sets the Ipv4 / Ipv6 dscp fields of packets sent from the TCP socket.
Definition: TcpSocket.cc:216
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:
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
INET_API InitStage INITSTAGE_APPLICATION_LAYER
Initialization of applications.
@ PEER_CLOSED
Definition: TcpSocket.h:153
int bytesRcvd
Definition: TcpAppBase.h:33
void bind(int localPort)
Bind the socket to a local port number.
Definition: TcpSocket.cc:69
void setTimeToLive(int ttl)
Set the TTL (Ipv6: Hop Limit) field on sent packets.
Definition: TcpSocket.cc:207
void setOutputGate(cGate *toTcp)
Sets the gate on which to send to TCP.
Definition: TcpSocket.h:242
void close() override
Closes the local end of the connection.
Definition: TcpSocket.cc:161
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
virtual void close()
Definition: TcpAppBase.cc:90
void renewSocket()
Required to re-connect with a "used" TcpSocket object.
Definition: TcpSocket.cc:249
int packetsRcvd
Definition: TcpAppBase.h:31