Skip to content

Commit 3914804

Browse files
committed
Fix AssocCongestionControl test
1 parent 003ea71 commit 3914804

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

association.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ type Config struct {
299299
// Step of congestion window increase at Congestion Avoidance
300300
CwndCAStep uint32
301301

302-
// RACK loss detection: DISABLED by default (although it should probably be enabled by default..?)
302+
// Whether RACK loss detection is disabled (default: false, which means RACK is enabled)
303303
DisableRACK bool
304304
// Optional: cap the minimum reordering window: 0 = use quarter-RTT
305305
RACKReoWndFloor time.Duration
@@ -3111,7 +3111,7 @@ func (a *Association) onRackAfterSACK(
31113111
} else {
31123112
base := max(a.rackMinRTT/4, a.rackReoWndFloor)
31133113
// if we have never seen reordering for this connection, set to zero *during loss recovery* (RACK for SCTP section 2B)
3114-
// we approximate during loss recovery with inFastRecovery or T3-Rtx pending. Outside recovery keep base.
3114+
// we approximate "during loss recovery" with inFastRecovery or T3-Rtx pending. outside recovery we can keep base.
31153115
if !a.rackReorderingSeen && (a.inFastRecovery || a.t3RTX.isRunning()) {
31163116
a.rackReoWnd = 0
31173117
} else if a.rackReoWnd == 0 {
@@ -3160,7 +3160,7 @@ func (a *Association) onRackAfterSACK(
31603160
a.name, chunk.tsn, chunk.since, a.rackDeliveredTime, a.rackReoWnd)
31613161
}
31623162
}
3163-
// if we marked anything, kick the writer
3163+
// if we marked anything then wake the writer
31643164
a.awakeWriteLoop()
31653165
}
31663166

association_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1835,8 +1835,7 @@ func TestAssocCongestionControl(t *testing.T) { //nolint:cyclop,maintidx
18351835
assert.Equal(t, n, len(sbuf), "unexpected length of received data")
18361836
}
18371837

1838-
// process packets for 500 msec, assuming that the fast retrans/recover
1839-
// should complete within 500 msec.
1838+
// process packets for 500 msec; recovery should complete without RTO
18401839
for i := 0; i < 50; i++ {
18411840
br.Tick()
18421841
time.Sleep(10 * time.Millisecond)
@@ -1860,7 +1859,7 @@ func TestAssocCongestionControl(t *testing.T) { //nolint:cyclop,maintidx
18601859
return
18611860
}
18621861
assert.Equal(t, len(sbuf), n, "unexpected length of received data")
1863-
assert.Equal(t, i, int(binary.BigEndian.Uint32(rbuf)), "unexpected length of received data")
1862+
assert.Equal(t, i, int(binary.BigEndian.Uint32(rbuf)), "unexpected payload sequence")
18641863
assert.Equal(t, ppi, PayloadTypeWebRTCBinary, "unexpected ppi")
18651864
}
18661865

@@ -1873,8 +1872,13 @@ func TestAssocCongestionControl(t *testing.T) { //nolint:cyclop,maintidx
18731872
t.Logf("nSACKs : %d\n", a0.stats.getNumSACKsReceived())
18741873
t.Logf("nAckTimeouts: %d\n", a1.stats.getNumAckTimeouts())
18751874
t.Logf("nFastRetrans: %d\n", a0.stats.getNumFastRetrans())
1875+
t.Logf("nT3Timeouts : %d\n", a0.stats.getNumT3Timeouts())
18761876

1877-
assert.Equal(t, uint64(1), a0.stats.getNumFastRetrans(), "should be 1")
1877+
// With RACK enabled, recovery may happen without classic fast retransmit.
1878+
// Require recovery before RTO; allow FR count to be 0 or 1.
1879+
assert.Equal(t, uint64(0), a0.stats.getNumT3Timeouts(), "recovery should complete before any RTO")
1880+
fr := a0.stats.getNumFastRetrans()
1881+
assert.Truef(t, fr == 0 || fr == 1, "expected fast retrans 0 or 1 (RACK may bypass FR), got %d", fr)
18781882

18791883
closeAssociationPair(br, a0, a1)
18801884
})

0 commit comments

Comments
 (0)