arthrop0d

Brief articles on varied topics.

TCP Selective Acknowledgments and Targeted Retransmission

networking

TCP Selective Acknowledgments (SACK) let a receiver tell a sender which ranges of data arrived, even when an earlier range is missing. The sender uses that record to retransmit only the missing segments rather than resending data the receiver already has.

The problem SACK solves

TCP numbers every byte in a stream. A receiver normally acknowledges data with a cumulative ACK: the ACK number identifies the next byte it expects. If it has received bytes through 9,999, it sends an ACK for 10,000.

That works well when packets arrive in order. Packet loss makes the information much less precise.

Imagine a sender transmits four segments:

segment A: bytes 0–999
segment B: bytes 1000–1999   (lost)
segment C: bytes 2000–2999
segment D: bytes 3000–3999

The receiver cannot advance its cumulative ACK past the gap, so it keeps acknowledging byte 1000. However, it may still accept and buffer segments C and D. A normal ACK of 1000 tells the sender only that the receiver is still waiting there; it does not reveal that bytes 2000–3999 are already safely stored.

Without SACK, the sender has less reliable knowledge of what arrived. After detecting the loss, it may retransmit segment B and then retransmit later segments too, or it may wait for acknowledgments that clarify the situation. On a connection with several losses in one transmission window, this can waste bandwidth and slow recovery.

A cumulative ACK says, “Everything before this point is complete.” SACK adds, “These later ranges are complete too.”

What a SACK record contains

A SACK record is carried in a TCP option on an ACK. Each SACK block describes one contiguous range of sequence numbers that the receiver has received and can identify. The range is represented by a left edge and a right edge; the right edge is exclusive.

For the example above, an ACK might contain:

ACK number: 1000
SACK block: [2000, 4000)

The cumulative ACK still says that byte 1000 is the next missing byte. The SACK block says that bytes 2000 through 3999 are present. The sender can therefore infer that the missing range is [1000, 2000) and retransmit just segment B.

SACK is not enabled automatically merely because a receiver understands the option. The endpoints negotiate permission during the TCP handshake using the SACK Permitted option. Once both sides agree, the receiver can include SACK blocks in later ACKs.

TCP options have limited space, so one ACK cannot describe every range in an arbitrarily fragmented stream. A receiver usually reports the most useful recently received ranges, and later ACKs can update that information as more data arrives. SACK blocks also describe received data; they do not directly list missing data. The sender derives the holes by comparing the SACK ranges with the sequence ranges it has transmitted.

How targeted recovery works

Consider the four-segment example in more detail:

  1. The receiver gets A and sends an ACK for 1000.
  2. B is lost, but C arrives. The receiver buffers C and sends another ACK for 1000 with a SACK block for [2000, 3000).
  3. D arrives. The receiver still cannot move its cumulative ACK beyond the gap, so it sends an ACK for 1000 with a SACK block covering [2000, 4000).
  4. The sender records these acknowledgments. It knows A is cumulatively acknowledged, C and D are selectively acknowledged, and B is the outstanding hole.
  5. The sender retransmits B, not C and D.

When B arrives, the receiver can join the now-contiguous data and advance its cumulative ACK, potentially acknowledging through byte 4000.

A real TCP implementation maintains this information as part of its loss-recovery state. This is often described as a scoreboard: a record of which transmitted sequence ranges are acknowledged, which remain outstanding, and which are suspected of being lost. The implementation uses that state alongside timers, duplicate ACKs and congestion-control rules to decide when and how much to retransmit.

SACK does not mean the sender can ignore congestion control. A retransmission still consumes network capacity, and the sender must reduce or pace its sending when loss indicates congestion. SACK improves the accuracy of recovery; it does not remove TCP’s safety rules.

Why it is more efficient than repeating a window

Suppose a window contains 100 segments and three are lost. If the sender knows only that delivery stopped at the first missing segment, it may need to retransmit a long suffix of the window, including segments that already reached the receiver. That creates several costs:

With SACK, the sender can fill the specific holes first. If 97 of 100 segments arrived, it can normally send the three missing segments instead of repeating most or all of the 100-segment window. The improvement is especially important when losses are multiple, bursty or occur on a fast connection with a large bandwidth-delay product.

You may encounter SACK in packet captures, kernel statistics, TCP diagnostic logs or configuration flags. A trace showing duplicate ACKs with SACK blocks is evidence that later data arrived out of order while an earlier range was missing. The key interpretation is simple: the cumulative ACK marks the first gap, and the SACK blocks preserve the receiver’s knowledge beyond that gap so the sender can repair only what is absent.

← All articles