diff --git a/jni/libdatachannel b/jni/libdatachannel index 47f2fa1..0b15881 160000 --- a/jni/libdatachannel +++ b/jni/libdatachannel @@ -1 +1 @@ -Subproject commit 47f2fa11b9ea9d59da3c860bfac4b16574ee2ec9 +Subproject commit 0b158812cfbd9676e7cf4a63452e0e13f305997e diff --git a/jni/src/util.cpp b/jni/src/util.cpp index 434f5c9..a6e6e92 100644 --- a/jni/src/util.cpp +++ b/jni/src/util.cpp @@ -66,7 +66,8 @@ JNIEXPORT void JNICALL Java_tel_schich_libdatachannel_LibDataChannel_setSctpSett JNIEnv* env, jclass clazz, const jint recvBufferSize, const jint sendBufferSize, const jint maxChunksOnQueue, const jint initialCongestionWindow, const jint maxBurst, const jint congestionControlModule, const jint delayedSackTimeMs, const jint minRetransmitTimeoutMs, const jint maxRetransmitTimeoutMs, - const jint initialRetransmitTimeoutMs, const jint maxRetransmitAttempts, const jint heartbeatIntervalMs) { + const jint initialRetransmitTimeoutMs, const jint maxRetransmitAttempts, const jint heartbeatIntervalMs, + const jint cwndBasedMaxBurst) { rtcSctpSettings settings{}; settings.recvBufferSize = recvBufferSize; settings.sendBufferSize = sendBufferSize; @@ -80,5 +81,6 @@ JNIEXPORT void JNICALL Java_tel_schich_libdatachannel_LibDataChannel_setSctpSett settings.initialRetransmitTimeoutMs = initialRetransmitTimeoutMs; settings.maxRetransmitAttempts = maxRetransmitAttempts; settings.heartbeatIntervalMs = heartbeatIntervalMs; + settings.cwndBasedMaxBurst = cwndBasedMaxBurst; wrap_error(env, "rtcSetSctpSettings", rtcSetSctpSettings(&settings)); } \ No newline at end of file diff --git a/src/main/java/tel/schich/libdatachannel/LibDataChannel.java b/src/main/java/tel/schich/libdatachannel/LibDataChannel.java index 9f29e85..db86a34 100644 --- a/src/main/java/tel/schich/libdatachannel/LibDataChannel.java +++ b/src/main/java/tel/schich/libdatachannel/LibDataChannel.java @@ -55,7 +55,8 @@ public static synchronized void setSctpSettings(SctpSettings settings) { private static void applySctpSettings(SctpSettings s) { setSctpSettingsNative(s.recvBufferSize, s.sendBufferSize, s.maxChunksOnQueue, s.initialCongestionWindow, s.maxBurst, s.congestionControlModule, s.delayedSackTimeMs, s.minRetransmitTimeoutMs, - s.maxRetransmitTimeoutMs, s.initialRetransmitTimeoutMs, s.maxRetransmitAttempts, s.heartbeatIntervalMs); + s.maxRetransmitTimeoutMs, s.initialRetransmitTimeoutMs, s.maxRetransmitAttempts, s.heartbeatIntervalMs, + s.cwndBasedMaxBurst); } private static native void setSctpSettingsNative(int recvBufferSize, int sendBufferSize, int maxChunksOnQueue, @@ -63,7 +64,7 @@ private static native void setSctpSettingsNative(int recvBufferSize, int sendBuf int congestionControlModule, int delayedSackTimeMs, int minRetransmitTimeoutMs, int maxRetransmitTimeoutMs, int initialRetransmitTimeoutMs, int maxRetransmitAttempts, - int heartbeatIntervalMs); + int heartbeatIntervalMs, int cwndBasedMaxBurst); /** * Initializes the library by loading the native library. diff --git a/src/main/java/tel/schich/libdatachannel/SctpSettings.java b/src/main/java/tel/schich/libdatachannel/SctpSettings.java index 9eb77e4..044bfbf 100644 --- a/src/main/java/tel/schich/libdatachannel/SctpSettings.java +++ b/src/main/java/tel/schich/libdatachannel/SctpSettings.java @@ -4,7 +4,8 @@ * Process-wide SCTP tuning, applied with {@link LibDataChannel#setSctpSettings(SctpSettings)}. *

* Fields left at 0 keep libdatachannel's default. A negative {@code maxBurst} or {@code delayedSackTimeMs} - * disables that mechanism, and {@code congestionControlModule} keeps the default at -1. + * disables that mechanism, and {@code congestionControlModule} keeps the default at -1. {@code cwndBasedMaxBurst} + * keeps usrsctp's default (on) at 0. * * @see Documentation */ @@ -13,7 +14,7 @@ public final class SctpSettings { final int recvBufferSize, sendBufferSize, maxChunksOnQueue, initialCongestionWindow, maxBurst, congestionControlModule, delayedSackTimeMs, minRetransmitTimeoutMs, maxRetransmitTimeoutMs, - initialRetransmitTimeoutMs, maxRetransmitAttempts, heartbeatIntervalMs; + initialRetransmitTimeoutMs, maxRetransmitAttempts, heartbeatIntervalMs, cwndBasedMaxBurst; private SctpSettings(Builder b) { this.recvBufferSize = b.recvBufferSize; @@ -28,6 +29,7 @@ private SctpSettings(Builder b) { this.initialRetransmitTimeoutMs = b.initialRetransmitTimeoutMs; this.maxRetransmitAttempts = b.maxRetransmitAttempts; this.heartbeatIntervalMs = b.heartbeatIntervalMs; + this.cwndBasedMaxBurst = b.cwndBasedMaxBurst; } public static Builder builder() { @@ -42,13 +44,13 @@ public String toString() { ", delayedSackTimeMs=" + delayedSackTimeMs + ", minRetransmitTimeoutMs=" + minRetransmitTimeoutMs + ", maxRetransmitTimeoutMs=" + maxRetransmitTimeoutMs + ", initialRetransmitTimeoutMs=" + initialRetransmitTimeoutMs + ", maxRetransmitAttempts=" + maxRetransmitAttempts + - ", heartbeatIntervalMs=" + heartbeatIntervalMs + "}"; + ", heartbeatIntervalMs=" + heartbeatIntervalMs + ", cwndBasedMaxBurst=" + cwndBasedMaxBurst + "}"; } public static final class Builder { private int recvBufferSize, sendBufferSize, maxChunksOnQueue, initialCongestionWindow, maxBurst, delayedSackTimeMs, minRetransmitTimeoutMs, maxRetransmitTimeoutMs, initialRetransmitTimeoutMs, - maxRetransmitAttempts, heartbeatIntervalMs; + maxRetransmitAttempts, heartbeatIntervalMs, cwndBasedMaxBurst; private int congestionControlModule = -1; private Builder() { @@ -135,6 +137,16 @@ public Builder heartbeatIntervalMs(int millis) { return this; } + /** + * Whether max burst shrinks the congestion window to what is in flight plus {@link #maxBurst} MTUs whenever the + * sender has less in flight than the window allows, as usrsctp does by default. Light traffic then pins the + * window at max burst MTUs going into every burst after it; with false, max burst only limits each burst. + */ + public Builder cwndBasedMaxBurst(boolean enabled) { + this.cwndBasedMaxBurst = enabled ? 1 : -1; + return this; + } + public SctpSettings build() { return new SctpSettings(this); }