From 5a24ca432923183a48586c8170e7ae2d018e2d00 Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 1 Dec 2026 09:22:22 +0000 Subject: [PATCH 1/2] Sync jni/libdatachannel to opencollab-incubator/libdatachannel@1fe8a38 Brings in opencollab-incubator/libdatachannel#7's per-association SCTP recovery counters, with opencollab-incubator/usrsctp#2 and #3 counting them, and #8's configurable Data Channel DSCP. The DSCP fields sit in rtcConfiguration ahead of iceUdpMuxDirect; native_peer.cpp zero-initialises the struct and sets fields by name, so peers keep AF11 until a setting exposes it. --- jni/libdatachannel | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jni/libdatachannel b/jni/libdatachannel index 0b15881..1fe8a38 160000 --- a/jni/libdatachannel +++ b/jni/libdatachannel @@ -1 +1 @@ -Subproject commit 0b158812cfbd9676e7cf4a63452e0e13f305997e +Subproject commit 1fe8a3886661d8a87036a1e90098dc765d201c7d From bb0b3184ca856467357fa8dc1939f5675830196b Mon Sep 17 00:00:00 2001 From: Shane Freeder Date: Tue, 1 Dec 2026 09:22:23 +0000 Subject: [PATCH 2/2] Expose how the SCTP association recovered its data SctpStats gains fastRetransmits(), retransmittedChunks(), gapSacks() and duplicateTsnsReceived(): an association's own fast retransmits, DATA chunks sent again, SACKs that reported gaps and duplicate DATA received, which together with dataTimeouts() say how its data is being recovered. --- jni/src/native_peer.cpp | 4 ++- .../tel/schich/libdatachannel/SctpStats.java | 30 +++++++++++++++---- 2 files changed, 28 insertions(+), 6 deletions(-) diff --git a/jni/src/native_peer.cpp b/jni/src/native_peer.cpp index aff5e96..1e106c6 100644 --- a/jni/src/native_peer.cpp +++ b/jni/src/native_peer.cpp @@ -370,7 +370,9 @@ JNIEXPORT jobject JNICALL Java_tel_schich_libdatachannel_LibDataChannelNative_rt static_cast(stats.congestionWindow), static_cast(stats.peerReceiveWindow), static_cast(stats.unackedChunks), static_cast(stats.pendingChunks), static_cast(stats.dataTimeouts), static_cast(stats.sendQueueBytes), - static_cast(stats.sendBufferSize), static_cast(stats.receiveQueueBytes)); + static_cast(stats.sendBufferSize), static_cast(stats.receiveQueueBytes), + static_cast(stats.fastRetransmits), static_cast(stats.retransmittedChunks), + static_cast(stats.gapSacks), static_cast(stats.duplicateTsnsReceived)); } JNIEXPORT jint JNICALL Java_tel_schich_libdatachannel_LibDataChannelNative_rtcSetLocalDescriptionWithIce( diff --git a/src/main/java/tel/schich/libdatachannel/SctpStats.java b/src/main/java/tel/schich/libdatachannel/SctpStats.java index 920609e..7d35d09 100644 --- a/src/main/java/tel/schich/libdatachannel/SctpStats.java +++ b/src/main/java/tel/schich/libdatachannel/SctpStats.java @@ -8,11 +8,13 @@ public final class SctpStats { private final Duration rtt, rto; private final long congestionWindow, peerReceiveWindow, unackedChunks, pendingChunks, dataTimeouts, - sendQueueBytes, sendBufferSize, receiveQueueBytes; + sendQueueBytes, sendBufferSize, receiveQueueBytes, fastRetransmits, retransmittedChunks, gapSacks, + duplicateTsnsReceived; private SctpStats(Duration rtt, Duration rto, long congestionWindow, long peerReceiveWindow, long unackedChunks, long pendingChunks, long dataTimeouts, long sendQueueBytes, - long sendBufferSize, long receiveQueueBytes) { + long sendBufferSize, long receiveQueueBytes, long fastRetransmits, + long retransmittedChunks, long gapSacks, long duplicateTsnsReceived) { this.rtt = rtt; this.rto = rto; this.congestionWindow = congestionWindow; @@ -23,15 +25,20 @@ private SctpStats(Duration rtt, Duration rto, long congestionWindow, long peerRe this.sendQueueBytes = sendQueueBytes; this.sendBufferSize = sendBufferSize; this.receiveQueueBytes = receiveQueueBytes; + this.fastRetransmits = fastRetransmits; + this.retransmittedChunks = retransmittedChunks; + this.gapSacks = gapSacks; + this.duplicateTsnsReceived = duplicateTsnsReceived; } @JNIAccess static SctpStats create(int rttMillis, int rtoMillis, long congestionWindow, long peerReceiveWindow, long unackedChunks, long pendingChunks, long dataTimeouts, long sendQueueBytes, - long sendBufferSize, long receiveQueueBytes) { + long sendBufferSize, long receiveQueueBytes, long fastRetransmits, + long retransmittedChunks, long gapSacks, long duplicateTsnsReceived) { return new SctpStats(Duration.ofMillis(rttMillis), Duration.ofMillis(rtoMillis), congestionWindow, peerReceiveWindow, unackedChunks, pendingChunks, dataTimeouts, sendQueueBytes, sendBufferSize, - receiveQueueBytes); + receiveQueueBytes, fastRetransmits, retransmittedChunks, gapSacks, duplicateTsnsReceived); } /** Smoothed round trip time in whole milliseconds, zero until sampled or while under one. */ @@ -54,12 +61,25 @@ static SctpStats create(int rttMillis, int rtoMillis, long congestionWindow, lon public long sendBufferSize() { return sendBufferSize; } /** Received bytes waiting for reassembly or ordering. */ public long receiveQueueBytes() { return receiveQueueBytes; } + /** + * Packets sent by fast retransmit, after the peer reported gaps. Each halves the congestion window, so where + * these run ahead of what the path lost, the peer is reporting gaps for data that arrived. + */ + public long fastRetransmits() { return fastRetransmits; } + /** DATA chunks sent again, by fast retransmit or after a retransmission timeout. */ + public long retransmittedChunks() { return retransmittedChunks; } + /** SACKs received that reported gaps in what the peer had. */ + public long gapSacks() { return gapSacks; } + /** DATA chunks received that had arrived already, so the peer resent what it need not have. */ + public long duplicateTsnsReceived() { return duplicateTsnsReceived; } @Override public String toString() { return "SctpStats{rtt=" + rtt.toMillis() + "ms, rto=" + rto.toMillis() + "ms, congestionWindow=" + congestionWindow + ", peerReceiveWindow=" + peerReceiveWindow + ", unackedChunks=" + unackedChunks + ", pendingChunks=" + pendingChunks + ", dataTimeouts=" + dataTimeouts + ", sendQueueBytes=" + - sendQueueBytes + ", sendBufferSize=" + sendBufferSize + ", receiveQueueBytes=" + receiveQueueBytes + "}"; + sendQueueBytes + ", sendBufferSize=" + sendBufferSize + ", receiveQueueBytes=" + receiveQueueBytes + + ", fastRetransmits=" + fastRetransmits + ", retransmittedChunks=" + retransmittedChunks + ", gapSacks=" + + gapSacks + ", duplicateTsnsReceived=" + duplicateTsnsReceived + "}"; } }