Skip to content

Commit

Permalink
Add config API for copa algorithm (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
iyangsj authored Sep 3, 2024
1 parent 9766b2d commit 3a8fbb1
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 4 deletions.
15 changes: 15 additions & 0 deletions include/tquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,21 @@ void quic_config_set_bbr_rtprop_filter_len(struct quic_config_t *config, uint64_
*/
void quic_config_set_bbr_probe_bw_cwnd_gain(struct quic_config_t *config, double v);

/**
* Set the delta in copa slow start state.
*/
void quic_config_set_copa_slow_start_delta(struct quic_config_t *config, double v);

/**
* Set the delta in coap steady state.
*/
void quic_config_set_copa_steady_delta(struct quic_config_t *config, double v);

/**
* Enable Using the rtt standing instead of the latest rtt to calculate queueing delay.
*/
void quic_config_enable_copa_use_standing_rtt(struct quic_config_t *config, bool v);

/**
* Set the initial RTT in milliseconds. The default value is 333ms.
* The configuration should be changed with caution. Setting a value less than the default
Expand Down
1 change: 1 addition & 0 deletions src/congestion_control/congestion_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ pub use bbr3::Bbr3;
pub use bbr3::Bbr3Config;
pub use copa::Copa;
pub use copa::CopaConfig;
pub use copa::COPA_DELTA;
pub use cubic::Cubic;
pub use cubic::CubicConfig;
pub use dummy::Dummy;
Expand Down
8 changes: 4 additions & 4 deletions src/congestion_control/copa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ use crate::connection::space::SentPacket;
use crate::RecoveryConfig;

/// Delta: determines how much to weigh delay compared to throughput.
const COPA_DELTA: f64 = 0.04;
pub const COPA_DELTA: f64 = 0.04;

/// Max count while cwnd grows with the same direction. Speed up if
/// the count exceeds threshold.
Expand Down Expand Up @@ -100,9 +100,9 @@ impl CopaConfig {
initial_cwnd,
initial_rtt,
max_datagram_size,
slow_start_delta: COPA_DELTA,
steady_delta: COPA_DELTA,
use_standing_rtt: true,
slow_start_delta: conf.copa_slow_start_delta,
steady_delta: conf.copa_steady_delta,
use_standing_rtt: conf.copa_use_standing_rtt,
}
}
}
Expand Down
18 changes: 18 additions & 0 deletions src/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,24 @@ pub extern "C" fn quic_config_set_bbr_probe_bw_cwnd_gain(config: &mut Config, v:
config.set_bbr_probe_bw_cwnd_gain(v);
}

/// Set the delta in copa slow start state.
#[no_mangle]
pub extern "C" fn quic_config_set_copa_slow_start_delta(config: &mut Config, v: f64) {
config.set_copa_slow_start_delta(v);
}

/// Set the delta in coap steady state.
#[no_mangle]
pub extern "C" fn quic_config_set_copa_steady_delta(config: &mut Config, v: f64) {
config.set_copa_steady_delta(v);
}

/// Enable Using the rtt standing instead of the latest rtt to calculate queueing delay.
#[no_mangle]
pub extern "C" fn quic_config_enable_copa_use_standing_rtt(config: &mut Config, v: bool) {
config.enable_copa_use_standing_rtt(v);
}

/// Set the initial RTT in milliseconds. The default value is 333ms.
/// The configuration should be changed with caution. Setting a value less than the default
/// will cause retransmission of handshake packets to be more aggressive.
Expand Down
27 changes: 27 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,21 @@ impl Config {
self.recovery.bbr_probe_bw_cwnd_gain = v;
}

/// Set the delta in copa slow start state.
pub fn set_copa_slow_start_delta(&mut self, v: f64) {
self.recovery.copa_slow_start_delta = v;
}

/// Set the delta in coap steady state.
pub fn set_copa_steady_delta(&mut self, v: f64) {
self.recovery.copa_steady_delta = v;
}

/// Enable Using the rtt standing instead of the latest rtt to calculate queueing delay.
pub fn enable_copa_use_standing_rtt(&mut self, v: bool) {
self.recovery.copa_use_standing_rtt = v;
}

/// Set the initial RTT in milliseconds. The default value is 333ms.
///
/// The configuration should be changed with caution. Setting a value less than the default
Expand Down Expand Up @@ -796,6 +811,15 @@ pub struct RecoveryConfig {
/// The cwnd gain for ProbeBW state
pub bbr_probe_bw_cwnd_gain: f64,

/// Delta in copa slow start state.
pub copa_slow_start_delta: f64,

/// Delta in coap steady state.
pub copa_steady_delta: f64,

/// Use rtt standing instead of latest rtt to calculate queueing delay
pub copa_use_standing_rtt: bool,

/// The initial rtt, used before real rtt is estimated.
pub initial_rtt: Duration,

Expand Down Expand Up @@ -827,6 +851,9 @@ impl Default for RecoveryConfig {
bbr_probe_rtt_cwnd_gain: 0.75,
bbr_rtprop_filter_len: Duration::from_secs(10),
bbr_probe_bw_cwnd_gain: 2.0,
copa_slow_start_delta: congestion_control::COPA_DELTA,
copa_steady_delta: congestion_control::COPA_DELTA,
copa_use_standing_rtt: true,
initial_rtt: INITIAL_RTT,
enable_pacing: true,
pacing_granularity: time::Duration::from_millis(1),
Expand Down

0 comments on commit 3a8fbb1

Please sign in to comment.