pub trait CongestionController: 'static + Clone + Send + Debug {
fn congestion_window(&self) -> u32;
fn bytes_in_flight(&self) -> u32;
fn is_congestion_limited(&self) -> bool;
fn requires_fast_retransmission(&self) -> bool;
fn on_packet_sent(
&mut self,
time_sent: Timestamp,
sent_bytes: usize,
rtt_estimator: &RttEstimator
);
fn on_rtt_update(
&mut self,
time_sent: Timestamp,
rtt_estimator: &RttEstimator
);
fn on_packet_ack(
&mut self,
largest_acked_time_sent: Timestamp,
bytes_sent: usize,
rtt_estimator: &RttEstimator,
ack_receive_time: Timestamp
);
fn on_packets_lost(
&mut self,
lost_bytes: u32,
persistent_congestion: bool,
timestamp: Timestamp
);
fn on_congestion_event(&mut self, event_time: Timestamp);
fn on_mtu_update(&mut self, max_data_size: u16);
fn on_packet_discarded(&mut self, bytes_sent: usize);
fn earliest_departure_time(&self) -> Option<Timestamp>;
}
Required methods
fn congestion_window(&self) -> u32
fn congestion_window(&self) -> u32
Returns the size of the current congestion window in bytes
fn bytes_in_flight(&self) -> u32
fn bytes_in_flight(&self) -> u32
Returns the current bytes in flight
fn is_congestion_limited(&self) -> bool
fn is_congestion_limited(&self) -> bool
Returns true
if the congestion window does not have sufficient
space for a packet of max_datagram_size
considering the current
bytes in flight
fn requires_fast_retransmission(&self) -> bool
fn requires_fast_retransmission(&self) -> bool
Returns true
if the current state of the congestion controller
requires a packet to be transmitted without respecting the
available congestion window
fn on_packet_sent(
&mut self,
time_sent: Timestamp,
sent_bytes: usize,
rtt_estimator: &RttEstimator
)
fn on_packet_sent(
&mut self,
time_sent: Timestamp,
sent_bytes: usize,
rtt_estimator: &RttEstimator
)
Invoked whenever a congestion controlled packet is sent
fn on_rtt_update(&mut self, time_sent: Timestamp, rtt_estimator: &RttEstimator)
fn on_rtt_update(&mut self, time_sent: Timestamp, rtt_estimator: &RttEstimator)
Invoked each time the round trip time is updated, which is whenever the largest acknowledged packet in an ACK frame is newly acknowledged
fn on_packet_ack(
&mut self,
largest_acked_time_sent: Timestamp,
bytes_sent: usize,
rtt_estimator: &RttEstimator,
ack_receive_time: Timestamp
)
fn on_packet_ack(
&mut self,
largest_acked_time_sent: Timestamp,
bytes_sent: usize,
rtt_estimator: &RttEstimator,
ack_receive_time: Timestamp
)
Invoked for each newly acknowledged packet
fn on_packets_lost(
&mut self,
lost_bytes: u32,
persistent_congestion: bool,
timestamp: Timestamp
)
fn on_packets_lost(
&mut self,
lost_bytes: u32,
persistent_congestion: bool,
timestamp: Timestamp
)
Invoked when packets are declared lost
fn on_congestion_event(&mut self, event_time: Timestamp)
fn on_congestion_event(&mut self, event_time: Timestamp)
Invoked from on_packets_lost, but is also directly invoked when the Explicit Congestion Notification counter increases.
fn on_mtu_update(&mut self, max_data_size: u16)
fn on_mtu_update(&mut self, max_data_size: u16)
Invoked when the path maximum transmission unit is updated.
fn on_packet_discarded(&mut self, bytes_sent: usize)
fn on_packet_discarded(&mut self, bytes_sent: usize)
Invoked for each packet discarded when a packet number space is discarded.
fn earliest_departure_time(&self) -> Option<Timestamp>
fn earliest_departure_time(&self) -> Option<Timestamp>
Returns the earliest time that a packet may be transmitted.
If the time is in the past or is None
, the packet should be transmitted immediately.