pub struct FlowController { /* private fields */ }Expand description
Sliding window flow controller.
Tracks in-flight packets and controls send rate based on window size. Supports acknowledgements, retransmission detection, and RTT estimation.
Implementations§
Source§impl FlowController
impl FlowController
Sourcepub fn new(window_size: usize) -> Self
pub fn new(window_size: usize) -> Self
Create a new flow controller with the given window size.
Sourcepub fn with_rto(window_size: usize, rto_ms: u64) -> Self
pub fn with_rto(window_size: usize, rto_ms: u64) -> Self
Create a flow controller with a custom retransmission timeout.
Sourcepub fn available_slots(&self) -> usize
pub fn available_slots(&self) -> usize
Returns how many more packets can be sent right now.
Sourcepub fn window_size(&self) -> usize
pub fn window_size(&self) -> usize
Returns the current window size.
Sourcepub fn set_window_size(&mut self, size: usize)
pub fn set_window_size(&mut self, size: usize)
Dynamically adjust the window size.
Sourcepub fn in_flight_count(&self) -> usize
pub fn in_flight_count(&self) -> usize
Returns the number of packets currently in flight.
Sourcepub fn oldest_unacked_sequence(&self) -> Option<u64>
pub fn oldest_unacked_sequence(&self) -> Option<u64>
Returns the sequence number of the oldest unacknowledged sent packet,
or None if there are no packets in flight.
Sourcepub fn on_send(&mut self, sequence: u64) -> bool
pub fn on_send(&mut self, sequence: u64) -> bool
Register a packet as sent.
Returns false if the window is full.
Sourcepub fn on_ack(&mut self, sequence: u64) -> bool
pub fn on_ack(&mut self, sequence: u64) -> bool
Register a packet as acknowledged.
Updates RTT estimate. Returns true if the packet was found.
Sourcepub fn timed_out_packets(&mut self) -> Vec<u64>
pub fn timed_out_packets(&mut self) -> Vec<u64>
Returns all in-flight packets that have exceeded the retransmission timeout.
Resets sent_at for each timed-out packet.
Sourcepub fn total_sent(&self) -> u64
pub fn total_sent(&self) -> u64
Returns total packets sent.
Sourcepub fn total_acked(&self) -> u64
pub fn total_acked(&self) -> u64
Returns total packets acknowledged.
Sourcepub fn total_lost(&self) -> u64
pub fn total_lost(&self) -> u64
Returns total packets detected as lost.