pub struct ResendReceiver { /* private fields */ }Expand description
Go-Back-N receiver state machine.
In Go-Back-N ARQ, frames arriving out of order are not queued or reordered; they are immediately dropped and prompt a cumulative ACK of the latest contiguous in-order frame.
This state machine provides two-phase sequence progression (inspect and
advance_in_order) to allow transport drivers to apply backpressure.
Implementations§
Source§impl ResendReceiver
impl ResendReceiver
Sourcepub fn expected_seq(&self) -> u8
pub fn expected_seq(&self) -> u8
Returns the sequence number currently expected by the receiver.
Sourcepub fn inspect(&self, seq: u8) -> FrameStatus
pub fn inspect(&self, seq: u8) -> FrameStatus
Evaluates an incoming frame sequence number without advancing state.
Returns FrameStatus::InOrder if seq == expected_seq. Otherwise, returns
FrameStatus::OutOfOrder with the cumulative ACK sequence to transmit.
Sourcepub fn advance_in_order(&mut self, seq: u8) -> Result<u8, UnexpectedSeqError>
pub fn advance_in_order(&mut self, seq: u8) -> Result<u8, UnexpectedSeqError>
Advances expected_seq by 1 and returns the cumulative ACK sequence to transmit.
§Errors
Returns UnexpectedSeqError if seq != expected_seq.
Sourcepub fn accept_seq(&mut self, seq: u8) -> FrameStatus
pub fn accept_seq(&mut self, seq: u8) -> FrameStatus
Processes an incoming frame sequence number in a single step.
If seq == expected_seq, advances the sequence and returns FrameStatus::InOrder.
Otherwise, returns FrameStatus::OutOfOrder with the cumulative ACK to send in response.
Callers implementing two-phase flow control (e.g. attempting non-blocking writes to bounded
channels before committing sequence progression) should use inspect
followed by advance_in_order instead.
Sourcepub fn current_ack_seq(&self) -> Option<u8>
pub fn current_ack_seq(&self) -> Option<u8>
Returns the current cumulative ACK sequence for out-of-order/duplicate frames.
If no frames have been received yet, returns None to suppress spurious ACK 255 emission
on startup packet loss (BUG-PROT-02).