Skip to main content

Module flow

Module flow 

Source
Expand description

§VCL Flow Control

Sliding window flow control for VCL Protocol.

Prevents the sender from overwhelming the receiver by limiting the number of unacknowledged packets in flight simultaneously.

§How it works

window_size = 4

Sent but unacked:  [0] [1] [2] [3]   <- window full, must wait
Acked:             [0]               <- window slides, can send [4]
Sent but unacked:      [1] [2] [3] [4]

§Example

use vcl_protocol::flow::FlowController;

let mut fc = FlowController::new(4);

// Send packets
assert!(fc.can_send());
fc.on_send(0);
fc.on_send(1);
fc.on_send(2);
fc.on_send(3);
assert!(!fc.can_send()); // window full

// Acknowledge packets
fc.on_ack(0);
assert!(fc.can_send()); // window has space again

Structs§

FlowController
Sliding window flow controller.
InFlightPacket
Tracks a sent-but-unacknowledged packet.