TCP Connection Management
TCP Connection Management
What is TCP?
Layers of TCP
What is TCP?
TCP is one of the most common protocols that ensure end-to-end delivery. It
guarantees the security and integrity of the data being transmitted. It always
establishes a secure connection between the sender and receiver. The transmitter
is the server, and the receiver is known as the client. We can also say that the
data transmission occurs between the server and client. Hence, TCP is used in
most of the high-level protocols, such as FTP (File Transfer
Protocol), HTTP (Hyper Text Transfer Protocol), and SMTP (Simple Mai
Transfer Protocol).
Layers of TCP
The data is then divided into packets, assigned to the address, transmitted,
routed, and received at the destination. The transmission process comprises four
layers, application layer, transport layer, internet layer, and data link layer.
The application layer performs the function similar to the top three layers
(application, presentation, and session) of the OSI model and control user-
interface specifications. The user interacts with the application layer of the TCP
model, such as messaging and email systems. The transport layer provides a
reliable and error-free data connection. It divides the data received from the
application layer into packets, which helps in creating ordered sequence.
The internet layer controls the routing of packet and ensures the delivery of a
packet at the destination. The data link layer performs the function similar to the
bottom two layers (data link and physical) of the OSI model. It is responsible
for transmitting the data between the applications or devices in the network.
Handshake refers to the process to establish connection between the client and
server. Handshake is simply defined as the process to establish a
communication link. To transmit a packet, TCP needs a three way handshake
before it starts sending data. The reliable communication in TCP is termed
as PAR (Positive Acknowledgement Re-transmission). When a sender sends the
data to the receiver, it requires a positive acknowledgement from the receiver
confirming the arrival of data. If the acknowledgement has not reached the
sender, it needs to resend that data. The positive acknowledgement from the
receiver establishes a successful connection.
Here, the server is the server and client is the receiver. The above diagram
shows 3 steps for successful connection. A 3-way handshake is commonly
known as SYN-SYN-ACK and requires both the client and server response to
exchange the data. SYN means synchronize Sequence Number and ACK
means acknowledgment. Each step is a type of handshake between the sender
and the receiver.
Step 1: SYN
Step 2: SYN-ACK
Step 3: ACK
After these three steps, the client and server are ready for the data
communication process. TCP connection and termination are full-duplex, which
means that the data can travel in both the directions simultaneously.
TCP Termination (A 4-way handshake)
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.
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.
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.