pub trait CongAlg<I: Ipc> {
type Flow: Flow;
fn name() -> &'static str;
fn datapath_programs(&self) -> HashMap<&'static str, String>;
fn new_flow(&self, control: Datapath<I>, info: DatapathInfo) -> Self::Flow;
}
Expand description
Implement this trait and portus::Flow
to define a CCP congestion control algorithm.
Instances of this type implement functionality which applies to a given
algorithm as a whole.
Required Associated Types§
sourcetype Flow: Flow
type Flow: Flow
A type which implements the portus::Flow
trait, to manage
an individual connection.
Required Methods§
sourcefn datapath_programs(&self) -> HashMap<&'static str, String>
fn datapath_programs(&self) -> HashMap<&'static str, String>
datapath_programs
returns all datapath programs the congestion control algorithm
will to use during its execution. It is called once, when Portus initializes
(portus::run
or portus::spawn
).
It should return a vector of string tuples, where the first string in each tuple is a unique name identifying the program, and the second string is the code for the program itself.
The Portus runtime will panic if any of the datapath programs do not compile.
For example,
extern crate fnv;
use fnv::FnvHashMap as HashMap;
let mut h = HashMap::default();
h.insert("prog1", "...(program)...".to_string());
h.insert("prog2", "...(program)...".to_string());
sourcefn new_flow(&self, control: Datapath<I>, info: DatapathInfo) -> Self::Flow
fn new_flow(&self, control: Datapath<I>, info: DatapathInfo) -> Self::Flow
Create a new instance of the CongAlg to manage a new flow.
Optionally copy any configuration parameters from &self
.