TcpGenericServerApp

Package: inet.applications.tcpapp

simple module TcpGenericServerApp

Generic server application for modeling TCP-based request-reply style protocols or applications.

The module listens on the designated TCP port, accepting incoming TCP connections. When a TCP connection is established, the model expects to receive messages of class GenericAppMsg on it. A message should contain how large the reply should be (number of bytes). For each received GenericAppMsg, TcpGenericServerApp will create another GenericAppMsg with the requested length as a response and send it back. The reply can be delayed by a constant time (replyDelay parameter).

By default, the server does not impose rate limiting on data reads from the socket. To enable rate limiting, you can set autoRead to “false” and configure the readSize and readDelay parameters, thereby facilitating TCP flow control.

Compatible with both Ipv4 and Ipv6.

See also: GenericAppMsg, TcpBasicClientApp, TelnetApp

inet.applications.tcpapp.TcpGenericServerAppTcpGenericServerAppsimple

Inheritance diagram

Extends

Name

Type

Description

SimpleModule

simple module

Base module for all INET simple modules.

Parameters

Name

Type

Default value

Description

displayStringTextFormat

string

“rcvd: {msgsRcvd} pks {bytesRcvd} bytes\nsent: {msgsSent} pks {bytesSent} bytes”

Determines the text that is written on top of the submodule, supports displaying pars, watches, and module-specific information

localAddress

string

“”

Local address; it may be left empty (“”)

localPort

int

1000

LocalPort number to listen on

autoRead

bool

true

Whether to use “autoread” or “explicit-read” mode for TCP connection

readSize

int

-1B

Used only with autoRead==false

readDelay

double

-1s

Used only with autoRead==false; delay for issuing a READ command after the previous READ was satisfied; -1 means immediately, 0 means zero delay

replyDelay

double

0s

stopOperationExtraTime

double

-1s

Extra time after lifecycle stop operation finished

stopOperationTimeout

double

2s

Timeout value for the lifecycle stop operation

Properties

Name

Value

Description

class

TcpGenericServerApp

display

i=block/app

lifecycleSupport

Gates

Name

Direction

Size

Description

socketIn

input

socketOut

output

Signals

Name

Type

Unit

Description

packetReceived

inet::Packet

packetSent

inet::Packet

Statistics

Name

Title

Source

Record

Unit

Interpolation Mode

Description

endToEndDelay

end-to-end delay

dataAge(packetReceived)

histogram,weightedHistogram,vector

s

none

packetReceived

packets received

packetReceived

count,”sum(packetBytes)”,”vector(packetBytes)”

none

packetSent

packets sent

packetSent

count,”sum(packetBytes)”,”vector(packetBytes)”

none

Source code

//
// Generic server application for modeling TCP-based request-reply style
// protocols or applications.
//
// The module listens on the designated TCP port, accepting incoming TCP
// connections. When a TCP connection is established, the model expects to
// receive messages of class ~GenericAppMsg on it. A message should contain how
// large the reply should be (number of bytes). For each received
// ~GenericAppMsg, ~TcpGenericServerApp will create another ~GenericAppMsg with
// the requested length as a response and send it back. The reply can be delayed
// by a constant time (`replyDelay` parameter).
//
// By default, the server does not impose rate limiting on data reads from the
// socket. To enable rate limiting, you can set `autoRead` to "false" and
// configure the `readSize` and `readDelay` parameters, thereby facilitating TCP
// flow control.
//
// Compatible with both ~Ipv4 and ~Ipv6.
//
// @see ~GenericAppMsg, ~TcpBasicClientApp, ~TelnetApp
//
simple TcpGenericServerApp extends SimpleModule like IApp
{
    parameters:
        @class(TcpGenericServerApp);
        string localAddress = default(""); // Local address; it may be left empty ("")
        int localPort = default(1000);     // LocalPort number to listen on
        bool autoRead = default(true); // Whether to use "autoread" or "explicit-read" mode for TCP connection
        volatile int readSize @unit(B) = default(-1B);    // Used only with autoRead==false
        volatile double readDelay @unit(s) = default(-1s);    // Used only with autoRead==false; delay for issuing a READ command after the previous READ was satisfied; -1 means immediately, 0 means zero delay
        double replyDelay @unit(s) = default(0s);
        displayStringTextFormat = default("rcvd: {msgsRcvd} pks {bytesRcvd} bytes\nsent: {msgsSent} pks {bytesSent} bytes");
        @display("i=block/app");
        @lifecycleSupport;
        double stopOperationExtraTime @unit(s) = default(-1s);    // Extra time after lifecycle stop operation finished
        double stopOperationTimeout @unit(s) = default(2s);    // Timeout value for the lifecycle stop operation
        @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);
    gates:
        input socketIn @labels(TcpCommand/up);
        output socketOut @labels(TcpCommand/down);
}

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