why
should
SACK
be designed ?
TCP may experience poor performance when multiple packets are lost from one window of data. With the limited information available from cumulative acknowledgments, a TCP sender can only learn about a single lost packet perround trip time. An aggressive sender could choose to retransmit packets early,but such retransmitted segments may have already been successfully received.
Tcp协议在一个窗口内多个数据丢失时,由于ACK携带信息有限,仅知其后的一个数据包丢失,发送方激进一点的做法是重传所有ACK后没有被应答的数据(到snd_una), 缺点是对端接受到的数据也会重传,这个重传是无效的。
A Selective Acknowledgment (SACK) mechanism, combined with a selective repeat retransmissionpolicy, can help to overcome these limitations. The receiving TCP sends backSACK packets to the sender
informing the sender of data that has beenreceived. The sender can then retransmit only the missing datasegments.
鉴于传统tcp存在上面的缺点,于是提出了SACK机制,SACK机制的原理是接收端检查到丢包时通过ACK携带信息,告知对端已经接受到的数据,之后不用重传已经接受到的数据包。SACK机制是重传机制更加高效。
How to support SACK?
The selective acknowledgment extension uses two TCP options. The firstis an enabling option, “SACK-permitted”, which may be sent in a SYN segment to indicate that the SACK option can be used once the connectionis established. The other is the SACK option itself, which may be sent over an established connection once permission has beengiven by SACK-permitted.
标准tcp扩展了额两个选项Sack-PermittedOption和Sack Option,Sack-Permitted Option
用来协商连接是否可以启用SACK支持,通过SYN携带Sack Permitted标志在连接建立过程中进行协商。Sack Option携带在ACK中,如果接受端发现了当前窗口有丢包时,需要携带SACK选项和SACK信息告知对端。
The SACK option is to be included in a segment sent from a TCP that is receiving data to the TCP that is sending that data; we willrefer to these TCP’s as the data receiver and the data sender, respectively. We will consider a particular simplex data flow; any dataflowing in the reverse direction over the same connection can be treated independently.
Sack-Permitted Option
This two-byte option may be sent in a SYN by a TCP that has been extended to receive (andpresumably process) the SACK option once the connection has opened. ItMUST NOT be sent on non-SYN segments.
TCP Sack-Permitted Option:
Sack Option Format
TheSACK option is to be used to convey extended acknowledgment information from thereceiver to the sender over an established TCP connection.
TCP SACK Option:
* Left Edge of Block
This is the first sequence number ofthis block.
* Right Edge of Block
This is the sequence number immediatelyfollowing the last sequence number of this block.
Note:
1、SACK的left/right edge描述的是已经接受到的数据段情况。
2、tcp 选项最大长度为40个字节,所以ACK最大可以携带4组边界,tcp header中有一个字段4bit描述tcp header的总长度(2^4 – 1) * 4 = 60,不包含选项时tcp头部为20个字节,所以tcp运行最大选项长度为40,所以ACK最大允许携带4组SACK边界。
3、SACK引入对数据包重传机制影响很大,后面分析SACK数据包重传策略。