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}
This commit is contained in:
Victor Boivie 2022-05-13 15:31:14 +02:00 committed by WebRTC LUCI CQ
parent 11174e7058
commit 5b2556e9cd
3 changed files with 21 additions and 0 deletions

View File

@ -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

View File

@ -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<TransmissionControlBlock>(
timer_manager_, log_prefix_, options_, capabilities, callbacks_,
send_queue_, my_verification_tag, my_initial_tsn, peer_verification_tag,

View File

@ -1892,6 +1892,22 @@ TEST(DcSctpSocketTest, InitialMetricsAreUnset) {
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");