dcsctp: Add metric for using message interleaving
There was also some refactoring to create the TCB at the same time,
to ensure the metric is always set.
Bug: webrtc:13052, webrtc:5696
Change-Id: I5557ad5f0fc4a0520de1eaaafa15459b3200c4f5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/262259
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#37388}
diff --git a/net/dcsctp/public/dcsctp_socket.h b/net/dcsctp/public/dcsctp_socket.h
index 0a65dae..770c674 100644
--- a/net/dcsctp/public/dcsctp_socket.h
+++ b/net/dcsctp/public/dcsctp_socket.h
@@ -235,6 +235,10 @@
// explicitly signalled during the connection establishment, heuristics is
// used to analyze e.g. the state cookie in the INIT-ACK chunk.
SctpImplementation peer_implementation = SctpImplementation::kUnknown;
+
+ // Indicates if RFC8260 User Message Interleaving has been negotiated by both
+ // peers.
+ bool uses_message_interleaving = false;
};
// Callbacks that the DcSctpSocket will call synchronously to the owning
diff --git a/net/dcsctp/socket/dcsctp_socket.cc b/net/dcsctp/socket/dcsctp_socket.cc
index 421b3bf..9287b86 100644
--- a/net/dcsctp/socket/dcsctp_socket.cc
+++ b/net/dcsctp/socket/dcsctp_socket.cc
@@ -314,6 +314,7 @@
TSN peer_initial_tsn,
size_t a_rwnd,
TieTag tie_tag) {
+ metrics_.uses_message_interleaving = capabilities.message_interleaving;
tcb_ = std::make_unique<TransmissionControlBlock>(
timer_manager_, log_prefix_, options_, capabilities, callbacks_,
send_queue_, my_verification_tag, my_initial_tsn, peer_verification_tag,
diff --git a/net/dcsctp/socket/dcsctp_socket_test.cc b/net/dcsctp/socket/dcsctp_socket_test.cc
index e70378f..f4b0b2c 100644
--- a/net/dcsctp/socket/dcsctp_socket_test.cc
+++ b/net/dcsctp/socket/dcsctp_socket_test.cc
@@ -1892,6 +1892,22 @@
EXPECT_FALSE(a.socket.GetMetrics().has_value());
}
+TEST(DcSctpSocketTest, MessageInterleavingMetricsAreSet) {
+ std::vector<std::pair<bool, bool>> combinations = {
+ {false, false}, {false, true}, {true, false}, {true, true}};
+ for (const auto& [a_enable, z_enable] : combinations) {
+ DcSctpOptions a_options = {.enable_message_interleaving = a_enable};
+ DcSctpOptions z_options = {.enable_message_interleaving = z_enable};
+
+ SocketUnderTest a("A", a_options);
+ SocketUnderTest z("Z", z_options);
+ ConnectSockets(a, z);
+
+ EXPECT_EQ(a.socket.GetMetrics()->uses_message_interleaving,
+ a_enable && z_enable);
+ }
+}
+
TEST(DcSctpSocketTest, RxAndTxPacketMetricsIncrease) {
SocketUnderTest a("A");
SocketUnderTest z("Z");