Administrator Handbook Table of contents version française LinkedIn social network LinkedIn social network LinkedIn social network LinkedIn social network Share on social media

Establishment of a TCP connection, state diagram

Short introduction to TCP protocol

The TCP protocol is used by a large majority of client/server applications like the millions of Internet Web servers.

TCP stands for Transmission Control Protocol and works on the transport network IP (Internet Protocol).

TCP is used to exchange data reliably through mechanisms of sequence and acknowledgment, error detection, error recovery. The performance and memory management of reception are controlled by a system of workflow management.

TCP is a connection-oriented protocol, a formal relationship (handshake) is established before exchanging data. The system that initiates the connection is considered as the client in the TCP terminology while the system that accepts this connection is considered as the server.

Two systems can establish connections to one another and simultaneously, in this case they are both server and client. The client and server exchange units of information called "TCP segments, the segments being composed of a header and a data area.

TCP is described in RFC 793.

Principle of establishing a TCP connection, the state diagram

Here are the steps of connecting and libration of a TCP connection.

TCP state transition

The client application opens a connection to the server by sending a TCP segment which only the header is present (no data). This header contains a flag SYN stands for "Synchronize" and the TCP port number the server (application). The client is in SYN_SENT state (SYN sent).

The server (application) is listening (listen) and on receipt of the SYN from the client, it changes of state and responds with a SYN and ACK flag. The server is then able SYN_RCVD (SYN received).

The client receives the server's TCP segment with SYN ACK indicators and move in status ESTABLISHED. He also sent a response ACK to the server that also passes in status ESTABLISHED.
This exchange in three phases (three-way handshake) complete the establishment of the TCP connection can now be used to exchange data between the client and server.

The client side of the connection is responsible for the connection performs an active connection (active open) while the server performs a passive connection (passive open).

In the event that a connection request arrives on the server and that no application is listening on the requested port, a segment with flag RST (reset) is sent to the client by the server, the connection attempt is immediately terminated.

Principle termination of a TCP connection state diagram

The termination of a TCP connection requires four exchanges of TCP segments.

As a TCP connection is bidirectional (full duplex) , connection termination process should be made in both directions of the communication. The client as the server can send a segment with FIN flag, this mean an end to sending data. Receiving a segment with FIN indicates that the other end will not send more data. The term used then is half closed, the connection is half closed.

Typically, the client generates the transmission segment with a FIN flag, he made a closing force (active close), the server receives the segment realizes a passive close. The server acknowledge the FIN with ACK, informs the application for the release of this connection and when done then sends a FIN segment to the customer which in turn, acknowledge it with an ACK flag.

All segments exchanged between client and server are numbered sequentially. The sequence number is an integer of 32 bits. Each side of the connection initiates and maintains the sequence of segments sent.

The header segment always contains two fields, one for the sequence number of the sent segment and one for the sequence number of the acknowledged segment . The sequence number of the acknowledged segment is actually the number of the next segment expected. In other words the acquittal as "waiting segment number 10 on your part" means that the 9 was received correctly.

The tests performed LoriotPro within its various modules to check TCP connection and measure TCP response time are based mainly on the time between the request from the client (initial segment SIN) and the server acknowledgement by SIN/ACK.

LoriotPro incorporates a system of interrogation (polling) and measuring response time to establish a TCP connection. On each host in the directory one or more polling at 1 or more TCP implementation (TCP) may be added. Consult the documentation for auditing Advanced TCP implementation. This module allows you to send an event if non-response and achieves a grahique response times for the last 100 measurements.

It is also possible to have graphical trend of TCP connection with module RRD Collector and the option of collecting by LUA script. A measurement module by LUA is available and can be used within the module RRD Collector to display grahique trend in response times of TCP connections.