Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add RTOMax settings #2682

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion sctptransport.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@

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

// NewSCTPTransport creates a new SCTPTransport.
Expand Down Expand Up @@ -105,12 +107,13 @@
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,
})

Check failure on line 116 in sctptransport.go

View workflow job for this annotation

GitHub Actions / test (1.20) / Go 1.20

unknown field RTOMax in struct literal of type sctp.Config

Check failure on line 116 in sctptransport.go

View workflow job for this annotation

GitHub Actions / test (1.21) / Go 1.21

unknown field RTOMax in struct literal of type sctp.Config
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
}
9 changes: 9 additions & 0 deletions settingengine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,3 +269,12 @@ func TestSetSCTPMaxReceiverBufferSize(t *testing.T) {
s.SetSCTPMaxReceiveBufferSize(expSize)
assert.Equal(t, expSize, s.sctp.maxReceiveBufferSize)
}

func TestSetSCTPRTOMax(t *testing.T) {
s := SettingEngine{}
assert.Equal(t, time.Duration(0), s.sctp.rtoMax)

expSize := time.Second
s.SetSCTPRTOMax(expSize)
assert.Equal(t, expSize, s.sctp.rtoMax)
}
Loading