v2: every SCTP-signaling engine reads the server's SCTP timer overrides

network_sctp_t1_init_ms / _t1_cookie_ms / _max_backoff_ms were read only by
InstanceV2Impl and InstanceV2CompatImpl. InstanceV2ReferenceImpl (11.0.0) and
CallCoreHost (18.0.0/19.0.0) built their SignalingSctpConnection with the
defaults whatever the server sent. All four now take their options from
SignalingSctpConnection::Options::fromCustomParameters, which replaces the two
copies of the reading code. The defaults (400/400/750 ms) are unchanged, and
the timers are local, so no wire or interop change.

Each connection logs the values it runs with
("SignalingSctpConnection: initiator, t1_init 400 ms, ..."), so a call log
shows whether an override arrived.

Measured with the CLI, 5 s fixed signaling delay, both sides asking for
1500/1500/3000 ms: the caller's INIT retries reach the callee 1.50 s then
3.00 s apart on 11, 13, 14, 18 and 19 (before: 0.41, 0.75, 0.75 s on 11, 18
and 19). Without overrides all five keep 0.40 s, then every 0.75 s. Plain calls
connect on every version and 18/19 -> 11; run-negotiation-tests.sh passes;
run-parity-tests.sh audio-loss30 at 13.0.0 connects 96 of 96 with audio both
ways in every pairing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
isaacandClaude Opus 5.5 committed 2026-10-27 22:12:51 +04:00
1 parent c839645dd1
commit 8d5e7e0947
6 files changed
+32 -26

No files matched your search

+1 -12
View File
@@ -431,17 +431,6 @@ public:
// (both ends get the same custom parameters, and a 13.0.0 peer under
// nosctp never answers an SCTP INIT); V1 and V2 always bare.
if (_signalingProtocolVersion == SignalingProtocolVersion::V3 && !getCustomParameterBool(_customParameters, "network_signaling_nosctp")) {
SignalingSctpConnection::Options sctpOptions;
if (int v = getCustomParameterInt(_customParameters, "network_sctp_t1_init_ms")) {
sctpOptions.t1InitTimeoutMs = v;
}
if (int v = getCustomParameterInt(_customParameters, "network_sctp_t1_cookie_ms")) {
sctpOptions.t1CookieTimeoutMs = v;
}
if (int v = getCustomParameterInt(_customParameters, "network_sctp_max_backoff_ms")) {
sctpOptions.maxBackoffMs = v;
}
_signalingConnection = std::make_unique<SignalingSctpConnection>(
_threads,
[threads = _threads, weak](const std::vector<uint8_t> &data) {
@@ -458,7 +447,7 @@ public:
signalingDataEmitted(data);
},
_encryptionKey.isOutgoing,
sctpOptions
SignalingSctpConnection::Options::fromCustomParameters(_customParameters)
);
}
if (!_signalingConnection) {
+1 -12
View File
@@ -981,17 +981,6 @@ public:
const auto weak = std::weak_ptr<InstanceV2ImplInternal>(shared_from_this());
if (_signalingProtocolVersion == SignalingProtocolVersion::V3 && !getCustomParameterBool(_customParameters, "network_signaling_nosctp")) {
SignalingSctpConnection::Options sctpOptions;
if (int v = getCustomParameterInt(_customParameters, "network_sctp_t1_init_ms")) {
sctpOptions.t1InitTimeoutMs = v;
}
if (int v = getCustomParameterInt(_customParameters, "network_sctp_t1_cookie_ms")) {
sctpOptions.t1CookieTimeoutMs = v;
}
if (int v = getCustomParameterInt(_customParameters, "network_sctp_max_backoff_ms")) {
sctpOptions.maxBackoffMs = v;
}
_signalingConnection = std::make_shared<SignalingSctpConnection>(
_threads,
[threads = _threads, weak](const std::vector<uint8_t> &data) {
@@ -1008,7 +997,7 @@ public:
signalingDataEmitted(data);
},
_encryptionKey.isOutgoing,
sctpOptions
SignalingSctpConnection::Options::fromCustomParameters(_customParameters)
);
}
if (!_signalingConnection) {
+2 -1
View File
@@ -471,7 +471,8 @@ public:
[signalingDataEmitted = _signalingDataEmitted](const std::vector<uint8_t> &data) {
signalingDataEmitted(data);
},
_encryptionKey.isOutgoing
_encryptionKey.isOutgoing,
SignalingSctpConnection::Options::fromCustomParameters(_customParameters)
);
}
if (!_signalingConnection) {
+17
View File
@@ -13,9 +13,24 @@
#include "system_wrappers/include/clock.h"
#include "FieldTrialsConfig.h"
#include "v2/CustomParameters.h"
namespace tgcalls {
SignalingSctpConnection::Options SignalingSctpConnection::Options::fromCustomParameters(std::map<std::string, json11::Json> const &customParameters) {
Options options;
if (int v = getCustomParameterInt(customParameters, "network_sctp_t1_init_ms")) {
options.t1InitTimeoutMs = v;
}
if (int v = getCustomParameterInt(customParameters, "network_sctp_t1_cookie_ms")) {
options.t1CookieTimeoutMs = v;
}
if (int v = getCustomParameterInt(customParameters, "network_sctp_max_backoff_ms")) {
options.maxBackoffMs = v;
}
return options;
}
// Factory that creates CustomDcSctpSocket (with the t1 timer backoff cap fix)
// instead of the stock DcSctpSocket, with optional timer overrides for the
// signaling channel.
@@ -131,6 +146,8 @@ SignalingSctpConnection::SignalingSctpConnection(std::shared_ptr<Threads> thread
_threads(threads),
_emitData(emitData),
_onIncomingData(onIncomingData) {
RTC_LOG(LS_INFO) << "SignalingSctpConnection: " << (isInitiator ? "initiator" : "responder") << ", t1_init " << options.t1InitTimeoutMs << " ms, t1_cookie " << options.t1CookieTimeoutMs << " ms, max backoff " << options.maxBackoffMs << " ms";
_threads->getNetworkThread()->BlockingCall([&]() {
_packetTransport = std::make_unique<SignalingPacketTransport>(threads, emitData, /*writable=*/isInitiator);
+9
View File
@@ -12,12 +12,15 @@
#include "rtc_base/byte_buffer.h"
#include "media/base/media_channel.h"
#include <map>
#include <string>
#include <vector>
#include <absl/types/optional.h>
#include "StaticThreads.h"
#include "SignalingConnection.h"
#include "third-party/json11.hpp"
namespace rtc {
class Socket;
@@ -49,6 +52,12 @@ public:
int t1CookieTimeoutMs; // 0 = use default
int maxBackoffMs; // 0 = use default
Options() : t1InitTimeoutMs(400), t1CookieTimeoutMs(400), maxBackoffMs(750) {}
// The defaults above with the server's overrides applied
// (network_sctp_t1_init_ms, network_sctp_t1_cookie_ms,
// network_sctp_max_backoff_ms; absent or 0 keeps the default). Every
// engine that carries its signaling over SCTP builds its options here.
static Options fromCustomParameters(std::map<std::string, json11::Json> const &customParameters);
};
SignalingSctpConnection(std::shared_ptr<Threads> threads, std::function<void(const std::vector<uint8_t> &)> onIncomingData, std::function<void(const std::vector<uint8_t> &)> emitData, bool isInitiator, Options options = Options());
+2 -1
View File
@@ -556,7 +556,8 @@ void CallCoreHost::start() {
[signalingDataEmitted = _signalingDataEmitted](const std::vector<uint8_t> &data) {
signalingDataEmitted(data);
},
_encryptionKey.isOutgoing
_encryptionKey.isOutgoing,
SignalingSctpConnection::Options::fromCustomParameters(_parsedCustomParameters)
);
} else {
_signalingConnection = std::make_unique<ExternalSignalingConnection>(