From de2e7b7e0166160f008c55b1664afea064aa806d Mon Sep 17 00:00:00 2001 From: Sean DuBois Date: Mon, 18 Mar 2024 09:33:27 -0400 Subject: [PATCH] Put SCTP Zero Checksum behind SettingEngine Old versions of Pion break against it --- go.mod | 2 +- go.sum | 4 ++-- sctptransport.go | 2 +- settingengine.go | 8 ++++++++ 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/go.mod b/go.mod index e76ecc50698..46ce2911b30 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/pion/randutil v0.1.0 github.com/pion/rtcp v1.2.12 github.com/pion/rtp v1.8.3 - github.com/pion/sctp v1.8.12 + github.com/pion/sctp v1.8.13 github.com/pion/sdp/v3 v3.0.8 github.com/pion/srtp/v2 v2.0.18 github.com/pion/stun v0.6.1 diff --git a/go.sum b/go.sum index 4fdb12b2365..1386037e6b4 100644 --- a/go.sum +++ b/go.sum @@ -61,8 +61,8 @@ github.com/pion/rtp v1.8.2/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU github.com/pion/rtp v1.8.3 h1:VEHxqzSVQxCkKDSHro5/4IUUG1ea+MFdqR2R3xSpNU8= github.com/pion/rtp v1.8.3/go.mod h1:pBGHaFt/yW7bf1jjWAoUjpSNoDnw98KTMg+jWWvziqU= github.com/pion/sctp v1.8.5/go.mod h1:SUFFfDpViyKejTAdwD1d/HQsCu+V/40cCs2nZIvC3s0= -github.com/pion/sctp v1.8.12 h1:2VX50pedElH+is6FI+OKyRTeN5oy4mrk2HjnGa3UCmY= -github.com/pion/sctp v1.8.12/go.mod h1:cMLT45jqw3+jiJCrtHVwfQLnfR0MGZ4rgOJwUOIqLkI= +github.com/pion/sctp v1.8.13 h1:YUJR44pWM2FPUhkl8l+vDyF2EDE3aTWtr3c+LDhCRcQ= +github.com/pion/sctp v1.8.13/go.mod h1:YKSgO/bO/6aOMP9LCie1DuD7m+GamiK2yIiPM6vH+GA= github.com/pion/sdp/v3 v3.0.8 h1:yd/wkrS0nzXEAb+uwv1TL3SG/gzsTiXHVOtXtD7EKl0= github.com/pion/sdp/v3 v3.0.8/go.mod h1:B5xmvENq5IXJimIO4zfp6LAe1fD9N+kFv+V/1lOdz8M= github.com/pion/srtp/v2 v2.0.18 h1:vKpAXfawO9RtTRKZJbG4y0v1b11NZxQnxRl85kGuUlo= diff --git a/sctptransport.go b/sctptransport.go index 35778ca955d..a468cbc98d6 100644 --- a/sctptransport.go +++ b/sctptransport.go @@ -109,7 +109,7 @@ func (r *SCTPTransport) Start(SCTPCapabilities) error { sctpAssociation, err := sctp.Client(sctp.Config{ NetConn: dtlsTransport.conn, MaxReceiveBufferSize: r.api.settingEngine.sctp.maxReceiveBufferSize, - EnableZeroChecksum: true, + EnableZeroChecksum: r.api.settingEngine.sctp.enableZeroChecksum, LoggerFactory: r.api.settingEngine.LoggerFactory, }) if err != nil { diff --git a/settingengine.go b/settingengine.go index 921c94b28e2..95c59fb11ad 100644 --- a/settingengine.go +++ b/settingengine.go @@ -75,6 +75,7 @@ type SettingEngine struct { } sctp struct { maxReceiveBufferSize uint32 + enableZeroChecksum bool } sdpMediaLevelFingerprints bool answeringDTLSRole DTLSRole @@ -434,3 +435,10 @@ func (e *SettingEngine) SetDTLSKeyLogWriter(writer io.Writer) { func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) { e.sctp.maxReceiveBufferSize = maxReceiveBufferSize } + +// SetSCTPZeroChecksum enables the zero checksum feature in SCTP. +// This removes the need to checksum every incoming/outgoing packet and will reduce +// latency and CPU usage. This feature is not backwards compatible so is disabled by default +func (e *SettingEngine) EnableSCTPZeroChecksum(isEnabled bool) { + e.sctp.enableZeroChecksum = isEnabled +}