TCP: Putting the Missing Bytes Back in Order
TCP, the Transmission Control Protocol, gives programs a reliable, ordered stream of data across a network. It tracks which bytes have arrived, puts received data in order and sends missing data again when needed. A byte is a small unit of digital information.
The program using TCP gets a stream: a sequence of bytes rather than the separate packets, small units of network data, that carried them. The program can then work with the received data without sorting out each out-of-order arrival itself.
TCP or UDP: Which One Carries Your Data?
A gap in the middle holds up the stream
Imagine a program sends a stretch of data in three pieces. The first and third reach the receiving computer, but the middle piece goes missing.
TCP's sequence numbers identify positions in the byte stream. They number the data bytes, rather than merely labeling whole packets “one,” “two” and “three.” The receiver can therefore recognize the gap even though some later data has arrived.
An acknowledgment reports received-byte progress. The sender uses that feedback and timers to determine when data needs to be sent again. Once the missing bytes arrive, TCP can provide the application with the continuing stream in the proper order.
The TCP specification describes this delivery model. TCP carries its control information and data in units called segments, which travel inside Internet Protocol packets. Internet Protocol, or IP, handles their movement through the network.
A connection doesn't reserve one physical route for those packets. Nor can TCP keep a failed network alive indefinitely. If communication cannot recover, the connection can time out and fail. Reliability includes detecting failure, not promising that every transfer must finish.
Sending faster isn't always progress
The two sides establish a connection through an opening exchange, the three-way handshake. They then keep information about that exchange as it proceeds.
The receiver advertises how much data it can accept, through a receive window. That helps keep a sender from overwhelming the receiving side. TCP also has congestion-control requirements that govern sending in response to network conditions. An overloaded receiver and a crowded network are different problems.
The stream itself doesn't label where one application message ends and another begins. The application needs its own format or rules for that. TCP can deliver the bytes of a file-transfer conversation without knowing which bytes are a filename or what counts as a completed file.
- Keep work, guest and smart-home gear apart with up to 32 VLANs on one small switch.
- Copy any port's traffic to your laptop with port mirroring and see what is on the wire.
- Set it up from a web page instead of learning a command line.
Received by TCP isn't the same as saved by the app
A TCP acknowledgment doesn't prove that the receiving application saved the data to disk, finished processing it or approved a requested action. Those are later jobs. A file-transfer program may need its own confirmation that the file was successfully stored.
Privacy is another separate job. Transport Layer Security, or TLS, can protect content carried over a reliable stream using encryption and checks against unauthorized changes. TCP alone doesn't conceal the message.
The web also uses other transports. HTTP/3, a version of the protocol browsers use to exchange web content, uses QUIC rather than TCP. QUIC is built over the User Datagram Protocol. A browser displaying a page doesn't tell you which transport did the carrying.
TCP's Three-Way Handshake: What Those Messages Do

TCP Windowing: How a Sender Knows When to Keep Going

UDP: Letting the Application Decide What Can Wait

QUOTE:
"Amateurs hack systems, professionals hack people."
