Skip to content

Commit 28be735

Browse files
committed
Switch BBR RNG to PCG
1 parent 7ba2a76 commit 28be735

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

quinn-proto/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ lru-slab = { workspace = true }
5050
qlog = { workspace = true, optional = true }
5151
rustc-hash = { workspace = true }
5252
rand = { workspace = true }
53+
rand_pcg = "0.10"
5354
ring = { workspace = true, optional = true }
5455
rustls = { workspace = true, optional = true }
5556
rustls-platform-verifier = { workspace = true, optional = true }
@@ -69,7 +70,6 @@ web-time = { workspace = true }
6970
[dev-dependencies]
7071
assert_matches = { workspace = true }
7172
hex-literal = { workspace = true }
72-
rand_pcg = "0.10"
7373
rcgen = { workspace = true }
7474
tracing-subscriber = { workspace = true }
7575
wasm-bindgen-test = { workspace = true }

quinn-proto/src/congestion/bbr/mod.rs

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,13 @@ use std::any::Any;
22
use std::fmt::Debug;
33
use std::sync::Arc;
44

5-
use rand::rngs::{StdRng, SysRng};
6-
use rand::{Rng, RngExt, SeedableRng};
5+
use rand::{RngExt, SeedableRng};
6+
use rand_pcg::Pcg32;
77

88
use crate::congestion::ControllerMetrics;
99
use crate::congestion::bbr::bw_estimation::BandwidthEstimation;
1010
use crate::congestion::bbr::min_max::MinMax;
1111
use crate::connection::RttEstimator;
12-
use crate::endpoint::NoRandomBytes;
1312
use crate::{Duration, Instant};
1413

1514
use super::{BASE_DATAGRAM_SIZE, Controller, ControllerFactory};
@@ -58,14 +57,14 @@ pub struct Bbr {
5857
bw_at_last_round: u64,
5958
round_wo_bw_gain: u64,
6059
ack_aggregation: AckAggregationState,
61-
random_number_generator: StdRng,
60+
random_number_generator: Pcg32,
6261
}
6362

6463
impl Bbr {
6564
/// Construct a state using the given `config` and current time `now`
66-
pub fn new(config: Arc<BbrConfig>, current_mtu: u16) -> Result<Self, NoRandomBytes> {
65+
pub fn new(config: Arc<BbrConfig>, current_mtu: u16) -> Self {
6766
let initial_window = config.initial_window;
68-
Ok(Self {
67+
Self {
6968
config,
7069
current_mtu: current_mtu as u64,
7170
max_bandwidth: BandwidthEstimation::default(),
@@ -99,8 +98,8 @@ impl Bbr {
9998
bw_at_last_round: 0,
10099
round_wo_bw_gain: 0,
101100
ack_aggregation: AckAggregationState::default(),
102-
random_number_generator: StdRng::try_from_rng(&mut SysRng)?,
103-
})
101+
random_number_generator: Pcg32::from_rng(&mut rand::rng()),
102+
}
104103
}
105104

106105
fn enter_startup_mode(&mut self) {

0 commit comments

Comments
 (0)