diff --git a/include/rtc/global.hpp b/include/rtc/global.hpp index 7dfc9de..68d9332 100644 --- a/include/rtc/global.hpp +++ b/include/rtc/global.hpp @@ -46,10 +46,12 @@ RTC_EXPORT void Preload(); RTC_EXPORT void Cleanup(); struct SctpSettings { + // For the following settings, not set means optimized default optional recvBufferSize; optional sendBufferSize; optional maxChunksOnQueue; optional initialCongestionWindow; + optional maxBurst; optional congestionControlModule; optional delayedSackTime; }; diff --git a/include/rtc/rtc.h b/include/rtc/rtc.h index 2d08fbc..563d8b5 100644 --- a/include/rtc/rtc.h +++ b/include/rtc/rtc.h @@ -226,6 +226,7 @@ typedef struct { int sendBufferSize; // <= 0 means optimized default int maxChunksOnQueue; // <= 0 means optimized default int initialCongestionWindow; // <= 0 means optimized default + int maxBurst; // 0 means optimized default, < 0 means disabled int congestionControlModule; // <= 0 means default (0: RFC2581, 1: HSTCP, 2: H-TCP, 3: RTCC) int delayedSackTimeMs; // <= 0 means optimized default } rtcSctpSettings; diff --git a/src/capi.cpp b/src/capi.cpp index 518d599..4366150 100644 --- a/src/capi.cpp +++ b/src/capi.cpp @@ -683,6 +683,11 @@ int rtcSetSctpSettings(const rtcSctpSettings *settings) { if (settings->initialCongestionWindow > 0) s.initialCongestionWindow = size_t(settings->initialCongestionWindow); + if (settings->maxBurst > 0) + s.maxBurst = size_t(settings->maxBurst); + else if (settings->maxBurst < 0) + s.maxBurst = size_t(0); // setting to 0 disables, not setting chooses optimized default + if (settings->congestionControlModule >= 0) s.congestionControlModule = unsigned(settings->congestionControlModule); diff --git a/src/impl/sctptransport.cpp b/src/impl/sctptransport.cpp index 8e32db9..11690d0 100644 --- a/src/impl/sctptransport.cpp +++ b/src/impl/sctptransport.cpp @@ -115,6 +115,9 @@ void SctpTransport::SetSettings(const SctpSettings &s) { // Increase initial congestion window size to 10 MTUs (RFC 6928) by default usrsctp_sysctl_set_sctp_initial_cwnd(to_uint32(s.initialCongestionWindow.value_or(10))); + // Set max burst to 10 MTUs by default (max burst is initially 0, meaning disabled) + usrsctp_sysctl_set_sctp_max_burst_default(to_uint32(s.maxBurst.value_or(10))); + // Use standard SCTP congestion control (RFC 4960) by default // See https://github.com/paullouisageneau/libdatachannel/issues/354 usrsctp_sysctl_set_sctp_default_cc_module(to_uint32(s.congestionControlModule.value_or(0)));