Browse Source

Merge pull request #414 from paullouisageneau/sctp-max-burst

Add SCTP max burst setting
Paul-Louis Ageneau 4 years ago
parent
commit
ce9fa374d0
4 changed files with 22 additions and 11 deletions
  1. 7 5
      include/rtc/global.hpp
  2. 7 6
      include/rtc/rtc.h
  3. 5 0
      src/capi.cpp
  4. 3 0
      src/impl/sctptransport.cpp

+ 7 - 5
include/rtc/global.hpp

@@ -46,11 +46,13 @@ RTC_EXPORT void Preload();
 RTC_EXPORT void Cleanup();
 
 struct SctpSettings {
-	optional<size_t> recvBufferSize;
-	optional<size_t> sendBufferSize;
-	optional<size_t> maxChunksOnQueue;
-	optional<size_t> initialCongestionWindow;
-	optional<unsigned int> congestionControlModule;
+	// For the following settings, not set means optimized default
+	optional<size_t> recvBufferSize;                // in bytes
+	optional<size_t> sendBufferSize;                // in bytes
+	optional<size_t> maxChunksOnQueue;              // in chunks
+	optional<size_t> initialCongestionWindow;       // in MTUs
+	optional<size_t> maxBurst;                      // in MTUs
+	optional<unsigned int> congestionControlModule; // 0: RFC2581, 1: HSTCP, 2: H-TCP, 3: RTCC
 	optional<std::chrono::milliseconds> delayedSackTime;
 };
 

+ 7 - 6
include/rtc/rtc.h

@@ -222,12 +222,13 @@ RTC_EXPORT int rtcGetTrackDescription(int tr, char *buffer, int size);
 
 // SCTP settings
 typedef struct {
-	int recvBufferSize;          // <= 0 means optimized default
-	int sendBufferSize;          // <= 0 means optimized default
-	int maxChunksOnQueue;        // <= 0 means optimized default
-	int initialCongestionWindow; // <= 0 means optimized default
-	int congestionControlModule; // <= 0 means default (0: RFC2581, 1: HSTCP, 2: H-TCP, 3: RTCC)
-	int delayedSackTimeMs;       // <= 0 means optimized default
+	int recvBufferSize;          // in bytes, <= 0 means optimized default
+	int sendBufferSize;          // in bytes, <= 0 means optimized default
+	int maxChunksOnQueue;        // in chunks, <= 0 means optimized default
+	int initialCongestionWindow; // in MTUs, <= 0 means optimized default
+	int maxBurst;				 // in MTUs, 0 means optimized default, < 0 means disabled
+	int congestionControlModule; // 0: RFC2581 (default), 1: HSTCP, 2: H-TCP, 3: RTCC
+	int delayedSackTimeMs;       // in msecs, <= 0 means optimized default
 } rtcSctpSettings;
 
 // Note: SCTP settings apply to newly-created PeerConnections only

+ 5 - 0
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);
 

+ 3 - 0
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)));