From 5b2556e9cdb3156d5c0b4a196ecf997107d22582 Mon Sep 17 00:00:00 2001 From: Victor Boivie Date: Fri, 13 May 2022 15:31:14 +0200 Subject: [PATCH] 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 Commit-Queue: Victor Boivie Cr-Commit-Position: refs/heads/main@{#37388} --- net/dcsctp/public/dcsctp_socket.h | 4 ++++ net/dcsctp/socket/dcsctp_socket.cc | 1 + net/dcsctp/socket/dcsctp_socket_test.cc | 16 ++++++++++++++++ 3 files changed, 21 insertions(+) diff --git a/net/dcsctp/public/dcsctp_socket.h b/net/dcsctp/public/dcsctp_socket.h index 0a65dae1d4..770c6746f9 100644 --- a/net/dcsctp/public/dcsctp_socket.h +++ b/net/dcsctp/public/dcsctp_socket.h @@ -235,6 +235,10 @@ struct Metrics { // 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 421b3bfea3..9287b869ac 100644 --- a/net/dcsctp/socket/dcsctp_socket.cc +++ b/net/dcsctp/socket/dcsctp_socket.cc @@ -314,6 +314,7 @@ void DcSctpSocket::CreateTransmissionControlBlock( TSN peer_initial_tsn, size_t a_rwnd, TieTag tie_tag) { + metrics_.uses_message_interleaving = capabilities.message_interleaving; tcb_ = std::make_unique( 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 e70378ffd3..f4b0b2c89f 100644 --- a/net/dcsctp/socket/dcsctp_socket_test.cc +++ b/net/dcsctp/socket/dcsctp_socket_test.cc @@ -1892,6 +1892,22 @@ TEST(DcSctpSocketTest, InitialMetricsAreUnset) { EXPECT_FALSE(a.socket.GetMetrics().has_value()); } +TEST(DcSctpSocketTest, MessageInterleavingMetricsAreSet) { + std::vector> 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");