Simple Module TCPBasicClientApp

File: Applications/TCPApp/TCPBasicClientApp.ned

C++ definition: click here

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 and 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 TCPGenericSrvApp; the model sends GenericAppMsg messages.

Example settings:

FTP:

   numRequestsPerSession = exponential(3)
   requestLength = truncnormal(20,5)
   replyLength = 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 = truncnormal(350,20)
   replyLength = 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: TCPGenericSrvApp, GenericAppMsg, TelnetApp

Usage diagram:

The following diagram shows usage relationships between modules, networks and channels. Unresolved module (and channel) types are missing from the diagram. Click here to see the full picture.

Parameters:

Name Type Description
address string

may be left empty ("")

port numeric const

port number to listen on

connectAddress string

server address (may be symbolic)

connectPort numeric const

port number to connect to

startTime numeric

time first session begins

numRequestsPerSession numeric

number of requests sent per session

requestLength numeric

length of a request (bytes)

replyLength numeric

length of a reply (bytes)

thinkTime numeric

time gap between requests

idleInterval numeric

time gap between sessions

reconnectInterval numeric

if connection breaks, waits this much before trying to reconnect

Gates:

Name Direction Description
tcpIn input
tcpOut output

Source code:

simple TCPBasicClientApp
    parameters:
        address: string, // may be left empty ("")
        port: numeric const, // port number to listen on
        connectAddress: string,  // server address (may be symbolic)
        connectPort: numeric const, // port number to connect to
        startTime: numeric, // time first session begins
        numRequestsPerSession: numeric,  // number of requests sent per session
        requestLength: numeric, // length of a request (bytes)
        replyLength: numeric, // length of a reply (bytes)
        thinkTime: numeric, // time gap between requests
        idleInterval: numeric, // time gap between sessions
        reconnectInterval: numeric;  // if connection breaks, waits this much before trying to reconnect
    gates:
        in: tcpIn;
        out: tcpOut;
endsimple