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§
Sourcefn uses_stream_sendme(&self) -> bool
fn uses_stream_sendme(&self) -> bool
Return true iff this algorithm uses stream level SENDMEs.
Sourcefn is_next_cell_sendme(&self) -> bool
fn is_next_cell_sendme(&self) -> bool
Return true iff the next cell is expected to be a SENDME.
Sourcefn can_send(&self) -> bool
fn can_send(&self) -> bool
Return true iff a cell can be sent on the wire according to the congestion control algorithm.
Sourcefn cwnd(&self) -> Option<&CongestionWindow>
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.
Sourcefn data_received(&mut self) -> Result<bool>
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.
Sourcefn sendme_received(
&mut self,
state: &mut State,
rtt: &mut RoundtripTimeEstimator,
signals: CongestionSignals,
) -> Result<()>
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.
Sourcefn sendme_sent(&mut self) -> Result<()>
fn sendme_sent(&mut self) -> Result<()>
Inform the algorithm that we just sent a SENDME.