File: Applications/TCPApp/TCPSessionApp.ned
C++ definition: click here
Single-connection TCP application: it opens a connection, sends the given number of bytes, and closes. Sending may be one-off, or may be controlled by a "script" which is a series of (time, number of bytes) pairs. May act either as client or as server, and works with TCPVirtualBytesSendQueue/RcvQueue as sendQueue/receiveQueue setting for TCP. Compatible with both IPv4 and IPv6.
Opening the connection
Regarding the type of opening the connection, the application may be either a client or a server. When active=false, the application will listen on the given local port, and wait for an incoming connection. When active=true, the application will bind to given local address:port, and connect to the connectAddress:connectPort. To use an ephemeral port as local port, set the port parameter to -1.
Even when in server mode (active=false), the application will only serve one incoming connection. Further connect attempts will be refused by TCP (it will send RST) for lack of LISTENing connections.
The time of opening the connection is in the tOpen parameter.
Sending data
Regardless of the type of OPEN, the application can be made to send data. One way of specifying sending is via the tSend, sendBytes parameters, the other way is sendScript. With the former, sendBytes bytes will be sent at tSend. With sendScript, the format is "<time> <numBytes>;<time> <numBytes>;..."
Closing the connection
The application will issue a TCP CLOSE at time tClose. If tClose=-1, no CLOSE will be issued.
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.
Name | Type | Description |
---|---|---|
address | string | |
port | numeric const | |
active | bool | |
connectAddress | string | |
connectPort | numeric const | |
tOpen | numeric const | |
tSend | numeric const | |
sendBytes | numeric const | |
sendScript | string | |
tClose | numeric const |
Name | Direction | Description |
---|---|---|
tcpIn | input | |
tcpOut | output |
simple TCPSessionApp parameters: address: string, port: numeric const, active: bool, connectAddress: string, connectPort: numeric const, tOpen: numeric const, tSend: numeric const, sendBytes: numeric const, sendScript: string, tClose: numeric const; gates: in: tcpIn; out: tcpOut; endsimple