In the expansive world of computer networking lies the Transmission Control Protocol which ensures there is the reliable and orderly transfer of data between devices over networks. TCP was first introduced in the 1970s. It is a core protocol of the Internet Protocol Suite (TCP/IP network) which provides a connection-oriented and error-checking data delivery mechanism to guarantee that the data is received correctly.
Without TCP some of the data could be missing or out of order. A good example is viewing a webpage on the internet. Without TCP, some images could be missing or text inverted. The placement of the elements would also be off.
In this article, we will dive deep and try to understand how the TCP works by exploring its features.
Let's get started.
How TCP works
As mentioned earlier, TCP is a connection-oriented protocol which means that a session has to be established first between a client and a server. This is achieved by using a three-way handshake where a series of messages are sent back and forth between the two endpoints. The Client sends a message called a SYN to initiate a connection. The server then responds with an acknowledgment message (SYN-ACK) and finally, the client sends the final message (ACK) to complete the connection. Through these messages, the client and the server agree on the initial parameters and synchronize their sequence parameters thus establishing a virtual
pipe for data transmission.
After a connection is established, the TCP has to ensure that the data is delivered to the destination. Not only arriving but also the data has to be correct and in the right order. To achieve this, various techniques are employed.
- Segmentation: When data is transferred, the TCP/IP model will break down the data into smaller units known as segments. Each segment holds a sequence number which makes it easy to reassemble back into the original data when they arrive at the destination.
- Acknowledgment: Once the segments arrive at the destination, the receiver sends and acknowledgment (ACK) to the sender to confirm successful reception. If the ACK is not received within a specified amount of time, the sender assumes that the segment was lost or damaged and retransmits it again.
- Retransmission: Retransmission occurs in cases of lost or damaged segments. This is done to ensure the data received is reliable. It works on a timeout-based mechanism.
- Sliding Window: When the data is being transferred, segmentation is done according to the MTU (Maximum Transmission Unit) of the underlying network technology. The bandwidth is also taken into account during segmentation. If the data being transferred is larger than the MTU of the network, it is broken down into smaller segments that have to fit within the MTU sizes of the receiver. The sliding window helps with flow control of the rate at which the sender can transfer the data. This ensures reliable delivery.
TCP in Action
Consider a scenario where a user requests a web page from a server on the internet. There server gets the request, processes it, and generates the corresponding HTML. The server then sends the HTML page using the HTTP Protocol which in turn requests the TCP layer to facilitate reliable delivery of the HTML file. The TCP then initiates a connection with the User. After the connection is established, the data is broken down into segments which are then handed over to the Internet Protocol (IP) layer.
The IP is responsible for the addresses, routing, and delivery of the segments to the destination. These segments can use different routes depending on the network congestion but the destination is always the same. The IP then hands over the segments to the User's TCP layer. With every segment received, the user's TCP acknowledges the reception. When all the segments are received by the User's system, The TCP layer notifies the application layer to process the HTML file rendering it as a web page for the user.
Advantages of Using TCP
- Guaranteed Delivery: With TCP, the data arrives at the destination accurately and uncorrupted.
- Orderly Transmission: Applications that require sequential processing get data in the same order as it was sent.
- Error detection and Recovery: With the checksums employed by TCP (acknowledgment mechanism), data integrity is assured.
- Widely Supported: TCP is universal which makes it ideal for applications and devices across different platforms.
- Flow control using the sliding window.
- It is an open protocol
The TCP/IP is built into most devices to facilitate device communication either internally or via the internet. Learn how to Troubleshoot the TCP/IP on Windows.
As the core of reliable data transmission, TCP plays a major role in the vast world of computer networking. This is made possible by some of its features such as connection establishment, Guaranteed data delivery, and its adaptation to network conditions. All these features and more ensure a seamless transfer of information across the internet. This article has broken down how The TCP works and if you found it helpful, consider subscribing to Geekbits and sharing the article with others.
Thank you for reading : )