-
Notifications
You must be signed in to change notification settings - Fork 2
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
update to 0.5.0 and fix probe rtt #7
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ authors = ["Akshay Narayan <[email protected]>"] | |
[dependencies] | ||
clap = "2.29" | ||
fnv = "1" | ||
portus = "^0.4.1" | ||
portus = { path = "/home/frank/portus" } | ||
portus_export = { path = "/home/frank/portus/portus_export" } | ||
slog = "2" | ||
slog-async = "2" | ||
slog-term = "2" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,13 +45,15 @@ | |
extern crate slog; | ||
extern crate fnv; | ||
extern crate portus; | ||
extern crate portus_export; | ||
extern crate time; | ||
extern crate clap; | ||
|
||
use portus::ipc::Ipc; | ||
use portus::lang::Scope; | ||
use portus::{CongAlg, Datapath, DatapathInfo, DatapathTrait, Report}; | ||
use portus::{CongAlg, CongAlgBuilder, Datapath, DatapathInfo, DatapathTrait, Report}; | ||
|
||
use fnv::FnvHashMap; | ||
use std::collections::HashMap; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make this a different commit? |
||
|
||
pub struct Bbr<T: Ipc> { | ||
control_channel: Datapath<T>, | ||
|
@@ -75,6 +77,7 @@ enum BbrMode { | |
|
||
pub const PROBE_RTT_INTERVAL_SECONDS: i64 = 10; | ||
|
||
#[portus_export::register_ccp_alg] | ||
#[derive(Clone)] | ||
pub struct BbrConfig { | ||
pub logger: Option<slog::Logger>, | ||
|
@@ -169,14 +172,53 @@ impl<T: Ipc> Bbr<T> { | |
} | ||
} | ||
|
||
use clap::Arg; | ||
impl<'a,'b> CongAlgBuilder<'a,'b> for BbrConfig { | ||
fn args() -> clap::App<'a,'b> { | ||
clap::App::new("CCP BBR") | ||
.version("0.2.1") | ||
.author("CCP Project <[email protected]>") | ||
.about("Implementation of BBR Congestion Control") | ||
.arg(Arg::with_name("probe_rtt_interval") | ||
.long("probe_rtt_interval") | ||
.help("Sets the BBR probe RTT interval in seconds, after which BBR drops its congestion window to potentially observe a new minimum RTT.") | ||
.default_value("10")) | ||
.arg(Arg::with_name("verbose") | ||
.short("v") | ||
.help("If provided, log internal BBR state")) | ||
} | ||
fn with_arg_matches(args: &clap::ArgMatches, logger: Option<slog::Logger>) -> Result<Self, portus::Error> { | ||
let probe_rtt_interval = time::Duration::seconds( | ||
i64::from_str_radix(args.value_of("probe_rtt_interval").unwrap(), 10) | ||
.map_err(|e| format!("{:?}", e)) | ||
.and_then(|probe_rtt_interval_arg| { | ||
if probe_rtt_interval_arg <= 0 { | ||
Err(format!( | ||
"probe_rtt_interval must be positive: {}", | ||
probe_rtt_interval_arg | ||
)) | ||
} else { | ||
Ok(probe_rtt_interval_arg) | ||
} | ||
}).map_err(|e| portus::Error(e))?, | ||
); | ||
Ok( | ||
Self { | ||
logger: logger, | ||
probe_rtt_interval | ||
} | ||
) | ||
} | ||
} | ||
|
||
impl<T: Ipc> CongAlg<T> for BbrConfig { | ||
type Flow = Bbr<T>; | ||
|
||
fn name() -> &'static str { | ||
"bbr" | ||
} | ||
|
||
fn datapath_programs(&self) -> FnvHashMap<&'static str, String> { | ||
fn datapath_programs(&self) -> HashMap<&'static str, String> { | ||
vec![ | ||
("init_program", String::from(" | ||
(def | ||
|
@@ -199,16 +241,23 @@ impl<T: Ipc> CongAlg<T> for BbrConfig { | |
) | ||
")), | ||
("probe_rtt", String::from(" | ||
(def | ||
(Report (volatile minrtt +infinity)) | ||
) | ||
(when true | ||
(:= Report.minrtt (min Report.minrtt Flow.rtt_sample_us)) | ||
(fallthrough) | ||
) | ||
(when (&& (> Micros 200000) (|| (< Flow.packets_in_flight 4) (== Flow.packets_in_flight 4))) | ||
(report) | ||
) | ||
(def | ||
(Report (volatile minrtt +infinity)) | ||
(target_inflight_reached false) | ||
) | ||
(when true | ||
(:= Report.minrtt (min Report.minrtt Flow.rtt_sample_us)) | ||
(fallthrough) | ||
) | ||
(when (&& (== target_inflight_reached false) | ||
(|| (< Flow.packets_in_flight 4) (== Flow.packets_in_flight 4))) | ||
(:= target_inflight_reached true) | ||
(:= Micros 0) | ||
) | ||
(when (&& (== target_inflight_reached true) | ||
(&& (> Micros Flow.rtt_sample_us) (> Micros 200000)) | ||
(report) | ||
) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think about moving these datapath programs to separate files ("*.ccp"), and using https://doc.rust-lang.org/std/macro.include_str.html? |
||
")), | ||
("probe_bw", String::from(" | ||
(def | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/home/frank
?