In the world of networking, ever wondered how our emails arrive to us without any missing text or attachments, our web pages load without any error and missing details, and files are downloaded intact? Behind the scenes are always interesting, be it a movie or technology.
Protocols are working on different layers to achieve these goals. TCP, also known as Transmission Control Protocol, is one such protocol. It might look complex but need not worry! In this article, you will get in-depth information about Transmission Control Protocol.
What is TCP?
TCP stands for Transmission Control Protocol which works on the Transport layer i.e., layer 4 of the OSI model and ensures the transmission of packets from source to destination.
Transmission Control Protocol is the most important protocol of the Internet Protocol Suite. It works by dividing data into small units called segments and making sure that they are delivered successfully from the source to the destination device, and then reassembling them at the destination.
TCP’s ability to establish a connection before data transmission begins is one of its advantages, and that is the reason it is called a connection-oriented protocol. To understand how the Transmission Control Protocol is reliable, let’s take an example–
Suppose Ankit is looking for CCNA training to start his career in the field of networking. While surfing he got to know about NETWORK KINGS.
He sends an HTTPS request using his browser to access the website of NK from NK servers and browse the vast catalogue available for networking courses. But what happens if in case Ankit’s request to access the webpage of NK is lost or the response of the server of NK is lost in transit? Webpage fails to load on Ankit’s web browser.
Most of the application layer protocol (HTTPS in our case) wants a way to ensure the delivery of the network across the network. Therefore, Transmission Control Protocol (TCP) plays an important role in it.
How does Transmission Control Protocol ensure data/segment delivery?
Now the question arises, how TCP is ensuring error-free data delivery?
It is achieved using a process called a 3-way handshake.
What is a 3-way handshake?
TCP provides a reliable connection between 2 network devices by using a process called TCP 3-way Handshake.
STEP 1: SYN
- Initially, the client sends a synchronization (SYN) message to the server when it wants to connect to it.
- SYN flag is set to 1. The message also contains Seq. no. (32-bit random number)
- Maximum segment size and window size are also set.
- If the window size is set to 10000 bits and the Maximum segment size is set to 100 bits, then a maximum of 100 data segments can be transmitted at a time (10000/100=100).
STEP 2: SYN-ACK
- On receiving the SYN packet from the client, the server acknowledges the request by sending an SYN-ACK message. It includes a unique acknowledgement number that confirms the receipt of the client’s SYN packet and the server’s SYN packet to initiate synchronization with the client.
- By setting the Acknowledgment (ACK) flag to 1, the server acknowledges the client’s request.
- ACK is the response to the segment sent by the client and SYN indicated the sequence number by which the server starts its segments.
- The server sets the SYN flag as 1 which confirms that the server also wants to establish a connection with the client.
- Seq. no used by the server is different from that of a client.
- If the Client’s SYN sequence no. is X, then the servers ACK sequence no. will be X+1
STEP 3: ACK
- The client sends back ACK to the server when it receives the SYN from the server which confirms the delivery of the server’s SYN-ACK packet.
- If the server’s SYN sequence number is Y, then the Client’s ACK sequence number will be Y+1
- After receiving the ACK from the client, the connection is established and the process of data transmission can start between the client and server.
That is why TCP is known as Connection-Oriented Protocol.
The 3-way handshake plays an important role in a reliable connection. It ensures that the client and server are ready to send and receive data by predetermining sequence number, and window size and confirming each other availability.
NOTE: To understand the process of TCP error-free data delivery, let’s continue with our previous example.
If in case Ankit’s request to access the webpage of NK is lost or the response of the server of NK is lost in transit? Webpage fails to load on Ankit’s web browser. To ensure that the data/segments do not get lost, TCP’s 3-way Handshake plays a crucial part.
Nk’s server sends out the segments to the client (Ankit’s PC) with 3 segments (1,2,3).
Since we have understood that for every SYN there is an ACK. Also, the Client’s ACK sequence number is Server’s SYN+1 and Server’s ACK Sequence number is Client’s SYN+1
Let us suppose that segment 2 is lost. The client will not be sending any acknowledgement to the server for segment 2. Also, the client realizes that there is a missing Segment no i.e., 2. The server will again send out segment number 2 to the client and if for some reason, the server does not send segment 2, then the client can request segment 2 again. At the client’s end, the segments are assembled to form the complete data with the help of sequence numbers.
In this way, Ankit can easily search for the networking courses available on NK’s website hassle-free and start his career as a skilled network engineer.
What are the advantages of TCP?
From the above example, we can observe the following advantages of TCP: –
- Reliability – Since it is a connection-oriented protocol, it is more reliable for sending E-mails, web browsing, File sharing, Remote access (used by SSH), etc. Data are not corrupted when we are using TCP as our Transport layer protocol.
- Flow control – TCP uses a sliding window mechanism for flow control. It can adjust the rate of data transmission according to the receiver’s ability to process the data which also leads to reducing the risk of segment loss due to congestion.
- Error detection – It provides error detection by using checksums
What are the disadvantages of TCP?
The disadvantages of TCP are as follows-
- Latency – TCP is a comparatively slower protocol than UDP which comes at the cost of latency. Acknowledgement packets and retransmission of lost packets can cause delays.
- Overhead – It has a relatively higher overhead than UDP. Due to the error-checking mechanism, additional control information leads to higher resource consumption and overhead.
NOTE: Due to low latency and overhead, it is not suitable for applications with low latency, like real-time gaming, VOIP services, and live streaming.
For reliable delivery of DATA, TCP can be trusted. It is a connection-oriented protocol that uses a process called a 3-way handshake to ensure the delivery of data between network devices. Besides some disadvantages, TCP has many advantages and is a widely used protocol.