AcknowledgmentHandler

Struct AcknowledgmentHandler 

Source
pub struct AcknowledgmentHandler { /* private fields */ }
Expand description

Responsible for handling the acknowledgment of packets.

Implementations§

Source§

impl AcknowledgmentHandler

Source

pub fn new() -> Self

Creates a new acknowledgment handler with default congestion control.

Source

pub fn with_congestion(congestion: CongestionControl) -> Self

Creates a new acknowledgment handler with custom congestion control.

Source

pub fn packets_in_flight(&self) -> u16

Returns the number of sent packets not yet acknowledged.

Source

pub fn local_sequence_num(&self) -> SequenceNumber

Returns the local sequence number for the next outgoing packet.

Source

pub fn remote_sequence_num(&self) -> SequenceNumber

Returns the most recent remote sequence number received.

Source

pub fn rtt(&self) -> Duration

Returns the current round-trip time.

Source

pub fn rto(&self) -> Duration

Returns the retransmission timeout.

Source

pub fn loss_rate(&self) -> f32

Returns the current packet loss rate (0.0 to 1.0).

Source

pub fn throttle(&self) -> f32

Returns the current throttle value (0.0 to 1.0).

Source

pub fn congestion(&self) -> &CongestionControl

Returns a reference to the congestion control.

Source

pub fn congestion_mut(&mut self) -> &mut CongestionControl

Returns a mutable reference to the congestion control.

Source

pub fn update_throttle(&mut self, now: Instant) -> bool

Updates the dynamic throttle based on current network conditions.

Source

pub fn should_drop_unreliable(&self) -> bool

Returns whether an unreliable packet should be dropped based on congestion.

Source

pub fn ack_bitfield(&self) -> u32

Returns the acknowledgment bitfield for the last 32 packets.

Source

pub fn process_incoming( &mut self, remote_seq_num: u16, remote_ack_seq: u16, remote_ack_field: u32, now: Instant, )

Processes an incoming packet and updates congestion metrics. Calculates RTT when ACKs are received.

Source

pub fn process_outgoing( &mut self, packet_type: PacketType, payload: &[u8], ordering_guarantee: OrderingGuarantee, item_identifier: Option<SequenceNumber>, now: Instant, )

Processes an outgoing packet and tracks it for acknowledgment.

Source

pub fn dropped_packets(&mut self) -> Vec<SentPacket>

Returns packets that are considered dropped (not ACKed beyond window). Records packet loss for congestion control.

A packet is considered dropped if it is more than REDUNDANT_PACKET_ACKS_SIZE (32) sequence numbers behind the latest acknowledged sequence number.

Trait Implementations§

Source§

impl Default for AcknowledgmentHandler

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V