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

update to 0.5.0 and fix probe rtt #7

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/home/frank?

slog = "2"
slog-async = "2"
slog-term = "2"
Expand Down
2 changes: 1 addition & 1 deletion src/bin/bbr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ fn main() {
.map_err(|e| warn!(log, "bad argument"; "err" => ?e))
.unwrap();

info!(log, "configured BBR";
info!(log, "configured BBR";
"ipc" => ipc.clone(),
"probe_rtt_interval" => ?cfg.probe_rtt_interval,
);
Expand Down
75 changes: 62 additions & 13 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Copy link
Member

Choose a reason for hiding this comment

The 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>,
Expand All @@ -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>,
Expand Down Expand Up @@ -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
Expand All @@ -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)
)
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand Down