TCP Connection Establishment (26.5.2)
In some cultures, when two persons meet, they often greet each other by shaking hands. Both parties understand the act of shaking hands as a signal for a friendly greeting. Connections on the network are similar. In TCP connections, the host client establishes the connection with the server using the three-way handshake process.
The steps for the TCP connection establishment process are shown in Figure 26-20 and described here:
Figure 26-20 Steps in the TCP Connection Establishment Process
Step 1. SYN—The initiating client requests a client-to-server communication session with the server.
Step 2. ACK and SYN—The server acknowledges the client-to-server communication session and requests a server-to-client communication session.
Step 3. ACK—The initiating client acknowledges the server-to-client communication session.
The three-way handshake validates that the destination host is available to communicate. In this example, host A has validated that host B is available.
To close a connection, the Finish (FIN) control flag must be set in the segment header. To end each one-way TCP session, a two-way handshake, consisting of a FIN segment and an Acknowledgment (ACK) segment, is used. Therefore, to terminate a single conversation supported by TCP, four exchanges are needed to end both sessions. Either the client or the server can initiate the termination.
Note
For simplicity, the terms client and server are used in the following steps, but any two hosts that have an open session can initiate the termination process.
The steps for the TCP session termination process are shown in Figure 26-21.
Figure 26-21 Steps in the TCP Session Termination Process
Step 1. FIN—When the client has no more data to send in the stream, it sends a segment with the FIN flag set.
Step 2. ACK—The server sends an ACK to acknowledge the receipt of the FIN to terminate the session from client to server.
Step 3. FIN—The server sends a FIN to the client to terminate the server-to-client session.
Step 4. ACK—The client responds with an ACK to acknowledge the FIN from the server.
When all segments have been acknowledged, the session is closed.
TCP Three-Way Handshake Analysis (26.5.4)
Hosts maintain state, track each data segment within a session, and exchange information about what data is received using the information in the TCP header. TCP is a full-duplex protocol, where each connection represents two one-way communication sessions. To establish the connection, the hosts perform a three-way handshake. As shown in Figure 26-22, control bits in the TCP header indicate the progress and status of the connection.
Figure 26-22 Control Bits Field
These are the functions of the three-way handshake:
• It establishes that the destination device is present on the network.
• It verifies that the destination device has an active service and is accepting requests on the destination port number that the initiating client intends to use.
• It informs the destination device that the source client intends to establish a communication session on that port number.
After the communication is completed, the sessions are closed and the connection is terminated. The connection and session mechanisms enable TCP’s reliability function.
The 6 bits in the Control Bits field of the TCP segment header are also known as flags. A flag is a bit that is set to either on or off. The six control bit flags are as follows:
- URG—Urgent pointer field significant
- ACK—Acknowledgment flag used in connection establishment and session termination
- PSH—Push function
- RST—Reset the connection when an error or timeout occurs
- SYN—Synchronize sequence numbers used in connection establishment
- FIN—No more data from sender, and used in session termination
Search the Internet to learn more about the PSH and URG flags.
Video—TCP Three-Way Handshake (26.5.5)
Refer to the online course to view this video.
Check Your Understanding—TCP Communication Process (26.5.6)
Refer to the online course to complete this activity.