TcpEchoApp

Package: inet.applications.tcpapp

TcpEchoApp

simple module

Accepts any number of incoming TCP connections, and sends back the messages that arrive on them, The lengths of the messages are multiplied by echoFactor before sending them back (echoFactor=1 will result in sending back the same message unmodified.) The reply can also be delayed by a constant time (echoDelay parameter).

Compatible with both Ipv4 and Ipv6.

Inheritance diagram

The following diagram shows inheritance relationships for this type. Unresolved types are missing from the diagram.

Extends

Name Type Description
TcpServerHostApp simple module

This module hosts TCP-based server applications. It dynamically creates and launches a new "thread" object for each incoming connection.

Parameters

Name Type Default value Description
localAddress string ""

may be left empty ("")

localPort int 1000

port number to listen on

serverThreadModuleType string "inet.applications.tcpapp.TcpEchoAppThread"

module type of "thread" module to launch on incoming connections

stopOperationExtraTime double -1s

extra time after lifecycle stop operation finished

stopOperationTimeout double 2s

timeout value for lifecycle stop operation

echoFactor double 1
echoDelay double 0s

Properties

Name Value Description
display i=block/app
lifecycleSupport
class TcpEchoApp

Gates

Name Direction Size Description
socketIn input
socketOut output

Signals

Name Type Unit
packetReceived inet::Packet
packetSent inet::Packet

Statistics

Name Title Source Record Unit Interpolation Mode
packetReceived packets received packetReceived count, sum(packetBytes), vector(packetBytes) none
packetSent packets sent packetSent count, sum(packetBytes), vector(packetBytes) none
endToEndDelay end-to-end delay dataAge(packetReceived) histogram, weightedHistogram, vector s none

Direct method calls (observed)

call tofunctioninfo
MessageDispatcherinet::MessageDispatcher::arrivedarrived

Incoming messages (observed)

gatemsgkindctrlsrcModuletags
socketInIndication3 (TcpStatusInd::TCP_I_AVAILABLE)TcpAvailableInfoTcpSocketInd
socketInIndication3 (TcpStatusInd::TCP_I_AVAILABLE)TcpAvailableInfoTcpLwipSocketInd, TransportProtocolInd
socketInIndication4 (TcpStatusInd::TCP_I_ESTABLISHED)TcpConnectInfoTcpSocketInd
socketInIndication4 (TcpStatusInd::TCP_I_ESTABLISHED)TcpConnectInfoTcpLwipSocketInd, TransportProtocolInd
socketInIndication5 (TcpStatusInd::TCP_I_PEER_CLOSED)TcpCommandTcpSocketInd
socketInIndication5 (TcpStatusInd::TCP_I_PEER_CLOSED)TcpCommandTcpLwipSocketInd, TransportProtocolInd
socketInIndication6 (TcpStatusInd::TCP_I_CLOSED)TcpCommandTcpSocketInd
socketInPacket1 (TcpStatusInd::TCP_I_DATA)TcpSocketInd
socketInPacket1 (TcpStatusInd::TCP_I_DATA)TcpLwipSocketInd, TransportProtocolInd

Outgoing messages (observed)

gatemsgkindctrldestModuletags
socketOutPacket4 (TcpCommandCode::TCP_C_SEND)TcpDispatchProtocolReq, SocketReq
socketOutPacket4 (TcpCommandCode::TCP_C_SEND)TcpLwipDispatchProtocolReq, SocketReq
socketOutRequest2 (TcpCommandCode::TCP_C_OPEN_PASSIVE)TcpOpenCommandTcpDispatchProtocolReq, SocketReq
socketOutRequest2 (TcpCommandCode::TCP_C_OPEN_PASSIVE)TcpOpenCommandTcpLwipDispatchProtocolReq, SocketReq
socketOutRequest3 (TcpCommandCode::TCP_C_ACCEPT)TcpAcceptCommandTcpDispatchProtocolReq, SocketReq
socketOutRequest3 (TcpCommandCode::TCP_C_ACCEPT)TcpAcceptCommandTcpLwipDispatchProtocolReq, SocketReq
socketOutRequest5 (TcpCommandCode::TCP_C_CLOSE)TcpCommandTcpDispatchProtocolReq, SocketReq
socketOutRequest5 (TcpCommandCode::TCP_C_CLOSE)TcpCommandTcpLwipDispatchProtocolReq, SocketReq

Packet operations (observed)

chunkTypepacketAction
peekData, peekDataAt
ByteCountChunkinsertAtBack
BytesChunkinsertAtBack
SliceChunkinsertAtBack

Shared Tagging operations (observed)

tagTypetagAction
DispatchProtocolReqaddTagIfAbsent
SocketIndfindTag, getTag
SocketReqaddTag, addTagIfAbsent, getTag

Region Tagging operations (observed)

tagTypetagAction
CreationTimeTaggetAllTags

Source code

//
// Accepts any number of incoming TCP connections, and sends back the
// messages that arrive on them, The lengths of the messages are
// multiplied by echoFactor before sending them back (echoFactor=1 will
// result in sending back the same message unmodified.) The reply can also be
// delayed by a constant time (echoDelay parameter).
//
// Compatible with both ~Ipv4 and ~Ipv6.
//
simple TcpEchoApp extends TcpServerHostApp
{
    parameters:
        @class(TcpEchoApp);
        double echoFactor = default(1);
        double echoDelay @unit(s) = default(0s);
        serverThreadModuleType = default("inet.applications.tcpapp.TcpEchoAppThread"); // module type of "thread" module to launch on incoming connections
        @signal[packetSent](type=inet::Packet);
        @signal[packetReceived](type=inet::Packet);
        @statistic[packetReceived](title="packets received"; source=packetReceived; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[packetSent](title="packets sent"; source=packetSent; record=count,"sum(packetBytes)","vector(packetBytes)"; interpolationmode=none);
        @statistic[endToEndDelay](title="end-to-end delay"; source="dataAge(packetReceived)"; unit=s; record=histogram,weightedHistogram,vector; interpolationmode=none);
}

File: src/inet/applications/tcpapp/TcpEchoApp.ned