rwebtransport 0.1.0 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Cargo.lock +666 -666
- package/Cargo.toml +31 -31
- package/LICENSE +202 -202
- package/NOTICE +41 -41
- package/README.md +550 -550
- package/crates/echo-server/Cargo.toml +20 -20
- package/crates/echo-server/src/main.rs +666 -666
- package/crates/native/Cargo.toml +23 -23
- package/crates/native/src/config.rs +129 -129
- package/crates/native/src/driver.rs +463 -463
- package/crates/native/src/lib.rs +821 -821
- package/crates/native/src/server.rs +718 -718
- package/crates/native/src/session.rs +1191 -1191
- package/crates/native/src/tls.rs +96 -96
- package/crates/wtcore/Cargo.toml +15 -15
- package/crates/wtcore/src/h3.rs +226 -226
- package/crates/wtcore/src/lib.rs +9 -9
- package/dist/index.js.map +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +80 -79
- package/prebuilds/darwin-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-arm64/rwebtransport.node +0 -0
- package/prebuilds/linux-x64/rwebtransport.node +0 -0
- package/prebuilds/win32-x64/rwebtransport.node +0 -0
- package/scripts/bench.mjs +180 -180
- package/scripts/build.js +67 -67
- package/scripts/postinstall.js +67 -67
- package/scripts/setup-unix.sh +129 -129
- package/scripts/setup-windows.ps1 +229 -229
- package/vendor/quiche/AGENTS.md +75 -75
- package/vendor/quiche/COPYING +23 -23
- package/vendor/quiche/Cargo.lock +1212 -1212
- package/vendor/quiche/Cargo.toml +215 -215
- package/vendor/quiche/README.md +466 -466
- package/vendor/quiche/examples/Makefile +46 -46
- package/vendor/quiche/examples/README.md +20 -20
- package/vendor/quiche/examples/cert-big.crt +90 -90
- package/vendor/quiche/examples/cert.crt +18 -18
- package/vendor/quiche/examples/cert.key +28 -28
- package/vendor/quiche/examples/client.c +343 -343
- package/vendor/quiche/examples/client.rs +281 -281
- package/vendor/quiche/examples/gen-certs.sh +15 -15
- package/vendor/quiche/examples/http3-client.c +473 -473
- package/vendor/quiche/examples/http3-client.rs +349 -349
- package/vendor/quiche/examples/http3-server.c +614 -614
- package/vendor/quiche/examples/http3-server.rs +680 -680
- package/vendor/quiche/examples/qpack-decode.rs +87 -87
- package/vendor/quiche/examples/qpack-encode.rs +88 -88
- package/vendor/quiche/examples/rootca.crt +21 -21
- package/vendor/quiche/examples/server.c +529 -529
- package/vendor/quiche/examples/server.rs +529 -529
- package/vendor/quiche/include/quiche.h +1282 -1282
- package/vendor/quiche/src/buffers.rs +105 -105
- package/vendor/quiche/src/build.rs +66 -66
- package/vendor/quiche/src/cid.rs +1079 -1079
- package/vendor/quiche/src/crypto/boringssl.rs +373 -373
- package/vendor/quiche/src/crypto/mod.rs +671 -671
- package/vendor/quiche/src/dgram.rs +118 -118
- package/vendor/quiche/src/error.rs +263 -263
- package/vendor/quiche/src/ffi.rs +2290 -2290
- package/vendor/quiche/src/flowcontrol.rs +246 -246
- package/vendor/quiche/src/frame.rs +2172 -2172
- package/vendor/quiche/src/h3/AGENTS.md +54 -54
- package/vendor/quiche/src/h3/ffi.rs +442 -442
- package/vendor/quiche/src/h3/frame.rs +1404 -1404
- package/vendor/quiche/src/h3/mod.rs +8223 -8223
- package/vendor/quiche/src/h3/qpack/decoder.rs +288 -288
- package/vendor/quiche/src/h3/qpack/encoder.rs +235 -235
- package/vendor/quiche/src/h3/qpack/mod.rs +202 -202
- package/vendor/quiche/src/h3/qpack/static_table.rs +323 -323
- package/vendor/quiche/src/h3/stream.rs +1595 -1595
- package/vendor/quiche/src/lib.rs +9556 -9556
- package/vendor/quiche/src/minmax.rs +446 -446
- package/vendor/quiche/src/packet.rs +2334 -2334
- package/vendor/quiche/src/path.rs +1374 -1374
- package/vendor/quiche/src/pmtud.rs +652 -652
- package/vendor/quiche/src/rand.rs +64 -64
- package/vendor/quiche/src/range_buf.rs +186 -186
- package/vendor/quiche/src/ranges.rs +755 -755
- package/vendor/quiche/src/recovery/AGENTS.md +80 -80
- package/vendor/quiche/src/recovery/bandwidth.rs +565 -565
- package/vendor/quiche/src/recovery/bytes_in_flight.rs +179 -179
- package/vendor/quiche/src/recovery/congestion/cubic.rs +1038 -1038
- package/vendor/quiche/src/recovery/congestion/delivery_rate.rs +514 -514
- package/vendor/quiche/src/recovery/congestion/hystart.rs +241 -241
- package/vendor/quiche/src/recovery/congestion/mod.rs +361 -361
- package/vendor/quiche/src/recovery/congestion/prr.rs +238 -238
- package/vendor/quiche/src/recovery/congestion/recovery.rs +1170 -1170
- package/vendor/quiche/src/recovery/congestion/reno.rs +291 -291
- package/vendor/quiche/src/recovery/congestion/test_sender.rs +201 -201
- package/vendor/quiche/src/recovery/gcongestion/bbr/bandwidth_sampler.rs +1947 -1947
- package/vendor/quiche/src/recovery/gcongestion/bbr/windowed_filter.rs +158 -158
- package/vendor/quiche/src/recovery/gcongestion/bbr.rs +37 -37
- package/vendor/quiche/src/recovery/gcongestion/bbr2/drain.rs +120 -120
- package/vendor/quiche/src/recovery/gcongestion/bbr2/mode.rs +318 -318
- package/vendor/quiche/src/recovery/gcongestion/bbr2/network_model.rs +784 -784
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_bw.rs +729 -729
- package/vendor/quiche/src/recovery/gcongestion/bbr2/probe_rtt.rs +175 -175
- package/vendor/quiche/src/recovery/gcongestion/bbr2/startup.rs +190 -190
- package/vendor/quiche/src/recovery/gcongestion/bbr2.rs +855 -855
- package/vendor/quiche/src/recovery/gcongestion/mod.rs +275 -275
- package/vendor/quiche/src/recovery/gcongestion/pacer.rs +294 -294
- package/vendor/quiche/src/recovery/gcongestion/recovery.rs +1384 -1384
- package/vendor/quiche/src/recovery/mod.rs +3086 -3086
- package/vendor/quiche/src/recovery/rtt.rs +152 -152
- package/vendor/quiche/src/stream/mod.rs +2210 -2210
- package/vendor/quiche/src/stream/recv_buf.rs +1236 -1236
- package/vendor/quiche/src/stream/send_buf.rs +849 -849
- package/vendor/quiche/src/test_utils.rs +681 -681
- package/vendor/quiche/src/tests.rs +12922 -12922
- package/vendor/quiche/src/tls/boringssl.rs +375 -375
- package/vendor/quiche/src/tls/mod.rs +1245 -1245
- package/vendor/quiche/src/transport_params.rs +628 -628
|
@@ -1,152 +1,152 @@
|
|
|
1
|
-
// Copyright (C) 2024, Cloudflare, Inc.
|
|
2
|
-
// All rights reserved.
|
|
3
|
-
//
|
|
4
|
-
// Redistribution and use in source and binary forms, with or without
|
|
5
|
-
// modification, are permitted provided that the following conditions are
|
|
6
|
-
// met:
|
|
7
|
-
//
|
|
8
|
-
// * Redistributions of source code must retain the above copyright notice,
|
|
9
|
-
// this list of conditions and the following disclaimer.
|
|
10
|
-
//
|
|
11
|
-
// * Redistributions in binary form must reproduce the above copyright
|
|
12
|
-
// notice, this list of conditions and the following disclaimer in the
|
|
13
|
-
// documentation and/or other materials provided with the distribution.
|
|
14
|
-
//
|
|
15
|
-
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
16
|
-
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
-
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
-
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
-
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
-
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
-
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
22
|
-
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
-
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
-
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
-
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
-
|
|
27
|
-
use std::time::Duration;
|
|
28
|
-
use std::time::Instant;
|
|
29
|
-
|
|
30
|
-
use crate::minmax::Minmax;
|
|
31
|
-
use crate::recovery::GRANULARITY;
|
|
32
|
-
|
|
33
|
-
pub(crate) const RTT_WINDOW: Duration = Duration::from_secs(300);
|
|
34
|
-
|
|
35
|
-
pub struct RttStats {
|
|
36
|
-
pub(super) latest_rtt: Duration,
|
|
37
|
-
|
|
38
|
-
max_rtt: Duration,
|
|
39
|
-
|
|
40
|
-
pub(super) smoothed_rtt: Duration,
|
|
41
|
-
|
|
42
|
-
pub(super) rttvar: Duration,
|
|
43
|
-
|
|
44
|
-
pub(super) min_rtt: Minmax<Duration>,
|
|
45
|
-
|
|
46
|
-
pub(super) max_ack_delay: Duration,
|
|
47
|
-
|
|
48
|
-
pub(super) has_first_rtt_sample: bool,
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
impl std::fmt::Debug for RttStats {
|
|
52
|
-
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
53
|
-
f.debug_struct("RttStats")
|
|
54
|
-
.field("lastest_rtt", &self.latest_rtt)
|
|
55
|
-
.field("srtt", &self.smoothed_rtt)
|
|
56
|
-
.field("minrtt", &*self.min_rtt)
|
|
57
|
-
.field("rttvar", &self.rttvar)
|
|
58
|
-
.finish()
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
impl RttStats {
|
|
63
|
-
pub(crate) fn new(initial_rtt: Duration, max_ack_delay: Duration) -> Self {
|
|
64
|
-
RttStats {
|
|
65
|
-
latest_rtt: Duration::ZERO,
|
|
66
|
-
min_rtt: Minmax::new(initial_rtt),
|
|
67
|
-
smoothed_rtt: initial_rtt,
|
|
68
|
-
max_rtt: initial_rtt,
|
|
69
|
-
rttvar: initial_rtt / 2,
|
|
70
|
-
has_first_rtt_sample: false,
|
|
71
|
-
max_ack_delay,
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
pub(crate) fn update_rtt(
|
|
76
|
-
&mut self, latest_rtt: Duration, mut ack_delay: Duration, now: Instant,
|
|
77
|
-
handshake_confirmed: bool,
|
|
78
|
-
) {
|
|
79
|
-
self.latest_rtt = latest_rtt;
|
|
80
|
-
|
|
81
|
-
if !self.has_first_rtt_sample {
|
|
82
|
-
self.min_rtt.reset(now, latest_rtt);
|
|
83
|
-
self.smoothed_rtt = latest_rtt;
|
|
84
|
-
self.max_rtt = latest_rtt;
|
|
85
|
-
self.rttvar = latest_rtt / 2;
|
|
86
|
-
self.has_first_rtt_sample = true;
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// min_rtt ignores acknowledgment delay.
|
|
91
|
-
self.min_rtt.running_min(RTT_WINDOW, now, latest_rtt);
|
|
92
|
-
|
|
93
|
-
self.max_rtt = self.max_rtt.max(latest_rtt);
|
|
94
|
-
|
|
95
|
-
// Limit ack_delay by max_ack_delay after handshake confirmation.
|
|
96
|
-
if handshake_confirmed {
|
|
97
|
-
ack_delay = ack_delay.min(self.max_ack_delay);
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Adjust for acknowledgment delay if plausible.
|
|
101
|
-
let mut adjusted_rtt = latest_rtt;
|
|
102
|
-
if latest_rtt >= *self.min_rtt + ack_delay {
|
|
103
|
-
adjusted_rtt = latest_rtt - ack_delay;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
self.rttvar = self.rttvar * 3 / 4 +
|
|
107
|
-
Duration::from_nanos(
|
|
108
|
-
self.smoothed_rtt
|
|
109
|
-
.as_nanos()
|
|
110
|
-
.abs_diff(adjusted_rtt.as_nanos()) as u64 /
|
|
111
|
-
4,
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
self.smoothed_rtt = self.smoothed_rtt * 7 / 8 + adjusted_rtt / 8;
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
pub(crate) fn rtt(&self) -> Duration {
|
|
118
|
-
self.smoothed_rtt
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
#[allow(dead_code)]
|
|
122
|
-
pub(crate) fn latest_rtt(&self) -> Duration {
|
|
123
|
-
self.latest_rtt
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
pub(crate) fn rttvar(&self) -> Duration {
|
|
127
|
-
self.rttvar
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
pub(crate) fn min_rtt(&self) -> Option<Duration> {
|
|
131
|
-
if self.has_first_rtt_sample {
|
|
132
|
-
Some(*self.min_rtt)
|
|
133
|
-
} else {
|
|
134
|
-
None
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
pub(crate) fn max_rtt(&self) -> Option<Duration> {
|
|
139
|
-
if self.has_first_rtt_sample {
|
|
140
|
-
Some(self.max_rtt)
|
|
141
|
-
} else {
|
|
142
|
-
None
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
pub(crate) fn loss_delay(&self, time_thresh: f64) -> Duration {
|
|
147
|
-
self.latest_rtt
|
|
148
|
-
.max(self.smoothed_rtt)
|
|
149
|
-
.mul_f64(time_thresh)
|
|
150
|
-
.max(GRANULARITY)
|
|
151
|
-
}
|
|
152
|
-
}
|
|
1
|
+
// Copyright (C) 2024, Cloudflare, Inc.
|
|
2
|
+
// All rights reserved.
|
|
3
|
+
//
|
|
4
|
+
// Redistribution and use in source and binary forms, with or without
|
|
5
|
+
// modification, are permitted provided that the following conditions are
|
|
6
|
+
// met:
|
|
7
|
+
//
|
|
8
|
+
// * Redistributions of source code must retain the above copyright notice,
|
|
9
|
+
// this list of conditions and the following disclaimer.
|
|
10
|
+
//
|
|
11
|
+
// * Redistributions in binary form must reproduce the above copyright
|
|
12
|
+
// notice, this list of conditions and the following disclaimer in the
|
|
13
|
+
// documentation and/or other materials provided with the distribution.
|
|
14
|
+
//
|
|
15
|
+
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
16
|
+
// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
17
|
+
// THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
18
|
+
// PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
|
|
19
|
+
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
20
|
+
// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
21
|
+
// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
22
|
+
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
23
|
+
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
24
|
+
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
25
|
+
// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
26
|
+
|
|
27
|
+
use std::time::Duration;
|
|
28
|
+
use std::time::Instant;
|
|
29
|
+
|
|
30
|
+
use crate::minmax::Minmax;
|
|
31
|
+
use crate::recovery::GRANULARITY;
|
|
32
|
+
|
|
33
|
+
pub(crate) const RTT_WINDOW: Duration = Duration::from_secs(300);
|
|
34
|
+
|
|
35
|
+
pub struct RttStats {
|
|
36
|
+
pub(super) latest_rtt: Duration,
|
|
37
|
+
|
|
38
|
+
max_rtt: Duration,
|
|
39
|
+
|
|
40
|
+
pub(super) smoothed_rtt: Duration,
|
|
41
|
+
|
|
42
|
+
pub(super) rttvar: Duration,
|
|
43
|
+
|
|
44
|
+
pub(super) min_rtt: Minmax<Duration>,
|
|
45
|
+
|
|
46
|
+
pub(super) max_ack_delay: Duration,
|
|
47
|
+
|
|
48
|
+
pub(super) has_first_rtt_sample: bool,
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
impl std::fmt::Debug for RttStats {
|
|
52
|
+
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
|
|
53
|
+
f.debug_struct("RttStats")
|
|
54
|
+
.field("lastest_rtt", &self.latest_rtt)
|
|
55
|
+
.field("srtt", &self.smoothed_rtt)
|
|
56
|
+
.field("minrtt", &*self.min_rtt)
|
|
57
|
+
.field("rttvar", &self.rttvar)
|
|
58
|
+
.finish()
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
impl RttStats {
|
|
63
|
+
pub(crate) fn new(initial_rtt: Duration, max_ack_delay: Duration) -> Self {
|
|
64
|
+
RttStats {
|
|
65
|
+
latest_rtt: Duration::ZERO,
|
|
66
|
+
min_rtt: Minmax::new(initial_rtt),
|
|
67
|
+
smoothed_rtt: initial_rtt,
|
|
68
|
+
max_rtt: initial_rtt,
|
|
69
|
+
rttvar: initial_rtt / 2,
|
|
70
|
+
has_first_rtt_sample: false,
|
|
71
|
+
max_ack_delay,
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
pub(crate) fn update_rtt(
|
|
76
|
+
&mut self, latest_rtt: Duration, mut ack_delay: Duration, now: Instant,
|
|
77
|
+
handshake_confirmed: bool,
|
|
78
|
+
) {
|
|
79
|
+
self.latest_rtt = latest_rtt;
|
|
80
|
+
|
|
81
|
+
if !self.has_first_rtt_sample {
|
|
82
|
+
self.min_rtt.reset(now, latest_rtt);
|
|
83
|
+
self.smoothed_rtt = latest_rtt;
|
|
84
|
+
self.max_rtt = latest_rtt;
|
|
85
|
+
self.rttvar = latest_rtt / 2;
|
|
86
|
+
self.has_first_rtt_sample = true;
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
// min_rtt ignores acknowledgment delay.
|
|
91
|
+
self.min_rtt.running_min(RTT_WINDOW, now, latest_rtt);
|
|
92
|
+
|
|
93
|
+
self.max_rtt = self.max_rtt.max(latest_rtt);
|
|
94
|
+
|
|
95
|
+
// Limit ack_delay by max_ack_delay after handshake confirmation.
|
|
96
|
+
if handshake_confirmed {
|
|
97
|
+
ack_delay = ack_delay.min(self.max_ack_delay);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// Adjust for acknowledgment delay if plausible.
|
|
101
|
+
let mut adjusted_rtt = latest_rtt;
|
|
102
|
+
if latest_rtt >= *self.min_rtt + ack_delay {
|
|
103
|
+
adjusted_rtt = latest_rtt - ack_delay;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
self.rttvar = self.rttvar * 3 / 4 +
|
|
107
|
+
Duration::from_nanos(
|
|
108
|
+
self.smoothed_rtt
|
|
109
|
+
.as_nanos()
|
|
110
|
+
.abs_diff(adjusted_rtt.as_nanos()) as u64 /
|
|
111
|
+
4,
|
|
112
|
+
);
|
|
113
|
+
|
|
114
|
+
self.smoothed_rtt = self.smoothed_rtt * 7 / 8 + adjusted_rtt / 8;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
pub(crate) fn rtt(&self) -> Duration {
|
|
118
|
+
self.smoothed_rtt
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
#[allow(dead_code)]
|
|
122
|
+
pub(crate) fn latest_rtt(&self) -> Duration {
|
|
123
|
+
self.latest_rtt
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
pub(crate) fn rttvar(&self) -> Duration {
|
|
127
|
+
self.rttvar
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
pub(crate) fn min_rtt(&self) -> Option<Duration> {
|
|
131
|
+
if self.has_first_rtt_sample {
|
|
132
|
+
Some(*self.min_rtt)
|
|
133
|
+
} else {
|
|
134
|
+
None
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
pub(crate) fn max_rtt(&self) -> Option<Duration> {
|
|
139
|
+
if self.has_first_rtt_sample {
|
|
140
|
+
Some(self.max_rtt)
|
|
141
|
+
} else {
|
|
142
|
+
None
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
pub(crate) fn loss_delay(&self, time_thresh: f64) -> Duration {
|
|
147
|
+
self.latest_rtt
|
|
148
|
+
.max(self.smoothed_rtt)
|
|
149
|
+
.mul_f64(time_thresh)
|
|
150
|
+
.max(GRANULARITY)
|
|
151
|
+
}
|
|
152
|
+
}
|