From cc12467b2f067e67fc2b01e19e0a6ea07ffdfb82 Mon Sep 17 00:00:00 2001 From: Benny Daon Date: Tue, 27 Feb 2024 14:05:24 +0200 Subject: [PATCH] Add RTOMax settings allowing the user to cap the retranmission timeout, this change adds RTOMax to SettingEngine and pass it on when creating an sctp Client --- sctptransport.go | 5 ++++- settingengine.go | 7 +++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/sctptransport.go b/sctptransport.go index c7e0c9bfa8a..43f7f4d842f 100644 --- a/sctptransport.go +++ b/sctptransport.go @@ -58,6 +58,8 @@ type SCTPTransport struct { api *API log logging.LeveledLogger + // maximum retransmission timeout + rtoMax float64 } // NewSCTPTransport creates a new SCTPTransport. @@ -105,11 +107,12 @@ func (r *SCTPTransport) Start(SCTPCapabilities) error { if dtlsTransport == nil || dtlsTransport.conn == nil { return errSCTPTransportDTLS } - + rtoMax := float64(r.api.settingEngine.sctp.rtoMax) / float64(time.Millisecond) sctpAssociation, err := sctp.Client(sctp.Config{ NetConn: dtlsTransport.conn, MaxReceiveBufferSize: r.api.settingEngine.sctp.maxReceiveBufferSize, LoggerFactory: r.api.settingEngine.LoggerFactory, + RTOMax: rtoMax, }) if err != nil { return err diff --git a/settingengine.go b/settingengine.go index a9eb1036419..37d47a1cc90 100644 --- a/settingengine.go +++ b/settingengine.go @@ -76,6 +76,7 @@ type SettingEngine struct { } sctp struct { maxReceiveBufferSize uint32 + rtoMax time.Duration } sdpMediaLevelFingerprints bool answeringDTLSRole DTLSRole @@ -441,3 +442,9 @@ func (e *SettingEngine) SetSCTPMaxReceiveBufferSize(maxReceiveBufferSize uint32) func (e *SettingEngine) SetDTLSCustomerCipherSuites(customCipherSuites func() []dtls.CipherSuite) { e.dtls.customCipherSuites = customCipherSuites } + +// SetSCTPRTOMax sets the maximum retransmission timeout. +// Leave this 0 for the default timeout. +func (e *SettingEngine) SetSCTPRTOMax(rtoMax time.Duration) { + e.sctp.rtoMax = rtoMax +}