Transmission Control Protocol (TCP) in Computer Networking

TCP is a standard protocol to define the ways for creating and managing the connections between devices in a network for the exchange of packets of data. It maintains the connection to ensure that the data is exchanged between the devices. 

This protocol also solves several challenges related to packet-based messaging. These challenges can be out-of-order packets, duplicate packets, corrupted packets, etc. TCP works with the Internet Protocol (IP).

TCP Three-Way Handshake

1. Synchronize Sequence Number (SYN)

This is the first step where a segment with SYN is sent to the server when there is a connection to be formed between the client and the server. 

2. SYN and ACK

Here, the server responds to the connection request with an Acknowledgement (ACK) to show that it has received the request of the client. It also tells about the SYN number with which it is likely to start the connection. 

3. ACK

In the last step, the client responds to the server with its acknowledgment. Then the connection is formed for data transmission.  

TCP traffic begins with a three-way handshake. In this TCP handshake process, a client needs to initiate the conversation by requesting a communication session with the Server:

3 way Handshake Diagram

  • Step 1In the first step, the client establishes a connection with a server. It sends a segment with SYN and informs the server about the client should start communication, and with what should be its sequence number.
  • Step 2In this step server responds to the client request with SYN-ACK signal set. ACK helps you to signify the response of segment that is received and SYN signifies what sequence number it should able to start with the segments.
  • Step 3In this final step, the client acknowledges the response of the Server, and they both create a stable connection will begin the actual data transfer process.

Real-world Example

Here is a simple example of the three-way handshake process that is consists of three steps:

  • Host X begins the connection by sending the TCP SYN packet to its host destination. The packets contain a random sequence number (For example, 4321) that indicates the beginning of the sequence numbers for data that the Host X should transmit.
  • After that, the Server will receive the packet, and it responds with its sequence number. It’s response also includes the acknowledgment number, that is Host X’s sequence number incremented with 1 (Here, it is 4322).
  • Host X responds to the Server by sending the acknowledgment number that is mostly server’s sequence number that is incremented by 1.

After the data transmission process is over, TCP automatically terminates the connection between two separate endpoints.

TCP Session Termination 

Any device establishes a connection before proceeding with the termination. TCP requires 3-way handshake to establish a connection between the client and server before sending the data. Similarly, to terminate or stop the data transmission, it requires a 4-way handshake. The segments required for TCP termination are similar to the segments to build a TCP connection (ACK and SYN) except the FIN segment. The FIN segment specifies a termination request sent by one device to the other.

The client is the data transmitter and the server is a receiver in a data transmission process between the sender and receiver. Consider the below TCP termination diagram that shows the exchange of segments between the client and server.

The communication between the two parties in a network can end in two ways:

1.Graceful

Here, both parties choose to terminate the connection.

2.Abrupt

In this, one party terminates the connection from both sides.  

Let’s discuss the TCP termination process with the help of six steps that includes the sent requests and the waiting states. The steps are as follows: 

Step 1: FIN

FIN refers to the termination request sent by the client to the server. The first FIN termination request is sent by the client to the server. It depicts the start of the termination process between the client and server.

Step 2: FIN_ACK_WAIT

The client waits for the ACK of the FIN termination request from the server. It is a waiting state for the client.

Step 3: ACK

The server sends the ACK (Acknowledgement) segment when it receives the FIN termination request. It depicts that the server is ready to close and terminate the connection.

Step 4: FIN _WAIT_2

The client waits for the FIN segment from the server. It is a type of approved signal sent by the server that shows that the server is ready to terminate the connection.

Step 5: FIN

The FIN segment is now sent by the server to the client. It is a confirmation signal that the server sends to the client. It depicts the successful approval for the termination.

Step 6: ACK

The client now sends the ACK (Acknowledgement) segment to the server that it has received the FIN signal, which is a signal from the server to terminate the connection. As soon as the server receives the ACK segment, it terminates the connection.

The role of TCP flags is to signal the state of the connection or to inform the other party about acknowledgment, termination, and resetting the connection. 

Here are some of the flags used in TCP:

  • SYN: To tell the other party in a connection about the synchronizing sequence number with which the connection can be formed. 

  • ACK: To acknowledge the connection request from the other party.

  • FIN: To request for finishing or terminating the connection when the data has been transmitted.

  • RST: This flag is used to reset the connection if the parties find some error or issue in the formed connection. 

  • PSH: PSH (Push) flag tells the receiver to send the data as it buffers, instead of waiting for all the data to be buffered first and then sending it. 

  • URG: It signals the other party to send the processed packets of data immediately or with urgency, even if some more packets of data are to be processed.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *