TCP

Last update: 2022-02-17 11:58:10 +0800 +0800
Available translations: 日本語 / 中文(简体) / 中文(繁體)

TCP is a reliable, ordered byte-stream transport. It identifies each byte with a 32-bit sequence number; arithmetic on those numbers is modulo 2^32.

Three-Way Handshake #

To open a connection, the client sends a SYN with an initial sequence number x. The server replies with SYN+ACK, chooses its own initial sequence number y, and acknowledges x + 1. The client sends an ACK acknowledging y + 1. A SYN consumes one sequence-number position even though it carries no application byte.

Data Transfer and Close #

Each ACK reports the next sequence number expected, so it cumulatively acknowledges all preceding bytes. TCP retransmits unacknowledged data, regulates sending with the receiver’s advertised window, and uses congestion control to avoid overwhelming the network. A graceful close uses FIN segments in each direction; a reset (RST) aborts a connection without the normal orderly shutdown.

Comments

Read or comment on GitHub (sign-in required to comment)