From: Guus Sliepen Date: Sun, 8 Mar 2020 21:12:41 +0000 (+0100) Subject: Avoid sending packets smaller than the MTU if we don't need to. X-Git-Url: https://git.meshlink.io/?a=commitdiff_plain;h=8b12570493ab77960aeac7e3e4a9bc458bb4f1a1;p=utcp 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. --- 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);