TcpBasicClientApp

Package: inet.applications.tcpapp

TcpBasicClientApp

simple module

Client for a generic request-response style protocol over TCP. May be used as a rough model of HTTP or FTP users. Compatible with both IPv4 (Ipv4) and IPv6 (Ipv6).

The model communicates with the server in sessions. During a session, the client opens a single TCP connection to the server, sends several requests (always waiting for the complete reply to arrive before sending a new request), and closes the connection.

The server app should be TcpGenericServerApp; the model sends GenericAppMsg messages.

Example settings:

FTP:

   numRequestsPerSession = exponential(3)
   requestLength = 1B*int(truncnormal(20,5))
   replyLength = 1B*int(exponential(1000000))

Note that this module doesn't open separate TCP connections for commands and data transfer as the FTP protocol.

HTTP:

   numRequestsPerSession = 1 (HTTP 1.0)
   numRequestsPerSession = exponential(5) (HTTP 1.1, with keepalive)
   requestLength = 1B*int(truncnormal(350,20))
   replyLength = 1B*int(exponential(2000))

Note that since most web pages contain images and may contain frames, applets etc, possibly from various servers, and browsers usually download these items in parallel to the main HTML document, this module cannot serve as a realistic web client.

Also, with HTTP 1.0 it is the server that closes the connection after sending the response, while in this model it is the client.

See also: TcpGenericServerApp, GenericAppMsg, TelnetApp

Inheritance diagram

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

Parameters

Name Type Default value Description
localAddress string ""

may be left empty ("")

localPort int -1

port number to listen on

connectAddress string ""

server address (may be symbolic)

connectPort int 1000

port number to connect to

startTime double 1s

time first session begins

stopTime double -1s

time of finishing sending, negative values mean forever

numRequestsPerSession int 1

number of requests sent per session

requestLength int 200B

length of a request

replyLength int 1MiB

length of a reply

thinkTime double

time gap between requests

idleInterval double

time gap between sessions

reconnectInterval double 30s

if connection breaks, waits this much before trying to reconnect

timeToLive int -1

if not -1, set the TTL (IPv4) or Hop Limit (IPv6) field of sent packets to this value

dscp int -1

if not -1, set the DSCP (IPv4/IPv6) field of sent packets to this value

tos int -1

if not -1, set the Type Of Service (IPv4) / Traffic Class (IPv6) field of sent packets to this value

stopOperationExtraTime double -1s

extra time after lifecycle stop operation finished

stopOperationTimeout double 2s

timeout value for lifecycle stop operation

Properties

Name Value Description
display i=block/app
lifecycleSupport

Gates

Name Direction Size Description
socketIn input
socketOut output

Signals

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

Statistics

Name Title Source Record Unit Interpolation Mode
packetReceived packets received packetReceived count, sum(packetBytes), vector(packetBytes) none
numSessions total number of sessions sum(connect+1)/2 last
packetSent packets sent packetSent count, sum(packetBytes), vector(packetBytes) none
numActiveSessions number of active sessions warmup(sum(connect)) max, timeavg, vector sample-hold
endToEndDelay end-to-end delay dataAge(packetReceived) histogram, weightedHistogram, vector s none

Scheduled messages (observed)

msgkindctrltagsmsgnamecontext
omnetpp::cMessage0timer
omnetpp::cMessage1timer

Direct method calls (observed)

call tofunctioninfo
MessageDispatcherinet::MessageDispatcher::arrivedarrived

Incoming messages (observed)

gatemsgkindctrlsrcModuletags
socketInIndication4 (TcpStatusInd::TCP_I_ESTABLISHED)TcpConnectInfoTcpSocketInd
socketInIndication6 (TcpStatusInd::TCP_I_CLOSED)TcpCommandTcpSocketInd
socketInPacket1 (TcpStatusInd::TCP_I_DATA)TcpSocketInd

Outgoing messages (observed)

gatemsgkindctrldestModuletags
socketOutPacket4 (TcpCommandCode::TCP_C_SEND)TcpDispatchProtocolReq, SocketReq
socketOutRequest1 (TcpCommandCode::TCP_C_OPEN_ACTIVE)TcpOpenCommandTcpDispatchProtocolReq, SocketReq
socketOutRequest5 (TcpCommandCode::TCP_C_CLOSE)TcpCommandTcpDispatchProtocolReq, SocketReq

Packet operations (observed)

chunkTypepacketAction
peekData
GenericAppMsginsertAtBack

Shared Tagging operations (observed)

tagTypetagAction
DispatchProtocolReqaddTagIfAbsent
SocketIndfindTag
SocketReqaddTagIfAbsent

Region Tagging operations (observed)

tagTypetagAction
CreationTimeTagaddTag, getAllTags

Tagging operations (observed)

tagTypetagAction
inet::Ipv4InterfaceDatafindTag

Source code

//
// Client for a generic request-response style protocol over TCP.
// May be used as a rough model of HTTP or FTP users.
// Compatible with both IPv4 (~Ipv4) and IPv6 (~Ipv6).
//
// The model communicates with the server in sessions. During a session,
// the client opens a single TCP connection to the server, sends several
// requests (always waiting for the complete reply to arrive before
// sending a new request), and closes the connection.
//
// The server app should be ~TcpGenericServerApp; the model sends ~GenericAppMsg
// messages.
//
// Example settings:
//
// FTP:
// <pre>
//    numRequestsPerSession = exponential(3)
//    requestLength = 1B*int(truncnormal(20,5))
//    replyLength = 1B*int(exponential(1000000))
// </pre>
//
// Note that this module doesn't open separate TCP connections for commands
// and data transfer as the FTP protocol.
//
// HTTP:
// <pre>
//    numRequestsPerSession = 1 <i>(HTTP 1.0)</i>
//    numRequestsPerSession = exponential(5) <i>(HTTP 1.1, with keepalive)</i>
//    requestLength = 1B*int(truncnormal(350,20))
//    replyLength = 1B*int(exponential(2000))
// </pre>
//
// Note that since most web pages contain images and may contain frames,
// applets etc, possibly from various servers, and browsers usually download
// these items in parallel to the main HTML document, this module cannot
// serve as a realistic web client.
//
// Also, with HTTP 1.0 it is the server that closes the connection after
// sending the response, while in this model it is the client.
//
// @see ~TcpGenericServerApp, ~GenericAppMsg, ~TelnetApp
//
simple TcpBasicClientApp like IApp
{
    parameters:
        string localAddress = default(""); // may be left empty ("")
        int localPort = default(-1); // port number to listen on
        string connectAddress = default("");  // server address (may be symbolic)
        int connectPort = default(1000); // port number to connect to
        double startTime @unit(s) = default(1s); // time first session begins
        double stopTime @unit(s) = default(-1s);  // time of finishing sending, negative values mean forever
        volatile int numRequestsPerSession = default(1);  // number of requests sent per session
        volatile int requestLength @unit(B) = default(200B); // length of a request
        volatile int replyLength @unit(B) = default(1MiB); // length of a reply
        volatile double thinkTime @unit(s); // time gap between requests
        volatile double idleInterval @unit(s); // time gap between sessions
        volatile double reconnectInterval @unit(s) = default(30s);  // if connection breaks, waits this much before trying to reconnect
        int timeToLive = default(-1); // if not -1, set the TTL (IPv4) or Hop Limit (IPv6) field of sent packets to this value
        int dscp = default(-1); // if not -1, set the DSCP (IPv4/IPv6) field of sent packets to this value
        int tos = default(-1); // if not -1, set the Type Of Service (IPv4) / Traffic Class (IPv6) field of sent packets to this value
        @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 lifecycle stop operation
        @signal[packetSent](type=inet::Packet);
        @signal[packetReceived](type=inet::Packet);
        @signal[connect](type=long);  // 1 for open, -1 for close
        @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);
        @statistic[numActiveSessions](title="number of active sessions"; source=warmup(sum(connect)); record=max,timeavg,vector; interpolationmode=sample-hold; autoWarmupFilter=false);
        @statistic[numSessions](title="total number of sessions"; source="sum(connect+1)/2"; record=last);
    gates:
        input socketIn @labels(TcpCommand/up);
        output socketOut @labels(TcpCommand/down);
}

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