Trait CongestionControlAlgorithm

Source
pub(crate) trait CongestionControlAlgorithm: Send + Debug {
    // Required methods
    fn uses_stream_sendme(&self) -> bool;
    fn is_next_cell_sendme(&self) -> bool;
    fn can_send(&self) -> bool;
    fn cwnd(&self) -> Option<&CongestionWindow>;
    fn data_received(&mut self) -> Result<bool>;
    fn data_sent(&mut self) -> Result<()>;
    fn sendme_received(
        &mut self,
        state: &mut State,
        rtt: &mut RoundtripTimeEstimator,
        signals: CongestionSignals,
    ) -> Result<()>;
    fn sendme_sent(&mut self) -> Result<()>;
    fn inflight(&self) -> Option<u32>;
}
Expand description

This trait defines what a congestion control algorithm must implement in order to interface with the circuit reactor.

Note that all functions informing the algorithm, as in not getters, return a Result meaning that on error, it means we can’t recover or that there is a protocol violation. In both cases, the circuit MUST be closed.

Required Methods§

Source

fn uses_stream_sendme(&self) -> bool

Return true iff this algorithm uses stream level SENDMEs.

Source

fn is_next_cell_sendme(&self) -> bool

Return true iff the next cell is expected to be a SENDME.

Source

fn can_send(&self) -> bool

Return true iff a cell can be sent on the wire according to the congestion control algorithm.

Source

fn cwnd(&self) -> Option<&CongestionWindow>

Return the congestion window object. The reason is returns an Option is because not all algorithm uses one and so we avoid acting on it if so.

Source

fn data_received(&mut self) -> Result<bool>

Inform the algorithm that we just got a DATA cell.

Return true if a SENDME should be sent immediately or false if not.

Source

fn data_sent(&mut self) -> Result<()>

Inform the algorithm that we just sent a DATA cell.

Source

fn sendme_received( &mut self, state: &mut State, rtt: &mut RoundtripTimeEstimator, signals: CongestionSignals, ) -> Result<()>

Inform the algorithm that we’ve just received a SENDME.

This is a core function because the algorithm massively update its state when receiving a SENDME by using the RTT value and congestion signals.

Source

fn sendme_sent(&mut self) -> Result<()>

Inform the algorithm that we just sent a SENDME.

Source

fn inflight(&self) -> Option<u32>

Available on crate feature conflux only.

Return the number of in-flight cells (sent but awaiting SENDME ack).

Optional, because not all algorithms track this.

Implementors§