From f09713bc19eb3a447e50d8309d13635982e4cf5f Mon Sep 17 00:00:00 2001 From: Orvaxis <198349614+Orvaxis@users.noreply.github.com> Date: Thu, 9 Oct 2025 13:02:58 +0800 Subject: [PATCH] fix: respect receiver's window size in send buffer full check --- src/stream/tcb.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/stream/tcb.rs b/src/stream/tcb.rs index 202a9a1..7795447 100644 --- a/src/stream/tcb.rs +++ b/src/stream/tcb.rs @@ -300,7 +300,9 @@ impl Tcb { } pub fn is_send_buffer_full(&self) -> bool { - self.seq.distance(self.get_last_received_ack()) >= MAX_UNACK + // To respect the receiver's window (remote_window) size and avoid sending too many unacknowledged packets, which may cause packet loss + // Simplified version: min(cwnd, rwnd) + self.seq.distance(self.get_last_received_ack()) >= MAX_UNACK.min(self.get_send_window() as u32) } }