]> git.meshlink.io Git - utcp/commitdiff
Avoid sending packets smaller than the MTU if we don't need to.
authorGuus Sliepen <guus@sliepen.org>
Sun, 8 Mar 2020 21:12:41 +0000 (22:12 +0100)
committerGuus Sliepen <guus@sliepen.org>
Sun, 8 Mar 2020 22:49:22 +0000 (23:49 +0100)
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

diff --git a/utcp.c b/utcp.c
index 7aeb2d358cf7b3157672f8bb2f25b488b9a40606..cb23e1bf3d6413510d8dd729f7dd00e781eb4291 100644 (file)
--- 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);