From b6135a7ca451ad4fc288cd0e0a0ae9680105f3e9 Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Wed, 3 Apr 2024 15:15:38 -0400 Subject: [PATCH] Heuristics to fix interop with bad ZeroChecksum The SCTP implementation used in v3.2.28 fails to establish a connection with other WebRTC implementations. The implementation of ZeroChecksum assumes incorrectly that the feature is bi-directional SCTP ZeroChecksum is actually a uni-directional feature which causes the Assocations to be unable to communicate. --- association.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/association.go b/association.go index d5722d3c..f09c03f2 100644 --- a/association.go +++ b/association.go @@ -161,6 +161,7 @@ type Association struct { peerVerificationTag uint32 myVerificationTag uint32 state uint32 + initialTSN uint32 myNextTSN uint32 // nextTSN peerLastTSN uint32 // lastRcvdTSN minTSN2MeasureRTT uint32 // for RTT measurement @@ -336,6 +337,7 @@ func createAssociation(config Config) *Association { mtu: initialMTU, maxPayloadSize: initialMTU - (commonHeaderSize + dataChunkHeaderSize), myVerificationTag: globalMathRandomGenerator.Uint32(), + initialTSN: tsn, myNextTSN: tsn, myNextRSN: tsn, minTSN2MeasureRTT: tsn, @@ -2553,6 +2555,12 @@ func (a *Association) onRetransmissionTimeout(id int, nRtos uint) { a.lock.Lock() defer a.lock.Unlock() + // TSN hasn't been incremented in 3 attempts. Speculatively + // disable ZeroChecksum because old Pion versions had a broken implementation + if a.cumulativeTSNAckPoint+1 == a.initialTSN && nRtos == 3 { + a.sendZeroChecksum = false + } + if id == timerT1Init { err := a.sendInit() if err != nil {