An Overview of TCP: Header Fields, MSS, TSO, Reliability, Flow and Congestion Control
This article provides a comprehensive introduction to TCP, covering its header structure, optional fields, the role of MSS and TSO, mechanisms for reliability and retransmission, as well as detailed explanations of flow control, sliding windows, and congestion control algorithms.
TCP, the cornerstone of reliable end‑to‑end communication on the Internet, is a connection‑oriented transport protocol that sits above IP and offers a byte‑stream service. Its design stems from the ARPANET philosophy of building reliable networks from unreliable devices.
Protocol Header – The TCP header consists of ten fixed fields (20 bytes) and optional extensions up to 40 bytes, making the header variable‑length. Key fields include Source Port, Destination Port, Sequence Number, Acknowledgment Number, Data Offset, Reserved bits, Flags, Window size, Checksum, Urgent Pointer, and Options.
Options – Each option begins with a kind byte indicating its type (e.g., End of Option List, No‑Operation, MSS, Window Scale, SACK, Timestamp). Options are padded to 4‑byte boundaries, often using NOP.
MSS and TSO – MSS (Maximum Segment Size) limits the TCP payload to avoid IP fragmentation; it is typically set to the interface MTU minus 40 bytes (IP+TCP header). TSO (TCP Segmentation Offload) allows the NIC to handle large segments, offloading segmentation and checksum computation from the CPU. Commands to view and toggle TSO on Linux:
$ sudo ethtool -k eth0
Features for eth0:
rx-checksumming: on
tx-checksumming: on
scatter-gather: on
tcp-segmentation-offload: on
$ sudo ethtool -K eth0 tso off // disable TSO
$ sudo ethtool -K eth0 tso on // enable TSOTSO explains why packet captures on TSO‑enabled hosts may show packets larger than the MTU; the capture reflects pre‑segmentation data.
Reliability and Retransmission – TCP ensures ordered delivery using the Sequence Number and acknowledges received data with ACKs. Retransmission is triggered by checksum failures, timeouts, or duplicate ACKs. Fast retransmit fires after three duplicate ACKs, while selective retransmission (SACK) allows the sender to resend only missing segments. SYN retransmission uses exponential back‑off.
Flow Control – Implemented via a sliding window advertised by the receiver. The window size, combined with optional window scaling, dictates how much data the sender may transmit without further ACKs. Issues such as Silly Window Syndrome are mitigated by requiring the receiver to advertise sufficiently large windows and the sender to transmit sizable segments.
Congestion Control – TCP measures RTT to infer network congestion. Classic RTT estimators (Karn/Partridge, Jacobson/Karels) feed into algorithms like Slow Start, Congestion Avoidance, Fast Retransmit, and Fast Recovery. The effective sending window is the minimum of the sliding window and the congestion window.
The article concludes with references to key RFCs (e.g., RFC 793, RFC 1122, RFC 5681, RFC 6298) that define TCP specifications and extensions.
Qunar Tech Salon
Qunar Tech Salon is a learning and exchange platform for Qunar engineers and industry peers. We share cutting-edge technology trends and topics, providing a free platform for mid-to-senior technical professionals to exchange and learn.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.