Commit graph

19 commits

Author SHA1 Message Date
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
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
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
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
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
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
cebbff7f58 dcsctp: Specify the max timer backoff duration
By allowing the max timer backoff duration to be limited, a socket can
fast recover in case of intermittent network issues. Before this CL, the
exponential backoff algorithm could result in very long retry durations
(in the order of minutes), when connection has been lost or been flaky
for a long while.

Note that limiting the maximum backoff duration might require
compensating the maximum retransmission limit to avoid closing the
socket prematurely due to reaching the maximum retransmission limit much
faster than previously.

Bug: webrtc:13129
Change-Id: Ib94030d666433e3fa1a2c8ef69750a1afab8ef94
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/230702
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34913}
2021-09-03 10:26:50 +00:00
Victor Boivie
9680d29e8d dcsctp: Support unlimited max_retransmissions
The restart limit for timers can already be limitless, but the
RetransmissionErrorCounter didn't support this. With this change, the
max_retransmissions and max_init_retransmits can be absl::nullopt to
indicate that there should be infinite retries.

Bug: webrtc:13129
Change-Id: Ia6e91cccbc2e1bb77b3fdd7f37436290adc2f483
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/230701
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#34882}
2021-08-31 10:57:48 +00:00
Victor Boivie
3ec9e03f73 dcsctp: Removing all references to unordered_map
Replacing with std::map and webrtc::flat_map where applicable.

Bug: webrtc:12689
Change-Id: Id0fdb88bd3d52957b1616911eb487fc581d3b7d8
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/229182
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#34797}
2021-08-18 19:55:07 +00:00
Victor Boivie
bb7ee95c71 dcsctp: Handle starting timer from timer callback
This was caught in an integration test which had stricter assertions
than the FakeTimeout which is used in unit tests, so the first thing was
to add the same assertions to the FakeTimeout.

The issue is that when a Timer triggers, and if it's set to
automatically restart (possibly with an exponential backoff), the
`is_running_` field was set to true while the timer callback was called
to allow the client to know that the timer is in fact running, but the
timer was actually not started until the callback returned. Which made
sense, as the callback can with its return value override the duration,
which should affect the backoff algorithm.

The problem was when a timer was manually started within the callback.
As the Timer itself thought that it was already running, it first would
Stop() the underlying Timeout, then Start(). But calling Stop() on a
timeout that is not running is illegal, which set of assertions.

So the solution is to don't lie; Don't say that a timer is running when
it's not. Make sure that the timer is running when the timer callback is
triggered, which makes it consistent at all times. That may result in
unnecessary timeout invocations (stopping and starting), but that's not
too expensive.

Bug: webrtc:12614
Change-Id: I7b4447ccd88bd43d181e158f0d29b0770c8a3fd6
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217522
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33926}
2021-05-05 13:13:03 +00:00
Victor Boivie
1d2fa9a1c3 dcsctp: Expire timers just before triggering them
In real life, when a Timeout expires, the caller is supposed to call
DcSctpSocket::HandleTimeout directly, as the Timeout that just expired
is stopped (it just expired), but the Timer still believes it's running.
The system is not in a consistent state.

In tests, all timeouts were evaluated at the same time, which, if two
timeouts expired at the same time, would put them both as "not running",
and with their timers believing they were running. So if you would do
any operation on a timer whose timeout had just expired, the timeout
would assert saying that "you can't stop a stopped timeout" or similar.

This isn't relevant in non-test scenarios.

Solved by expiring timeouts one by one.

Bug: webrtc:12614
Change-Id: I79d006f4d3e96854d77cec3eb0080aa23b8569cb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217560
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33925}
2021-05-05 12:40:21 +00:00
Victor Boivie
de88b08b94 dcsctp: Add TaskQueue based timeout implementation
This is about doing the best with what we have. As delayed tasks can't
be cancelled, and dcSCTP timers will almost always be stopped or
restarted, and will generally only expire on packet loss.

This implementation will post a delayed task whenever a Timeout is
started. Whenever it's stopped or restarted, it will keep the scheduled
delay task running (there's no alternative), but it will also not start
a new delayed task on subsequent starts/restarts. Instead, it will wait
until the original delayed task has triggered, and will then - if the
timer is still running, which it probably isn't - post a new delayed
task with the remainder of the the duration.

There is special handling for when a shorter duration is requested, as
that can't re-use the scheduled task, but that shouldn't be very common.

Bug: webrtc:12614
Change-Id: I7f3269cabf84f80dae3b8a528243414a93d50fc4
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217223
Reviewed-by: Tommi <tommi@webrtc.org>
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33904}
2021-05-03 16:12:30 +00:00
Mirko Bonadei
b7854e43af Enable GN check on //net.
This should avoid the situation where WebRTC's GN check is green and
Chromium (which turns it ON for //third_party/webrtc) fails.

Bug: webrtc:12614
Change-Id: Id4c06ac57e9faa07c5e43491a61fbc093c68a40d
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217221
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Reviewed-by: Florent Castelli <orphis@webrtc.org>
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33900}
2021-05-03 14:23:09 +00:00
Florent Castelli
6072275e4a dcsctp: Add missing target dependencies
Those were found when trying to build within Chromium's codebase.

Bug: webrtc:12614
Change-Id: Ic3f7a266ad4b5d816a693645e1e909fc39d513c3
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/217220
Reviewed-by: Victor Boivie <boivie@webrtc.org>
Commit-Queue: Florent Castelli <orphis@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33896}
2021-05-03 12:19:29 +00:00
Victor Boivie
5d3bda58fd dcsctp: Add timer safeguards and sanity checks
Ensuring that timer durations never go beyond a safe maximum duration
and that timer IDs are not re-used.

Bug: webrtc:12614
Change-Id: I227a2e9933da16669dc6ea0a39c570892010ba2c
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215063
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Reviewed-by: Tommi <tommi@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33860}
2021-04-28 06:58:29 +00:00
Victor Boivie
9861f960c3 dcsctp: Add operators on TimeMs and DurationMs
To be able to use them type-safely, they should support native
operators (e.g. adding a time and a duration, or subtracting two time
values), as the alternative is to manage them as numbers.

Yes, this makes them behave a bit like absl::Time/absl::Duration.

Bug: webrtc:12614
Change-Id: I4dea12e33698a46e71fb549f44c06f2f381c9201
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/215143
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33725}
2021-04-14 09:21:15 +00:00
Victor Boivie
9d60936048 dcsctp: Fix relative dependency paths in timer/
Bug: webrtc:12614
Change-Id: I50cd2e5beae516e4a1ba47626d835eb9c80dffcb
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/214965
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33686}
2021-04-12 08:25:49 +00:00
Victor Boivie
6fa0cfa4dd dcsctp: Add Timer and TimerManager
Timer is a high-level timer (in contrast to the low-level `Timeout`
class). Timers are started and can be stopped or restarted. When a timer
expires, the provided callback will be triggered.

Timers can be configured to do e.g. exponential backoff when they expire
and how many times they should be automatically restarted.

Bug: webrtc:12614
Change-Id: Id5eddd58dd0af62184b10dd1f98e3e886e3f1d50
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/213350
Reviewed-by: Tommi <tommi@webrtc.org>
Commit-Queue: Victor Boivie <boivie@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#33666}
2021-04-09 07:48:50 +00:00