TCP-IP is a readable, exhaustive look at the core protocols that make the Internet work. It is a valuable resource for newcomers to the field and an essential reference for IT professionals.
TCP is an innovative communications protocol that ensures data packages reach their destination. It breaks a message into smaller packets, sends them over the Internet, and then puts them back together in the correct order at the end destination.
How TCP Works
What is TCP-IP, and how does it operate? Over the Internet, data is sent between devices using the TCP communications protocol. It is a component of the Internet Protocol Suite comprising four to five layers and explains how apps and devices exchange data packets over a network.
TCP connects two networks, establishing an active connection until the complete data transfer. Then it chops up the message into smaller pieces, known as packets. These packets are then dispatched on various routes to their destination computers. Once the packets reach their destinations, TCP combines them to form the original message. TCP also checks for errors and retransmits missing segments, which is why it’s reliable.
This process is a lot like sending a puzzle through the mail. The pieces could be sent in different postal routes and may arrive at the recipient out of order. TCP is the assembler that puts the pieces back together in the correct order and acknowledges when it receives each piece so the sender knows it has been received. TCP also uses sequence numbers and receives windows to track how long it’s been since a segment was last acknowledged. It allows TCP to ensure that all packets are delivered before the connection is closed. It also manages congestion control to avoid sending too many packets at once.
TCP separates application data that comes in the form of streams of bytes into chunks of information called segments. These are then passed down to the IP layer, where they are encapsulated into IP packets for transmission across the Internet. Each segment is individually numbered so TCP can recognize and resend any lost during transfers.
TCP also adds extra information to each segment, known as the header. This extra information supports the TCP protocol-specific services, such as segmentation, windowing, and flow control.
The first field in the TCP header is the source port, which identifies the sending device. The next is the destination port, which identifies where the segment is being sent to. TCP uses the combination of these two fields to establish connections.
When the connection is established, TCP segments the stream of bytes from the sending application into easy-to-handle chunks that can fit into an IP packet sends these over the network, and reassembles them at the receiving end. This reassembly ensures that each sequence of bytes is received in the correct order and that any lost packets are resent to avoid gaps in the data.
TCP also includes a window field in each segment that advertises the amount of data it can accept from the receiver. If the receiver can’t accept more data, TCP will set this window to zero, causing the stream of bytes to pause until the problem is resolved.
TCP’s Flow Control
TCP uses a variety of mechanisms to achieve high performance and avoid congestion collapse (a gridlock situation where network performance is severely degraded). One mechanism is known as flow control. P pacing data transmission ensures data flows do not exceed a network’s capacity. It is accomplished by using ACKs to inform the sender that its data has been received and acknowledged at the receiving end.
TCP sends data in segments. Chunks are reassembled at the receiving end to form an entire message. Each segment is transmitted at a rate that keeps pace with the receiver’s buffer space and window size. During the connection setup process, the client and server communicate the maximum amount of data they are willing to receive or send simultaneously. It is called the “send window” and the “receive window” respectively.
The receiver also advertises the maximum amount of data it can accept at any given time, called its “receive window.” Once the receiver’s receive buffer reaches capacity, it will signal this to the sender by dropping some of its data. The sender then adjusts its data transfer rate accordingly by increasing its window size by 1 byte every time it sends a packet.
TCP sets up connections via a three-way handshake process, in which the first computer sends an SYN packet to another computer. The second computer then sends an SYN-ACK packet to the first, acknowledging that it has received the SYN packet.
TCP’s Error Checking
TCP’s error-checking guarantees that the data you send will reach its destination. It is a critical feature for applications that require reliability, such as web browsing, email, file transfer, and online games. If there is an error in the data transmission, TCP will retransmit the packets to guarantee their delivery to the intended recipient.
This process also allows the sending network to determine how much data it can send in a single session, ensuring that the amount of data does not overwhelm the receiving network’s ability to process it. It is a significant benefit over UDP, which does not check for data errors and discards them.
TCP also uses a mechanism known as sliding window flow control to ensure that the amount of data in transit is controlled, unlike UDP, which does not keep track of the number of unacknowledged packets in the system. Sliding window flow control allows the receiver to acknowledge discontinuous data blocks rather than each byte received.