The SACK option is to be used to convey extended acknowledgment information over an established connection. Specifically, it is to be sent by a data receiver to inform the data transmitter of non-contiguous blocks of data that have been received and queued. The data receiver is awaiting the receipt of data in later retransmissions to fill the gaps in sequence space between these blocks. At that time, the data receiver will acknowledge the data normally by advancing the left window edge in the Acknowledgment Number field of the TCP header.
It is important to understand that the SACK option will not change the meaning of the Acknowledgment Number field, whose value will still specify the left window edge, i.e., one byte beyond the last sequence number of fully-received data. The SACK option is advisory; if it is ignored, TCP acknowledgments will continue to function as specified in the protocol.
However, SACK will provide additional information that the data transmitter can use to optimize retransmissions. The TCP data receiver may include the SACK option in an acknowledgment segment whenever it has data that is queued and unacknowledged. Of course, the SACK option may be sent only when the TCP has received the SACK-permitted option in the SYN segment for that connection.
TCP SACK Option: Kind: 5 Length: Variable +--------+--------+--------+--------+--------+--------+...---+ | Kind=5 | Length | Relative Origin | Block Size | | +--------+--------+--------+--------+--------+--------+...---+
This option contains a list of the blocks of contiguous sequence space occupied by data that has been received and queued within the window. Each block is contiguous and isolated; that is, the octets just below the block,
Acknowledgment Number + Relative Origin -1,
and just above the block,
Acknowledgment Number + Relative Origin + Block Size,
have not been received.
Each contiguous block of data queued at the receiver is defined in the SACK option by two 16-bit integers:
This is the first sequence number of this block, relative to the Acknowledgment Number field in the TCP header (i.e., relative to the data receiver's left window edge).
This is the size in octets of this block of contiguous data.
A SACK option that specifies n blocks will have a length of 4*n+2 octets, so the 44 bytes available for TCP options can specify a maximum of 10 blocks. Of course, if other TCP options are introduced, they will compete for the 44 bytes, and the limit of 10 may be reduced in particular segments.
There is no requirement on the order in which blocks can appear in a single SACK option.
Note: requiring that the blocks be ordered would allow a slightly more efficient algorithm in the transmitter; however, this does not seem to be an important optimization.