mirror of
https://github.com/soypat/lneto.git
synced 2026-07-26 10:38:47 +00:00
8873b55e5d
Provide a concrete packet-loss recovery algorithm for the LossRecovery interface added in #168: the RFC 6298 round-trip-time estimator and single retransmission timer. RTO is a pure, reactive state machine. It derives RTT estimates and retransmission decisions solely from the segments observed through the LossRecovery hooks and the monotonic time handed in at each boundary, so it holds no clock and allocates nothing (issue #140). It tracks a shadow of the send sequence space (snd.UNA/snd.NXT) purely from observed segments, which is how it manages the timer without reaching into the ControlBlock and how it distinguishes retransmissions for Karn's algorithm. Covered: - §2.2/§2.3 SRTT/RTTVAR/RTO smoothing (integer-shift form) - §3 Karn's algorithm: one sample in flight, never sample a retransmit - §5.1-§5.3 timer arm/restart/stop as data is sent and acknowledged - §5.4-§5.6 timeout response: exponential backoff + go-back-N retransmit - §5.7 backoff collapse on a valid RTT sample - RTO clamped to [rtoMin, rtoMax] RTT introspection (SmoothedRTT, CurrentRTO, Running) lives on the concrete type, not the interface, per the LossRecovery design. Install with new(RTO) on ConnConfig.LossRecovery; the connection calls Reset on open so the zero value is ready to use. Generated with LLM assistance. Signed-off-by: Marvin Drees <marvin.drees@9elements.com>