pub struct CongestionController { /* private fields */ }Expand description
Multi-connection, multi-algorithm TCP-inspired congestion controller.
Manages per-connection congestion state and emits Decision structs
that callers use to pace their sends.
Implementations§
Source§impl CongestionController
impl CongestionController
Sourcepub fn new(config: CccControllerConfig) -> Self
pub fn new(config: CccControllerConfig) -> Self
Create a new controller with the given configuration.
Sourcepub fn with_defaults() -> Self
pub fn with_defaults() -> Self
Create a new controller with default configuration.
Sourcepub fn add_connection(&mut self, id: CccConnId)
pub fn add_connection(&mut self, id: CccConnId)
Register a new connection. If the connection already exists this is a no-op.
Sourcepub fn remove_connection(&mut self, id: CccConnId) -> bool
pub fn remove_connection(&mut self, id: CccConnId) -> bool
Remove a tracked connection. Returns true if it existed.
Sourcepub fn reset_connection(&mut self, id: CccConnId) -> Result<(), &'static str>
pub fn reset_connection(&mut self, id: CccConnId) -> Result<(), &'static str>
Reset a connection to its initial state (keeps the entry).
Returns an error if the connection does not exist.
Sourcepub fn on_ack(
&mut self,
conn_id: CccConnId,
bytes_acked: u64,
rtt_ms: f64,
) -> Result<CccDecision, &'static str>
pub fn on_ack( &mut self, conn_id: CccConnId, bytes_acked: u64, rtt_ms: f64, ) -> Result<CccDecision, &'static str>
Process an ACK for bytes_acked bytes on conn_id with the measured RTT.
Returns the new Decision, or an error if conn_id is unknown.
Sourcepub fn on_loss(
&mut self,
conn_id: CccConnId,
lost_bytes: u64,
) -> Result<CccDecision, &'static str>
pub fn on_loss( &mut self, conn_id: CccConnId, lost_bytes: u64, ) -> Result<CccDecision, &'static str>
Process a packet loss event on conn_id.
Applies multiplicative decrease and enters fast recovery.
Sourcepub fn on_timeout(
&mut self,
conn_id: CccConnId,
) -> Result<CccDecision, &'static str>
pub fn on_timeout( &mut self, conn_id: CccConnId, ) -> Result<CccDecision, &'static str>
Process a retransmission timeout on conn_id.
Resets cwnd to min_cwnd, halves ssthresh, re-enters slow start.
Sourcepub fn sending_rate(&self, conn_id: CccConnId) -> Option<f64>
pub fn sending_rate(&self, conn_id: CccConnId) -> Option<f64>
Current sending rate for a connection, in bytes/sec.
Returns None if the connection is unknown or RTT has not been measured.
Sourcepub fn controller_stats(&self) -> CccControllerStats
pub fn controller_stats(&self) -> CccControllerStats
Aggregate statistics across all active connections.
Sourcepub fn connection(&self, conn_id: CccConnId) -> Option<&CccConnection>
pub fn connection(&self, conn_id: CccConnId) -> Option<&CccConnection>
Immutable reference to a connection, if it exists.
Auto Trait Implementations§
impl Freeze for CongestionController
impl RefUnwindSafe for CongestionController
impl Send for CongestionController
impl Sync for CongestionController
impl Unpin for CongestionController
impl UnsafeUnpin for CongestionController
impl UnwindSafe for CongestionController
Blanket Implementations§
impl<T> Allocation for T
Source§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
Source§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more