Crate portus[][src]

Welcome to CCP.

This crate, portus, implements a CCP. This includes:

  1. An interface definition for external types wishing to implement congestion control algorithms (CongAlg).
  2. A compiler for datapath programs.
  3. An IPC and serialization layer for communicating with libccp-compliant datapaths.

The entry points into portus are run and spawn, which start the CCP algorithm runtime. This runtime listens for datapath messages and dispatches calls to the appropriate congestion control methods.

Example

The following congestion control algorithm sets the congestion window to 42, and prints the minimum RTT observed over 42 millisecond intervals.

extern crate portus;
use portus::{CongAlg, Config, Datapath, DatapathInfo, DatapathTrait, Report};
use portus::ipc::Ipc;
use portus::lang::Scope;

struct MyCongestionControlAlgorithm(Scope);
#[derive(Clone)]
struct MyEmptyConfig;

impl<T: Ipc> CongAlg<T> for MyCongestionControlAlgorithm {
    type Config = MyEmptyConfig;
    fn name() -> String {
        String::from("My congestion control algorithm")
    }
    fn create(control: Datapath<T>, cfg: Config<T, Self>, info: DatapathInfo) -> Self {
        let sc = control.install(b"
            (def (Report
                (volatile minrtt +infinity)
            ))
            (when true
                (:= Report.minrtt (min Report.minrtt Flow.rtt_sample_us))
            )
            (when (> Micros 42000)
                (report)
                (reset)
            )
        ", None).unwrap();
        MyCongestionControlAlgorithm(sc)
    }
    fn on_report(&mut self, sock_id: u32, m: Report) {
        println!("minrtt: {:?}", m.get_field("Report.minrtt", &self.0).unwrap());
    }
}

Modules

algs

Helper methods for making algorithm binaries.

ipc

A library wrapping various IPC mechanisms with a datagram-oriented messaging layer. This is how CCP communicates with the datapath.

lang

The datapath program compiler.

serialize

Serialization library for communicating with libccp in the datapath.

test_helper

Helper type for writing unit tests.

Macros

check_msg

Generates a test which serializes and deserializes a message and verifies the message is unchanged.

Structs

CCPHandle

A handle to manage running instances of the CCP execution loop.

Config

Defines a slog::Logger to use for (optional) logging and a custom CongAlg::Config to pass into algorithms as new flows are created.

Datapath

A collection of methods to interact with the datapath.

DatapathInfo

The set of information passed by the datapath to CCP when a connection starts. It includes a unique 5-tuple (CCP socket id + source and destination IP and port), the initial congestion window (init_cwnd), and flow MSS.

Error

CCP custom error type.

FieldNotFoundError
InvalidRegTypeError
InvalidReportError
Report

Contains the values of the pre-defined Report struct from the fold function. Use get_field to query its values using the names defined in the fold function.

StaleProgramError

Traits

CongAlg

Implement this trait to define a CCP congestion control algorithm.

DatapathTrait

A collection of methods to interact with the datapath.

Functions

run

Main execution loop of CCP for the static pipeline use case. The run method blocks 'forever'; it only returns in two cases:

spawn

Spawn a thread which will perform the CCP execution loop. Returns a CCPHandle, which the caller can use to cause the execution loop to stop. The run method blocks 'forever'; it only returns in three cases:

Type Definitions

Result

CCP custom Result type, using Error as the Err type.