Model Interfaces: TCP

The following sections discuss the topics necessary for interfacing with the TCP model.

Packet Formats

The following packet format is used to represent a TCP segment:

Format Description
tcp_seg_v2 Represents a TCP segment. Used by TCP to encapsulate application data for transmission to the remote end of the connection. It contains fields for source/destination port identification, status flags (e.g., SYN, FIN) and several other TCP-specific information fields

Each TCP segment contains a TCP header, options and data field. This is defined by the following TCP packet format (tcp_seg_v2). In the packet format editor, it looks like this:

Figure 562: TCP Packet Format

TCP packet format

Refer to the descriptions provided for each packet field for more details about their importance.

ICI Formats

The following table lists the interface control information (ICI) formats used in the TCP model suite:

Format Description
ip_encap_ind_v4 The lower level (network layer) protocols forward packets to TCP accompanied by this ICI. It contains information about the source network and source node of the arriving packet.
ip_encap_req_v4 The TCP processes use this format to specify the destination network and node information to the Network Layer. The ICI always accompanies (installed with) a packet transfer.
tcp_command_v3 The Application Layer processes use this ICI format to identify the target TCP connection, so that the commands they issue can be dispatched to the correct connection process. The same ICI should be used for all interactions with a particular connection for the duration of the connection. ICI reuse simplifies the TCP Interface, since the connection parameters can be preserved when the connection is first opened.
tcp_status_ind The TCP connection process uses this ICI to notify the Application Layer processes of important events. The connection creates this ICI, but does not destroy it; the application is responsible for destroying it.
tcp_open_ind When an application opens a passive session with the server, the TCP connection process uses this ICI to notify the application that the passive session has been bound. The application then sends TCP a request to create a new passive connection.

TCP Commands and Indications

The interface between TCP and the application is based on commands issued by the application to TCP and indications returned to the application from TCP. The commands and indications are identified by symbolic constants defined in the C header file tcp_api_v3.h (located in the <models>/std/include directory); any applications that interact with TCP should refer to this file to obtain these definitions.

The following table lists the various commands used in the TCP model suite:

Command Description
OPEN The application issues an OPEN command to the TCP module to open a new connection. There are two types of OPEN commands: OPEN_ACTIVE, which causes a segment to be sent to the remote socket, requesting that the connection be established; and OPEN_PASSIVE, which causes the local socket to wait for an establishment request (SYN) segment. The command is issued by forcing a remote interrupt at the TCP module, with the code argument set to either TCPC_COMMAND_OPEN_ACTIVE or TCPC_COMMAND_OPEN_PASSIVE. The interrupt should typically be forced rather than scheduled so that the “return value” in the command ICI can be examined to determine whether the command was successful.
SEND The application issues a SEND command to the TCP module to send a packet to the other end of an established connection. This is performed by sending the data packet to the TCP module. If the connection was opened with an OPEN_PASSIVE command, and the address or port information for the remote socket has not yet been specified, the SEND command (which must, in this case, be accompanied by the missing remote socket information) also acts as an OPEN_ACTIVE command.
RECEIVE The application issues a RECEIVE command to request data. The application sends the TCP module a remote interrupt with the code argument set to TCPC_COMMAND_RECEIVE. The connection process will then forward the requested number of packets as soon as they become available. The RECEIVE command takes one argument, the number of packets requested.
CLOSE The application issues a CLOSE command to the TCP module to indicate that it has finished sending data and is ready for the connection to close. This is performed by sending a remote interrupt with the code argument set to TCPC_COMMAND_CLOSE. The local socket (tcp_conn_v3 process) begins the connection teardown sequence when this command is issued.
ABORT The application issues an ABORT command to abruptly drop the connection without carrying out the normal teardown sequence. The application sends a remote interrupt with the code argument set to TCPC_COMMAND_ABORT.

Indications take the form of remote interrupts or stream interrupts issued from the TCP connection process to the application. All indications are accompanied by an ICI of type tcp_status_ind_v3, described earlier.

TCP Indication Description
SEG_FWD The connection process forwards packets to the applications when data requested by the application becomes available, or when unrequested urgent data is received.
ESTAB The connection process uses a remote interrupt to indicate connection establishment to the application. The “status” attribute in the accompanying ICI is set to TCPC_IND_ESTAB.
FIN_RECEIVED The connection process sends a FIN_RECEIVED indication to the Application Layer to initiate the closing of the connection.
CLOSED The connection process forwards a CLOSED indication to the Application Layer at the end of the standard teardown sequence. This relies on a remote interrupt with the “status” attribute in the accompanying ICI set to TCPC_IND_CLOSED.
ABORTED The connection process an ABORTED indication to the application to indicate an unexpected connection teardown. The application is notified through a remote interrupt with the status attribute in the accompanying ICI set to TCPC_IND_ABORTED.

Application Layer Interfacing

The following figure shows the relevant portions of a typical Application Layer process model which interfaces with the TCP model.

Figure 563: Typical Application Layer Process Model

Typical Application Layer process model

You can use one of two methods to create the application–to–TCP Interface: either directly, by using remote interrupts; or by using the TCP API. Unless you are accustomed to creating this interface directly, you will probably find the API method simpler.

  • Issuing Commands Using Remote Interrupts: commands take the form of remote interrupts or stream interrupts issued by the application to the TCP manager process, which is the root process of the TCP module. All commands must be accompanied by an ICI of type tcp_command_v3, described earlier.
  • Issuing Commands Using the TCP API: The TCP API is a set of functions that hide many of the details involved in issuing commands. To use these functions, declare the external source file tcp_api.ex.c; then include tcp_api.h in the header block of the application-layer process:

TCP API include in the application-layer process header block

Each application module must first register itself with TCP using the function tcp_app_register(); this returns a handle that the application uses as a parameter in subsequent function calls. Dynamic processes within a single Application Layer module can make copies of this handle to use in function calls instead of re-registering.

For more information in this section, see:

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com