Skip to content

Commit

Permalink
Add RTOMax settings
Browse files Browse the repository at this point in the history
allowing the user to cap the retranmission timeout, this change adds
RTOMax to SettingEngine and pass it on when creating an sctp Client
  • Loading branch information
daonb committed Feb 27, 2024
1 parent 1345033 commit cc12467
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 4 additions & 1 deletion sctptransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ type SCTPTransport struct {

api *API
log logging.LeveledLogger
// maximum retransmission timeout
rtoMax float64
}

// NewSCTPTransport creates a new SCTPTransport.
Expand Down Expand Up @@ -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
Expand Down
7 changes: 7 additions & 0 deletions settingengine.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ type SettingEngine struct {
}
sctp struct {
maxReceiveBufferSize uint32
rtoMax time.Duration
}
sdpMediaLevelFingerprints bool
answeringDTLSRole DTLSRole
Expand Down Expand Up @@ -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
}

0 comments on commit cc12467

Please sign in to comment.