From 8b12570493ab77960aeac7e3e4a9bc458bb4f1a1 Mon Sep 17 00:00:00 2001 From: Guus Sliepen Date: Sun, 8 Mar 2020 22:12:41 +0100 Subject: [PATCH] Avoid sending packets smaller than the MTU if we don't need to. If we have almost filled the congestion window but have more data in the send buffer than we can send right now, wait until the congestion window frees up to avoid sending small packets unnecessarily. --- utcp.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/utcp.c b/utcp.c index 7aeb2d3..cb23e1b 100644 --- a/utcp.c +++ b/utcp.c @@ -521,10 +521,14 @@ static void ack(struct utcp_connection *c, bool sendatleastone) { assert(left >= 0); - if(cwndleft < 0) { + if(cwndleft <= 0) { left = 0; } else if(cwndleft < left) { left = cwndleft; + + if(!sendatleastone || cwndleft > c->utcp->mtu) { + left -= left % c->utcp->mtu; + } } debug("cwndleft = %d, left = %d\n", cwndleft, left); -- 2.39.2