Skip to content
Merged
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
4 changes: 3 additions & 1 deletion jni/src/util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
}
5 changes: 3 additions & 2 deletions src/main/java/tel/schich/libdatachannel/LibDataChannel.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,16 @@ 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,
int initialCongestionWindow, int maxBurst,
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.
Expand Down
20 changes: 16 additions & 4 deletions src/main/java/tel/schich/libdatachannel/SctpSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
* Process-wide SCTP tuning, applied with {@link LibDataChannel#setSctpSettings(SctpSettings)}.
* <p>
* 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 <a href="https://github.com/paullouisageneau/libdatachannel/blob/master/DOC.md#rtcsetsctpsettings">Documentation</a>
*/
Expand All @@ -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;
Expand All @@ -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() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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);
}
Expand Down
Loading