From 5f604a49de22c8a74afbc1d06587bbfabba2d8ed Mon Sep 17 00:00:00 2001 From: cnderrauber Date: Thu, 14 Nov 2024 14:52:01 +0800 Subject: [PATCH] Increment missing indications from SACK Increment missing indication for reported missing chunks instead of all inflight chunks. --- association.go | 11 +++++++---- association_test.go | 4 ++-- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/association.go b/association.go index 29e9978c..40796694 100644 --- a/association.go +++ b/association.go @@ -512,7 +512,7 @@ func (a *Association) Close() error { a.log.Debugf("[%s] stats nPackets (out) : %d", a.name, a.stats.getNumPacketsSent()) a.log.Debugf("[%s] stats nDATAs (in) : %d", a.name, a.stats.getNumDATAs()) a.log.Debugf("[%s] stats nSACKs (in) : %d", a.name, a.stats.getNumSACKsReceived()) - a.log.Debugf("[%s] stats nSACKs (out) : %d\n", a.name, a.stats.getNumSACKsSent()) + a.log.Debugf("[%s] stats nSACKs (out) : %d", a.name, a.stats.getNumSACKsSent()) a.log.Debugf("[%s] stats nT3Timeouts : %d", a.name, a.stats.getNumT3Timeouts()) a.log.Debugf("[%s] stats nAckTimeouts: %d", a.name, a.stats.getNumAckTimeouts()) a.log.Debugf("[%s] stats nFastRetrans: %d", a.name, a.stats.getNumFastRetrans()) @@ -1728,7 +1728,7 @@ func (a *Association) onCumulativeTSNAckPointAdvanced(totalBytesAcked int) { } // The caller should hold the lock. -func (a *Association) processFastRetransmission(cumTSNAckPoint, htna uint32, cumTSNAckPointAdvanced bool) error { +func (a *Association) processFastRetransmission(cumTSNAckPoint uint32, gapAckBlocks []gapAckBlock, htna uint32, cumTSNAckPointAdvanced bool) error { // HTNA algorithm - RFC 4960 Sec 7.2.4 // Increment missIndicator of each chunks that the SACK reported missing // when either of the following is met: @@ -1745,7 +1745,10 @@ func (a *Association) processFastRetransmission(cumTSNAckPoint, htna uint32, cum maxTSN = htna } else { // b) increment for all TSNs reported missing - maxTSN = cumTSNAckPoint + uint32(a.inflightQueue.size()) + 1 + maxTSN = cumTSNAckPoint + if len(gapAckBlocks) > 0 { + maxTSN += uint32(gapAckBlocks[len(gapAckBlocks)-1].end) + } } for tsn := cumTSNAckPoint + 1; sna32LT(tsn, maxTSN); tsn++ { @@ -1855,7 +1858,7 @@ func (a *Association) handleSack(d *chunkSelectiveAck) error { a.setRWND(d.advertisedReceiverWindowCredit - bytesOutstanding) } - err = a.processFastRetransmission(d.cumulativeTSNAck, htna, cumTSNAckPointAdvanced) + err = a.processFastRetransmission(d.cumulativeTSNAck, d.gapAckBlocks, htna, cumTSNAckPointAdvanced) if err != nil { return err } diff --git a/association_test.go b/association_test.go index a8611318..7267da3b 100644 --- a/association_test.go +++ b/association_test.go @@ -3489,10 +3489,10 @@ func TestAssociation_OpenStreamAfterInternalClose(t *testing.T) { require.NoError(t, a2.netConn.Close()) _, err = a1.OpenStream(1, PayloadTypeWebRTCString) - require.NoError(t, err) + require.True(t, err == nil || errors.Is(err, ErrAssociationClosed)) _, err = a2.OpenStream(1, PayloadTypeWebRTCString) - require.NoError(t, err) + require.True(t, err == nil || errors.Is(err, ErrAssociationClosed)) require.NoError(t, a1.Close()) require.NoError(t, a2.Close())