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
Table of Contents
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.
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:
Step 1: In 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 2: In 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 3: In 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.
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:
Here, both parties choose to terminate the connection.
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 thetermination requestsent 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.
You are most likely already familiar with access points and wireless cards, but so many more tools and “gadgets” are available today for securing, attacking, monitoring,auditing, and accessing wireless networks. In this chapter, you’ll learn some of the productofferings on the market today as well as some of the more exotic tools that have securityimplications…
TCP/IP Model helps you to determine how a specific computer should be connected to the internet and how data should be transmitted between them. It helps you to create a virtual network when multiple computer networks are connected together. The purpose of TCP/IP model is to allow communication over large distances. Transmission Control Protocol/Internet Protocol is…
An IP address is a unique address that identifies a device on the internet or a local network. IP stands for “Internet Protocol,” which is the set of rules governing the format of data sent via the internet or local network. In essence, IP addresses are the identifier that allows information to be sent between…
Usually, the Network Port concept is challenging to understand. In networking, it is a communication endpoint used to connect an external device to the computer. When there is a requirement to set up remote access for your IP Cameras, the network port comes into the picture. Routers are dependent on ports to route data to…
ICMP is a network layer protocol used in the devices within a network to find whether the data transmission initiated by a device has reached the destination without fail. The key role of Internet Control Message Protocol is to report the errors in the communication in a network. Mostly, it is used in routers, hosts,…
In the modern world, two devices are considered to be in a network if a process on one of them can exchange data with a process on the other. Nodes (a group of devices) or computers can connect to one another through networks. A network is made up of several computers, servers, and networking equipment…