Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BBR initial_window config #14

Merged
merged 5 commits into from
Sep 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 37 additions & 28 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions tuic-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,10 @@ replace <tag> with [current version tag](https://github.com/Itsusinn/tuic/pkgs/c
// Default: 1500
"max_external_packet_size": 1500,

// Optional. Sets the initial congestion window size in bytes for the BBR algorithm, which may improve burst performance but could lead to congestion under high concurrency.
// Default: None
"initial_window": 1048576,

// Optional. Maximum number of bytes to transmit to a peer without acknowledgment
// Should be set to at least the expected connection latency multiplied by the maximum desired throughput
// Default: 8MiB * 2
Expand Down
7 changes: 7 additions & 0 deletions tuic-server/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ pub struct Config {
#[serde(default = "default::max_external_packet_size")]
pub max_external_packet_size: usize,

#[serde(default = "default::initial_window")]
pub initial_window: Option<u64>,

#[serde(default = "default::send_window")]
pub send_window: u64,

Expand Down Expand Up @@ -191,6 +194,10 @@ mod default {
1500
}

pub fn initial_window() -> Option<u64> {
None
}

pub fn send_window() -> u64 {
8 * 1024 * 1024 * 2
}
Expand Down
13 changes: 12 additions & 1 deletion tuic-server/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,16 @@ impl Server {
));
let mut tp_cfg = TransportConfig::default();

fn create_bbr_with_initial_window(initial_window: Option<u64>) -> BbrConfig {
let mut bbr_config = BbrConfig::default();

if let Some(window) = initial_window {
bbr_config.initial_window(window);
}

bbr_config
}

tp_cfg
.max_concurrent_bidi_streams(VarInt::from(DEFAULT_CONCURRENT_STREAMS))
.max_concurrent_uni_streams(VarInt::from(DEFAULT_CONCURRENT_STREAMS))
Expand All @@ -91,7 +101,8 @@ impl Server {
tp_cfg.congestion_controller_factory(Arc::new(NewRenoConfig::default()))
}
CongestionControl::Bbr => {
tp_cfg.congestion_controller_factory(Arc::new(BbrConfig::default()))
let bbr_config = create_bbr_with_initial_window(cfg.initial_window);
tp_cfg.congestion_controller_factory(Arc::new(bbr_config))
}
};

Expand Down