Commit graph

167 commits

Author SHA1 Message Date
Florent Castelli
8d4e9fba21 Remove //api:sequence_checker from public deps
Bug: webrtc:8603
Change-Id: Ib572cdc5b5f4c1f0eb3357e5e0812fc9ce7437c4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257915
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36465}
2022-04-06 14:23:50 +00:00
Florent Castelli
dd837e28fa Remove //rtc_base:timeutils from public deps
Bug: webrtc:8603
Change-Id: Iaca9356d16275a02e8842c783f259131d72ef010
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257914
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36460}
2022-04-06 11:23:21 +00:00
Florent Castelli
57aa81bce7 Remove //rtc_base:stringutils from public deps
Bug: webrtc:8603
Change-Id: Ic2dfbe28d310cb4b35983b73e895fc95e8439669
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257913
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36453}
2022-04-05 22:42:19 +00:00
Florent Castelli
f86f6f9afd Remove //rtc_base:refcount from public deps
Bug: webrtc:8603
Change-Id: Ib27a107ae809df739492846175f0e9c4af40d21a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257910
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36447}
2022-04-05 15:32:29 +00:00
Florent Castelli
0af55ba60d Remove //rtc_base:logging from public deps
Bug: webrtc:8603
Change-Id: I2704da8618f88032adac7ae9eb2a0f47fce4a836
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257908
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36443}
2022-04-05 10:31:19 +00:00
Florent Castelli
e17d111f4a dcsctp: Remove dependency on //rtc_base
It's not used and pulls a lot of dependencies.

Bug: None
Change-Id: I8fd41b1f5793b281fddb83891d63b6e3eca5235f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257902
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36426}
2022-04-04 13:28:06 +00:00
Victor Boivie
f9e116f46e dcsctp: Continue reset pending streams
When resetting several streams in sequence, only the first stream will
be included in the first RE_CONFIG chunk as it's created eagerly
whenever someone calls ResetStreams. The remaining ones are queued as
pending. When the first request finishes, the remaining ones should
continue to be processed, but this wasn't done prior to this commit.

This would only happen if two streams would be reset with shorter time
between them than a RTT, so that there would be an outstanding request
forcing the second reset to be enqueued.

Bug: chromium:1312009
Change-Id: Id74b375d1d1720406a3bca4ec60df5780ca7edba
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257306
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36404}
2022-04-01 06:35:46 +00:00
Victor Boivie
8beccd5c47 dcsctp: Remove limit of message fragmentation
This was available in the beginning, as a way to increase the chance of
a message sent with partial reliability to be delivered, by avoiding it
to be fragmented in too small fragments.

This however added a few downsides:
 * Packet efficiency goes down, as the entire MTU isn't always used
 * Complexity increases when adding message interleaving, since if one
   stream refuses to produce messages, but there is another stream with
   a very small message that could fit in its place, it should be used
   instead.

Removing this feature altogether is much easier. It's hard to defend.

Bug: webrtc:5696
Change-Id: Ie2f296e052f4a32a281497d379c0d528a2df3308
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257168
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36396}
2022-03-31 13:47:46 +00:00
Victor Boivie
fbf0ac0ecd dcsctp: Clarify current behavior of stream reset
RFC8831, section 6.7 states that closing a data channel MUST be signaled
as resetting an outgoing stream, and that will ensure that all messages
are either delivered or abandoned before the stream is reset. In the
current implementation, dcSCTP has opted to abandoned any queued
messages that haven't been partially sent.

And this CL simply adds more documentation around this choice. It's
subject to change and a client implementation shouldn't depend on any
such behavior as the RFC allows the implementation to decide.

Bug: None
Change-Id: I60305fe396a6a3f494d823c71e092acfeb6075b7
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257167
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36395}
2022-03-31 13:36:12 +00:00
Victor Boivie
0cfaa610ca dcsctp: Add test case for pending paused streams
This use case was missing test coverage and sufficient comments in the
code.

Bug: None
Change-Id: I95b54a64f714b68a347fdbeef79eb38e715adbc3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/257166
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36393}
2022-03-31 12:20:43 +00:00
Victor Boivie
568bc23208 dcsctp: Don't reassemble already received chunks
This is a solution to some problems that have been found locally when
running the fuzzer for a long time. The fuzzer keeps on fuzzing, and has
found a way to trigger a consistency check to fail when a client
intentionally sends different messages - unordered and ordered - using
the same TSNs. As the reassembly queue has different handling of ordered
and unordered chunks due to how they are reassembled, it will not notice
if it receives two different chunks with the same TSN. They will both go
to their respective reassembly streams, as those are separate by design.

The data tracker - which keeps track of all received DATA chunks as it
needs to generate SACKs, has a global understanding of all received
chunks. By having it indicate if this is a duplicate received chunk, the
socket can avoid forwarding both chunks to the reassembly queue; only
one chunk will get there.

Bug: None
Change-Id: I602a8552a9a4c853684fcf105309ec3d8073f2c2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/256110
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36316}
2022-03-24 10:39:03 +00:00
Victor Boivie
9848890590 dcsctp: Remove handover_state from RRSendQueue
It's not used as a constructor parameter, but instead invoked by calling
RestoreFromState. Removing this parameter avoids confusion.

Bug: None
Change-Id: I3bb8a0135808e3ae010be6d37439513517f71832
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254820
Auto-Submit: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Sergey Sukhanov <sergeysu@webrtc.org>
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36188}
2022-03-14 12:19:56 +00:00
Victor Boivie
584b4df92d dcsctp: Don't deliver skipped messages
If a FORWARD-TSN contains an ordered skipped stream with a large TSN
but with a too small SSN, it can result in messages being assembled
that should've been skipped. Typically:

Receive DATA, ordered, complete, TSN=10, SID=1, SSN=0
  - will be delivered.
Receive DATA, ordered, complete, TSN=43, SID=1, SSN=7
  - will stay in queue, due to missing SSN=1,2,3,4,5,6.
Receive FORWARD-TSN, TSN=44, SSN=6
  - is invalid, as the SSN should've been 7 or higher.

However, as the TSN isn't used for removing messages in ordered streams,
but just the SSN, the SSN=7 isn't removed but instead will be delivered
as it's the next following SSN after 6. This will trigger internal
consistency checks as a chunk with TSN=43 will be delivered when the
current cumulative TSN is set to 44, which is greater.

This was found when fuzzing, and can only be provoked by a client that
is intentionally misbehaving. Before this fix, there was no harm done,
but it failed consistency checks which fuzzers have enabled. When
bug 13799 was fixed (in a previous commit), this allowed the fuzzers to
find it faster.

Bug: webrtc:13799
Change-Id: I830ef189476e227e1dbe08157d34f96ad6453e30
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/254240
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36157}
2022-03-09 11:22:15 +00:00
Victor Boivie
a04b8b5043 dcsctp: Handle losing first DATA on ordered stream
When a FORWARD-TSN is received as the first chunk on an ordered stream,
it will fail to set the new "next expected SSN" that is present in the
FORWARD-TSN as that stream hasn't been allocated yet. It's allocated
when the first DATA is received on that stream.

This is a non-issue for ordinary data channels as the first message on
any stream will be the "Data Channel Establishment Protocol" messages,
which are always sent reliably. But if prenegotiated channels are used,
and the very first packet received on an ordered data channel is lost
_and_ signaled to the receiver as lost _before_ the receiver has
received any other fragments on that data channel, future messages will
not be delivered on that channel.

Bug: webrtc:13799
Change-Id: Ide5c656243b3a51a2ed9d76615cfc3631cfe900c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253902
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36155}
2022-03-09 10:41:32 +00:00
Victor Boivie
eee0e336a2 dcsctp: Convert socket tests not to use fixtures
Following https://abseil.io/tips/122 to make tests easier to understand
and adds a bit of flexibility to create sockets with custom parameters.
This also simplifies handover tests.

Additionally, AdvanceTime will now also run timers, as that was easily
forgotten previously.

Bug: None
Change-Id: Ieb5eece7aca51c98a7634ed1c61646383ad1712d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/253782
Reviewed-by: Sergey Sukhanov <sergeysu@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36141}
2022-03-07 12:20:40 +00:00
Florent Castelli
29ff3efebf Reland: Make dcSCTP the default SCTP implementation
To disable dcSCTP and fallback to usrsctp, you can use the field trial
WebRTC-DataChannel-Dcsctp/Disabled/

Also remove a hidden no-break space in dcSCTP logging causing issues in
some log parsing.

Bug: chromium:1243702
Change-Id: I46136a8913a6d803a3c63c710f3ed29523e4d773
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/251867
Auto-Submit: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Victor Boivie <boivie@google.com>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#36027}
2022-02-17 23:57:01 +00:00
Henrik Boström
f3a381adcd Use kHigh timer precision for 'delayed-ack' timers.
In SCTP, sending ACKs at the right time is presumably important in order
not to cause unnecessary retransmissions.

This CL sets the ACK timers to use high timer precision. This unblocks
experimentally lowering the precision of the default, "low", timers in
WebRTC.

// All bots are green, but mac_chromium_compile is randomly timing out
// independently of this CL and has been doing so for several days...
NOTRY=True

Bug: webrtc:13604
Change-Id: I1c81e3d0eeb477c3e00277d35649114c5edd249c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249090
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35813}
2022-01-27 11:09:24 +00:00
Henrik Boström
b951dc6f4c Allow specifying delayed task precision of dcsctp::Timer.
Context: The timer precision of PostDelayedTask() is about to be lowered
to include up to 17 ms leeway. In order not to break use cases that
require high precision timers, PostDelayedHighPrecisionTask() will
continue to have the same precision that PostDelayedTask() has today.
webrtc::TaskQueueBase has an enum (kLow, kHigh) to decide which
precision to use when calling PostDelayedTaskWithPrecision().

See go/postdelayedtask-precision-in-webrtc for motivation and a table of
delayed task use cases in WebRTC that are "high" or "low" precision.

Most timers in DCSCTP are believed to only be needing low precision (see
table), but the delayed_ack_timer_ of DataTracker[1] is an example of a
use case that is likely to break if the timer precision is lowered (if
ACK is sent too late, retransmissions may occur). So this is considered
a high precision use case.

This CL makes it possible to specify the precision of dcsctp::Timer.
In a follow-up CL we will update delayed_ack_timer_ to kHigh precision.

[1] https://source.chromium.org/chromium/chromium/src/+/main:third_party/webrtc/net/dcsctp/rx/data_tracker.cc;l=340

Bug: webrtc:13604
Change-Id: I8eec5ce37044096978b5dd1985fbb00bc0d8fb7e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249081
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Tomas Gunnarsson <tommi@webrtc.org>
Commit-Queue: Henrik Boström <hbos@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35809}
2022-01-26 18:40:24 +00:00
Ali Tofigh
62238097c9 Remove top-level const from parameters in function declarations.
This is a safe cleanup change since top-level const applied to
parameters in function declarations (that are not also
definitions) are ignored by the compiler. Hence, such changes do
not change the type of the declared functions and are simply
no-ops.

Bug: webrtc:13610
Change-Id: Ibafb92c45119a6d8bdb6f9109aa8dad6385163a9
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/249086
Reviewed-by: Niels Moller <nisse@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Ali Tofigh <alito@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35802}
2022-01-26 11:05:25 +00:00
Victor Boivie
29159ca979 dcsctp: Use c++17 structured bindings
As WebRTC now supports C++17, simplify the code of dcSCTP by binding
return values from std::pair or std::tuple to separate names.

Bug: webrtc:13220
Change-Id: Ie49154ff4c823e1528deaef7e372cbc550923bc2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/246442
Reviewed-by: Danil Chapovalov <danilchap@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35773}
2022-01-24 13:57:30 +00:00
Danil Chapovalov
46cc32d89f Replace ABSL_FALLTHROUGH_INTENDED with c++17 attribute
the new spelling is more standard and more compact, in particular doesn't need extra include and thus dependency

Bug: None
Change-Id: Iaea69d2154e4d9eff2468514f5734cb3fe016ff8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/245080
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Danil Chapovalov <danilchap@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35709}
2022-01-17 14:55:02 +00:00
Victor Boivie
4b7024b572 Revert "dcsctp: Use rtc::CopyOnWriteBuffer"
This reverts commit 2db59a6584.

Reason for revert: Causes msan-issue in crc32c, reading uninitialized
memory.

Bug: webrtc:12943, chromium:1275559
Change-Id: I05f1012d896aeaca86c4562e0df15fa7ea326d60
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/239560
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35461}
2021-12-02 12:33:46 +00:00
Victor Boivie
2db59a6584 dcsctp: Use rtc::CopyOnWriteBuffer
This avoids copying the payload at all. Future CL will change the
transport.

In performance tests, memcpy was visible in the performance profiles
prior to this change.

Bug: webrtc:12943
Change-Id: I507a1a316165db748e73cf0d58c1be62cc76a2d2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236346
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35428}
2021-11-29 11:53:19 +00:00
Philipp Hancke
c3a1ea1b3f dcsctp: assert that CreateTimeout returns a usable pointer
BUG=None

Change-Id: I97852d5222a4a722e61b450fbe446dd949b6840e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/238802
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35412}
2021-11-24 11:44:15 +00:00
Artem Titov
d3251968d1 Prepare to rename RTC_NOTREACHED to RTC_DCHECK_NOTREACHED
Add implementation of RTC_DCHECK_NOTREACHED equal to the RTC_NOTREACHED.
The new macros will replace the old one when old one's usage will be
removed. The idea of the renaming to provide a clear signal that this
is debug build only macros and will be stripped in the production build.

Bug: webrtc:9065
Change-Id: I4c35d8b03e74a4b3fd1ae75dba2f9c05643101db
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/237802
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Artem Titov <titovartem@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35348}
2021-11-15 21:44:59 +00:00
Victor Boivie
42a850d250 dcsctp: Use strong type for MaxRetransmits
It's put in the public folder since the intention is to expose it in
SendOptions.

Additionally, use TimeMs::InfiniteFuture() to represent sending a
message with no limited lifetime (i.e. to send it reliably).

One benefit for these two is avoiding using absl::optional more than
necessary, as it results in larger struct sizes for the outstanding
data chunks.

Bug: webrtc:12943
Change-Id: I87a340f0e0905342878fe9d2a74869bfcd6b0076
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235984
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35323}
2021-11-08 20:14:15 +00:00
Victor Boivie
71604ebf64 dcsctp: Refactor out OutstandingData
RetransmissionQueue was growing too long (almost 1000 lines), and as
there is reason to believe that more changes are necessary in it for
performance reasons, the data structure that handles managing the
in-flight outstanding data has been extracted as a separate class with
its own test cases. What remains in RetransmissionQueue is that it holds
OutstandingData, fetch data from the SendQueue and manage all congestion
control variables and algorithms.

Bug: webrtc:12943
Change-Id: I46062a774e0e76b44e36c66f836b7d992508bf5f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235980
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35279}
2021-10-29 09:03:49 +00:00
Victor Boivie
ec19d5ea79 dcsctp: Don't run network tests with TSAN or MSAN
Networks tests were previously disabled if building in debug mode as
debug mode adds DCHECKs, and when DCHECKs are enabled, a lot of the
components in dcSCTP will add consistency checks, and they can be really
expensive to run in these network tests.

However, if running in with TSAN or MSAN sanitizers and with DCHECKs
enabled, they also take a long time.

Current run-time on my relatively fast CPU (with is_debug=false):

(no sanitizer) always_dcheck=false: 2.5s
(no sanitizer) always_dcheck=true: 31s
is_tsan=true, always_dcheck=false: 53s
is_tsan=true, always_dcheck=true: 5m50s <-- too slow
is_asan=true, always_dcheck=false: 13s
is_asan=true, always_dcheck=true: 47s
is_msan=true, always_dcheck=false: 35s
is_msan=true, always_dcheck=true: 1m53s <-- too slow

Note that buildbots may be much slower than my computer.

Bug: webrtc:12943
Change-Id: If044ee9936372d54c9899b4864156c9f680af0b6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/236581
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35276}
2021-10-28 15:01:40 +00:00
Victor Boivie
7bb853f549 dcsctp: Remove debug-log-only TSN collection
A vector of which TSNs that were acked for each received SACK was
created, but only used in debug logs, which aren't enabled by default.

Removing them, as they don't add that much value and cost a bit
of performance.

Bug: webrtc:12943
Change-Id: Ice323cf46ca6e469fbbcf2a268ad67ca883bb2f5
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235985
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35265}
2021-10-26 15:11:51 +00:00
Victor Boivie
3f981ee979 dcsctp: Support zero window probing
This is explained in RFC 4960, section 6.1, A.

  ... However, regardless of the value of rwnd (including if it
  is 0), the data sender can always have one DATA chunk in flight to
  the receiver if allowed by cwnd ...  This rule
  allows the sender to probe for a change in rwnd that the sender
  missed due to the SACK's having been lost in transit from the data
  receiver to the data sender.

Before this change, when a receiver has advertised a zero receiver
window size (a_rwnd=0) and a subsequent SACK advertising a non-zero
receiver window was lost, the sender was blocked from sending and since
SACKs are only sent when a DATA chunk is received, it would be
deadlocked. The retransmission timer would fire, but nothing would be
retransmitted (as it respected the zero receiver window).

With this change, when the retransmission timer fires (after RTO), it
would send a single packet with DATA chunk(s) and then SACKs would
eventually be received, with the non-zero receiver window and the socket
would recover.

Bug: chromium:1258225
Change-Id: I1ea62fb3c002150eeada28d3e703dbc09cfd038e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/235280
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35215}
2021-10-15 09:08:24 +00:00
Victor Boivie
ab9ed5c305 dcsctp: Fixed minor typo
Bug: None
Change-Id: Icf7e9b4b004e69ecf89b9788345c72c9230dcd6f
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234586
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35193}
2021-10-13 10:28:50 +00:00
Victor Boivie
3179fb2931 dcsctp: Avoid integer overflow in HEARTBEAT-ACK v2
This is a follow-up to change 232904 that also validates that the
timestamp from the heartbeat ack isn't negative (which the fuzzer
managed to set it to).

Bug: chromium:1252515
Change-Id: Idaac570589dbdaaee67b7785f6232b60226e88e1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/234582
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35168}
2021-10-08 11:06:11 +00:00
Victor Boivie
5755f3edaf dcsctp: Add sequence checker to socket
The DcSctpSocket is not thread safe and must be called from a single
thread or from a task queue that serializes access to it. This is now
validated at run-time in debug builds.

Bug: None
Change-Id: I3ed816924c20f6ed7e84a3273bee5a3f8f74112b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233420
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35127}
2021-09-30 11:25:18 +00:00
Victor Boivie
82ccdd36aa dcsctp: Add network/throughput tests
This initial version contains a few tests, testing both lossy, non-lossy
and bandwidth limited networks. It uses simulated time, and runs much
faster than wall time on release builds, but slower on debug when there
is a lot of outstanding data (high throughput) as there are consistency
checks on outstanding data. Because of that, some tests had to be
disabled in debug build.

Bug: webrtc:12943
Change-Id: I9323f2dc99bca4e40558d05a283e99ce7dded7f1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/225201
Reviewed-by: Artem Titov <titovartem@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35124}
2021-09-30 07:59:58 +00:00
Victor Boivie
15a0c880cf dcsctp: Ensure callbacks are always triggered
The previous manual way of triggering the deferred callbacks was very
error-prone, and this was also forgotten at a few places.

We can do better.

Using the RAII programming idiom, the callbacks are now ensured to be
called before returning from public methods.

Also added additional debug checks to ensure that there is a
ScopedDeferrer active whenever callbacks are deferred.

Bug: webrtc:13217
Change-Id: I16a8343b52c00fb30acb018d3846acd0a64318e0
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233242
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35117}
2021-09-29 08:17:27 +00:00
Victor Boivie
0081f1c331 dcsctp: Refactor CallbackDeferrer
Moving the implementation to a source file.

Bug: webrtc:13217
Change-Id: I2929f4af96a9d01d3adfa49b36b021e4b229a025
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233241
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35116}
2021-09-29 07:13:57 +00:00
Victor Boivie
f4fa166cc5 dcsctp: Detect the peer SCTP implementation
It's to be used for clients to record metrics and to e.g. attribute
metrics to which SCTP implementation the peer was using.

This is not explicitly signaled, so heuristics are used. These are not
guaranteed to come to the correct conclusion, and the data is not always
available.

Note: The behavior of dcSCTP will not change depending on the assumed
implementation - only by explicitly signaled capabilities.

Bug: webrtc:13216
Change-Id: I2f58054d17d53d947ed5845df7a08f974d42f918
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/233100
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35103}
2021-09-28 05:10:45 +00:00
Victor Boivie
f75f9c2b29 dcsctp: Avoid integer overflow in HEARTBEAT-ACK
When a HEARTBEAT is sent out, the current timestamp is stored in the
parameter that will be returned by the HEARTBEAT-ACK. If the timestamp
from the HEARTBEAT-ACK would be from the future (either by jumping
clocks, bit errors, exploiting peer or a fuzzer), the measured RTT would
become really large, and when it was calculated, it would result in an
integer overflow; a wrapping subtraction.

This isn't a problem, as RetransmissionTimeout::ObserveRTT method would
discard measurements that were negative or too large, but it would
trigger an UBSAN violation.

Adding an additional check so that the subtraction doesn't ever wrap.

Bug: chromium:1252515
Change-Id: I1f97b1e773a4639b8193a528716ebd6a27fcb740
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232904
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35095}
2021-09-27 10:52:46 +00:00
Victor Boivie
adfe54c965 dcsctp: Remove the TCP style cwnd doubling
It wasn't correct and not enabled by default, so just remove it.

Bug: webrtc:12943
Change-Id: Idd426abd0da4ae259e519dd01239b4303296756a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232609
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35075}
2021-09-23 08:06:46 +00:00
Victor Boivie
d68f18ee6e dcsctp: Allow specifying minimum RTT variance
This is mentioned in
https://datatracker.ietf.org/doc/html/rfc4960#section-6.3.1 and further
described in https://datatracker.ietf.org/doc/html/rfc6298#section-4.

The TCP RFCs mentioned G as the clock granularity, but in SCTP it should
be set much higher, to account for the delayed ack timeout (ATO) of the
peer (as that can be seen as a very high clock granularity). That one is
set to 200ms by default in many clients, so a reasonable default limit
could be set to 220 ms.

If the measured variance is higher, it will be used instead.

Bug: webrtc:12943
Change-Id: Ifc217daa390850520da8b3beb0ef214181ff8c4e
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232614
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35068}
2021-09-22 20:22:54 +00:00
Victor Boivie
7d7afc6468 dcsctp: Fix accidental re-use of variable
This was caused by change 231229 and was later caught when reviewing the
code. The rtt variable was accidentally re-used for another purpose, and
then assumed to still be used to represent the rtt.

There have been no issues found with this re-use, but it was wrong.

Bug: webrtc:12614
Change-Id: If1a180315cf833e293f78c54c3c3b29394a19a20
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232610
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35064}
2021-09-22 13:27:37 +00:00
Victor Boivie
b918230640 Move StrongAlias to rtc_base
It's useful for other parts of WebRTC and there is no real reason why
it should be located in net/dcsctp.

Bug: None
Change-Id: Iccaed4e943e21ddaea8603182d693114b2da9f6b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232606
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35055}
2021-09-21 15:17:26 +00:00
Sergey Sukhanov
72435325c6 dcsctp: hand over RRSendQueue streams state
Bug: webrtc:13154
Change-Id: I560b59ad2f5bcd2deafc3a37e3af853108b572b2
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232605
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35053}
2021-09-21 12:59:46 +00:00
Sergey Sukhanov
9d2b3cb595 dcsctp: enabled handover in test SendManyFragmentedMessagesWithLimitedRtx
Bug: webrtc:13154
Change-Id: I192d5093de9b7596208d44f4868b413602db473a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232543
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35052}
2021-09-21 11:55:43 +00:00
Sergey Sukhanov
d92f8a86b3 dcsctp: move HandoverReadinessStatus::ToString definition to build target public:socket
This allows build targets that need only HandoverReadinessStatus
to depend only on public:socket, and not on socket:dcsctp_socket.

Bug: webrtc:13154
Change-Id: I29f41910cdb5baed96b57fd7284b96fc50a56ba4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232331
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35037}
2021-09-20 12:25:15 +00:00
Sergey Sukhanov
3852698ad9 dcsctp: support handover state serialization testing
dcSCTP library users can set their custom
g_handover_state_transformer_for_test that can serialize and
deserialize the state. All dcSCTP handover tests call
g_handover_state_transformer_for_test. If some part of the state is
serialized incorrectly or is forgotten, high chance that it will
fail the tests.

Bug: webrtc:13154
Change-Id: I251a099be04dda7611e9df868d36e3a76dc7d1e1
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232325
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35035}
2021-09-20 10:08:58 +00:00
Sergey Sukhanov
4397281f38 dcsctp: implement socket handover in the DcSctpSocket class and expose the functionality in the API
Bug: webrtc:13154
Change-Id: Idf4f4028c8e65943cb6b41fab0baef1b3584205d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232126
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Sergey Sukhanov <sergeysu@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35029}
2021-09-17 15:19:01 +00:00
Victor Boivie
25b5e08094 dcsctp: implement congestion control errata
When re-reading through the errata for RFC4960 in RFC8540, it was found
that two erratas were not applied to dcSCTP:

https://datatracker.ietf.org/doc/html/rfc8540#section-3.11
https://datatracker.ietf.org/doc/html/rfc8540#section-3.12

They are now applied. Re-running throughput tests show no difference.

Bug: webrtc:12943
Change-Id: I9d73d0d257eab8442954924dc414d8efa2c41e8b
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232221
Reviewed-by: Harald Alvestrand <hta@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35024}
2021-09-17 10:49:13 +00:00
Victor Boivie
80e96de5ba dcsctp: Add more consistency checks
When there is no outstanding data, then next TSN to allocate should
always be one more than what the client has last ACKed.

Bug: None
Change-Id: Ieb8b5b23912d77d96fe3749fb53fd53652d97066
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232002
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35016}
2021-09-16 13:31:51 +00:00
Victor Boivie
54e4e35c89 dcsctp: Add consistency check for assembled msgs
The buffer of reassembled messages in ReassemblyQueue is only to be
used while processing a DATA/I-DATA or FORWARD-TSN as processing these
chunks may result in assembling messages.

When the socket is idle - between API calls - it's supposed to be empty.

Instead of having it as a member in ReassemblyQueue, it could be
provided as an argument to ReassemblyQueue::Add and
ReassemblyQueue::Handle(ForwardTSN), but that would be a quite big
refactoring. That will be investigated separately.

Bug: None
Change-Id: I41238de28f32f2a622c1d045debe3ea11e7c23f6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/232000
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#35014}
2021-09-16 13:19:31 +00:00