TCP Maximum Segment Size (MSS) works by negotiating the largest amount of data a device can receive in a single TCP segment during the TCP handshake process. Here's a breakdown:
TCP Handshake and MSS Negotiation
- TCP Connection Establishment: TCP establishes a connection using a three-way handshake.
- MSS Advertisement: During the TCP handshake, each device advertises its MSS option. This advertisement indicates the maximum size of the TCP segment it can accept. The reference notes that this communication of packet size is called "MSS clamping."
- Effective MSS: The smaller of the two advertised MSS values becomes the effective MSS for the connection. This ensures neither device sends segments larger than the other can handle.
Key Aspects of TCP MSS
Aspect | Description |
---|---|
Purpose | To avoid IP fragmentation, which can negatively impact network performance. |
Negotiation | Agreed upon during the TCP handshake process. |
Calculation | Typically, MSS is calculated as the Maximum Transmission Unit (MTU) of the underlying network minus the IP and TCP header sizes. MTU – IP Header – TCP Header = MSS (e.g., 1500 - 20 - 20 = 1460). |
MSS Clamping | The process where devices communicate their receive buffer size capabilities during the TCP handshake. |
Fragmentation | MSS aims to prevent IP fragmentation at the sender by limiting the size of TCP segments. If fragmentation occurs, it's ideally handled at the destination or along the path if Path MTU Discovery (PMTUD) fails. |
Why is MSS Important?
- Avoids Fragmentation: Fragmentation increases overhead and can lead to performance issues. MSS ensures data is sent in sizes that avoid fragmentation, improving efficiency.
- Improves Network Performance: By avoiding fragmentation, MSS contributes to faster data transmission and lower latency.
- Compatibility: Ensures compatibility between devices with different MTU sizes.