INET Framework for OMNeT++/OMNEST
inet::TcpEchoApp Class Reference

Accepts any number of incoming connections, and sends back whatever arrives on them. More...

#include <TcpEchoApp.h>

Inheritance diagram for inet::TcpEchoApp:
inet::TcpServerHostApp inet::ApplicationBase inet::TcpSocket::ICallback inet::OperationalBase inet::OperationalMixin< cSimpleModule > inet::ILifecycle

Public Member Functions

 TcpEchoApp ()
 
 ~TcpEchoApp ()
 
- Public Member Functions inherited from inet::TcpServerHostApp
virtual ~TcpServerHostApp ()
 
virtual void removeThread (TcpServerThreadBase *thread)
 
virtual void threadClosed (TcpServerThreadBase *thread)
 
- Public Member Functions inherited from inet::ApplicationBase
 ApplicationBase ()
 
- Public Member Functions inherited from inet::OperationalMixin< cSimpleModule >
virtual ~OperationalMixin ()
 }@ More...
 
- Public Member Functions inherited from inet::ILifecycle
virtual ~ILifecycle ()
 
- Public Member Functions inherited from inet::TcpSocket::ICallback
virtual ~ICallback ()
 

Protected Member Functions

virtual void sendDown (Packet *packet)
 
virtual void initialize (int stage) override
 
virtual int numInitStages () const override
 
virtual void finish () override
 
virtual void refreshDisplay () const override
 
- Protected Member Functions inherited from inet::TcpServerHostApp
virtual void handleMessageWhenUp (cMessage *msg) override
 
virtual void socketDataArrived (TcpSocket *socket, Packet *packet, bool urgent) override
 Notifies about data arrival, packet ownership is transferred to the callee. More...
 
virtual void socketAvailable (TcpSocket *socket, TcpAvailableInfo *availableInfo) override
 
virtual void socketEstablished (TcpSocket *socket) override
 
virtual void socketPeerClosed (TcpSocket *socket) override
 
virtual void socketClosed (TcpSocket *socket) override
 
virtual void socketFailure (TcpSocket *socket, int code) override
 
virtual void socketStatusArrived (TcpSocket *socket, TcpStatusInfo *status) override
 
virtual void socketDeleted (TcpSocket *socket) override
 
virtual void handleStartOperation (LifecycleOperation *operation) override
 
virtual void handleStopOperation (LifecycleOperation *operation) override
 
virtual void handleCrashOperation (LifecycleOperation *operation) override
 
- Protected Member Functions inherited from inet::ApplicationBase
virtual bool isInitializeStage (int stage) const override
 
virtual bool isModuleStartStage (int stage) const override
 
virtual bool isModuleStopStage (int stage) const override
 
- Protected Member Functions inherited from inet::OperationalMixin< cSimpleModule >
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 ()
 

Protected Attributes

simtime_t delay
 
double echoFactor = NaN
 
long bytesRcvd = 0
 
long bytesSent = 0
 
- Protected Attributes inherited from inet::TcpServerHostApp
TcpSocket serverSocket
 
SocketMap socketMap
 
ThreadSet threadSet
 
- Protected Attributes inherited from inet::OperationalMixin< cSimpleModule >
State operationalState
 
simtime_t lastChange
 
Operation activeOperation
 
cMessage * activeOperationTimeout
 
cMessage * activeOperationExtraTimer
 

Friends

class TcpEchoAppThread
 

Additional Inherited Members

- Protected Types inherited from inet::TcpServerHostApp
typedef std::set< TcpServerThreadBase * > ThreadSet
 
- Protected Types inherited from inet::OperationalMixin< cSimpleModule >
enum  State
 

Detailed Description

Accepts any number of incoming connections, and sends back whatever arrives on them.

Constructor & Destructor Documentation

◆ TcpEchoApp()

inet::TcpEchoApp::TcpEchoApp ( )
25 {
26 }

◆ ~TcpEchoApp()

inet::TcpEchoApp::~TcpEchoApp ( )
29 {
30 }

Member Function Documentation

◆ finish()

void inet::TcpEchoApp::finish ( )
overrideprotectedvirtual

Reimplemented from inet::TcpServerHostApp.

69 {
71 
72  recordScalar("bytesRcvd", bytesRcvd);
73  recordScalar("bytesSent", bytesSent);
74 }

◆ initialize()

void inet::TcpEchoApp::initialize ( int  stage)
overrideprotectedvirtual

Reimplemented from inet::TcpServerHostApp.

33 {
35 
36  if (stage == INITSTAGE_LOCAL) {
37  delay = par("echoDelay");
38  echoFactor = par("echoFactor");
39 
40  bytesRcvd = bytesSent = 0;
41  WATCH(bytesRcvd);
42  WATCH(bytesSent);
43  }
44 }

◆ numInitStages()

virtual int inet::TcpEchoApp::numInitStages ( ) const
inlineoverrideprotectedvirtual

Reimplemented from inet::TcpServerHostApp.

34 { return NUM_INIT_STAGES; }

◆ refreshDisplay()

void inet::TcpEchoApp::refreshDisplay ( ) const
overrideprotectedvirtual

Reimplemented from inet::TcpServerHostApp.

60 {
62 
63  char buf[160];
64  sprintf(buf, "threads: %d\nrcvd: %ld bytes\nsent: %ld bytes", socketMap.size(), bytesRcvd, bytesSent);
65  getDisplayString().setTagArg("t", 0, buf);
66 }

◆ sendDown()

void inet::TcpEchoApp::sendDown ( Packet packet)
protectedvirtual
47 {
48  if (msg->isPacket()) {
49  Packet *pk = static_cast<Packet *>(msg);
50  bytesSent += pk->getByteLength();
51  emit(packetSentSignal, pk);
52  }
53 
54  msg->addTagIfAbsent<DispatchProtocolReq>()->setProtocol(&Protocol::tcp);
55  msg->getTag<SocketReq>();
56  send(msg, "socketOut");
57 }

Referenced by inet::TcpEchoAppThread::dataArrived(), and inet::TcpEchoAppThread::timerExpired().

Friends And Related Function Documentation

◆ TcpEchoAppThread

friend class TcpEchoAppThread
friend

Member Data Documentation

◆ bytesRcvd

long inet::TcpEchoApp::bytesRcvd = 0
protected

◆ bytesSent

long inet::TcpEchoApp::bytesSent = 0
protected

◆ delay

simtime_t inet::TcpEchoApp::delay
protected

◆ echoFactor

double inet::TcpEchoApp::echoFactor = NaN
protected

The documentation for this class was generated from the following files:
inet::TcpServerHostApp::initialize
virtual void initialize(int stage) override
Definition: TcpServerHostApp.cc:20
inet::TcpEchoApp::bytesSent
long bytesSent
Definition: TcpEchoApp.h:28
inet::Protocol::tcp
static const Protocol tcp
Definition: Protocol.h:112
DispatchProtocolReq
removed DscpReq Ipv4ControlInfo Ipv6ControlInfo up L3AddressInd DispatchProtocolReq L4PortInd Ipv4ControlInfo Ipv6ControlInfo down DispatchProtocolReq
Definition: IUdp-gates.txt:25
inet::TcpServerHostApp::socketMap
SocketMap socketMap
Definition: TcpServerHostApp.h:29
inet::packetSentSignal
simsignal_t packetSentSignal
Definition: Simsignals.cc:96
inet::SocketMap::size
unsigned int size() const
Returns the number of sockets stored.
Definition: SocketMap.h:52
inet::TcpServerHostApp::finish
virtual void finish() override
Definition: TcpServerHostApp.cc:89
inet::INITSTAGE_LOCAL
INET_API InitStage INITSTAGE_LOCAL
Initialization of local state that don't use or affect other modules includes:
NUM_INIT_STAGES
#define NUM_INIT_STAGES
Definition: InitStageRegistry.h:73
inet::TcpEchoApp::delay
simtime_t delay
Definition: TcpEchoApp.h:24
inet::TcpEchoApp::bytesRcvd
long bytesRcvd
Definition: TcpEchoApp.h:27
inet::OperationalMixin< cSimpleModule >::refreshDisplay
virtual void refreshDisplay() const override
Definition: OperationalMixinImpl.h:200
inet::TcpEchoApp::echoFactor
double echoFactor
Definition: TcpEchoApp.h:25