Skip to content

Commit ff8445e

Browse files
author
Your Name
committed
auto-enable adaptive reorder based on SRTO_LOSSMAXTTL
1 parent 568dbeb commit ff8445e

4 files changed

Lines changed: 5 additions & 42 deletions

File tree

congestion/congestion.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,6 @@ type Receiver interface {
5656

5757
// ReorderTolerance returns the current dynamic reorder tolerance value.
5858
ReorderTolerance() int
59-
60-
// SetReorderSupport enables or disables adaptive reorder tolerance based on peer REXMIT capability.
61-
SetReorderSupport(enabled bool)
6259
}
6360

6461
// SendStats are collected statistics from a sender

congestion/live/fake.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,5 +182,3 @@ func (r *fakeLiveReceive) SetNAKInterval(nakInterval uint64) {
182182
}
183183

184184
func (r *fakeLiveReceive) ReorderTolerance() int { return 0 }
185-
186-
func (r *fakeLiveReceive) SetReorderSupport(enabled bool) {}

congestion/live/receive.go

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,6 @@ type receiver struct {
5757
// Adaptive reorder tolerance state (mirrors libsrt m_iReorderTolerance)
5858
maxReorderTolerance int
5959
reorderTolerance int
60-
reorderSupport bool
6160
consecOrderedDelivery int
6261
consecEarlyDelivery int
6362
freshLoss []freshLossEntry
@@ -97,7 +96,6 @@ func NewReceiver(config ReceiveConfig) congestion.Receiver {
9796

9897
maxReorderTolerance: config.MaxReorderTolerance,
9998
reorderTolerance: config.MaxReorderTolerance,
100-
reorderSupport: false,
10199

102100
sendACK: config.OnSendACK,
103101
sendNAK: config.OnSendNAK,
@@ -277,9 +275,9 @@ func (r *receiver) Push(pkt packet.Packet) {
277275
r.statistics.PktLoss += lossLen
278276
r.statistics.ByteLoss += lossLen * uint64(r.avgPayloadSize)
279277

280-
// Determine initial loss TTL based on reorder support
278+
// Determine initial loss TTL based on adaptive reorder tolerance support
281279
initialLossTTL := 0
282-
if r.reorderSupport {
280+
if r.maxReorderTolerance > 0 {
283281
initialLossTTL = r.reorderTolerance
284282
}
285283

@@ -512,28 +510,12 @@ func (r *receiver) ReorderTolerance() int {
512510
return r.reorderTolerance
513511
}
514512

515-
func (r *receiver) SetReorderSupport(enabled bool) {
516-
r.lock.Lock()
517-
defer r.lock.Unlock()
518-
519-
r.reorderSupport = enabled
520-
if enabled {
521-
r.reorderTolerance = r.maxReorderTolerance
522-
} else {
523-
r.reorderTolerance = 0
524-
r.consecOrderedDelivery = 0
525-
r.consecEarlyDelivery = 0
526-
r.freshLoss = nil
527-
r.traceReorderDistance = 0
528-
}
529-
}
530-
531513
// unlose adjusts reorder tolerance for a belated packet. Mirrors libsrt CUDT::unlose().
532514
func (r *receiver) unlose(pkt packet.Packet) {
533515
hasIncreasedTolerance := false
534516
wasReordered := false
535517

536-
if r.reorderSupport {
518+
if r.maxReorderTolerance > 0 {
537519
// Original (not retransmitted) belated packet means reordering
538520
wasReordered = !pkt.Header().RetransmittedPacketFlag
539521
if wasReordered {
@@ -553,7 +535,7 @@ func (r *receiver) unlose(pkt packet.Packet) {
553535
}
554536

555537
// Early return if adaptive reorder is not active (mirrors libsrt)
556-
if !r.reorderSupport || r.reorderTolerance == 0 {
538+
if r.maxReorderTolerance == 0 || r.reorderTolerance == 0 {
557539
return
558540
}
559541

@@ -578,7 +560,7 @@ func (r *receiver) unlose(pkt packet.Packet) {
578560

579561
// updateOrderedDelivery tracks in-order delivery and decays tolerance after 50 consecutive.
580562
func (r *receiver) updateOrderedDelivery(wasSentInOrder bool) {
581-
if !r.reorderSupport {
563+
if r.maxReorderTolerance == 0 {
582564
return
583565
}
584566

connection.go

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -918,13 +918,6 @@ func (c *srtConn) handleHSRequest(p packet.Packet) {
918918
return
919919
}
920920

921-
if cif.SRTFlags.REXMITFLG {
922-
// Peer supports REXMIT flag, enable adaptive reorder tolerance
923-
c.recv.SetReorderSupport(true)
924-
} else {
925-
c.log("control:recv:HSRes:warn", func() string { return "peer does not support REXMITFLG, adaptive reorder tolerance disabled" })
926-
}
927-
928921
// we as receiver don't need this
929922
cif.SRTFlags.TSBPDSND = false
930923

@@ -1013,13 +1006,6 @@ func (c *srtConn) handleHSResponse(p packet.Packet) {
10131006
return
10141007
}
10151008

1016-
if cif.SRTFlags.REXMITFLG {
1017-
// Peer supports REXMIT flag, enable adaptive reorder tolerance
1018-
c.recv.SetReorderSupport(true)
1019-
} else {
1020-
c.log("control:recv:HSRes:warn", func() string { return "peer does not support REXMITFLG, adaptive reorder tolerance disabled" })
1021-
}
1022-
10231009
// These flag was introduced in HSv5 and should not be set in HSv4
10241010
if cif.SRTFlags.STREAM {
10251011
c.log("control:recv:HSReq:error", func() string { return "STREAM flag is set" })

0 commit comments

Comments
 (0)