From c2642eef3c80e4e32d412954a4824c6c9d87ef57 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Mon, 9 Dec 2019 08:45:52 -0600 Subject: [PATCH] net/tcp/tcp_appsend.c: Enhance delayed ACK algorithm with behavior of Windows delayed ACK described at https://support.microsoft.com/en-nz/help/214397/design-issues-sending-small-data-segments-over-tcp-with-winsock: 'If there are data to be sent in the same direction as the ACK before the second data packet is received and the delay timer expires, the ACK is piggybacked with the data segment and sent immediately.' --- net/tcp/tcp_appsend.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/net/tcp/tcp_appsend.c b/net/tcp/tcp_appsend.c index 93b1a6eca2..b545732a0d 100644 --- a/net/tcp/tcp_appsend.c +++ b/net/tcp/tcp_appsend.c @@ -134,6 +134,17 @@ void tcp_appsend(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn, return; } } + + /* If there are data to be sent in the same direction as the ACK before + * the second data packet is received and the delay timer expires, the ACK + * is piggybacked with the data segment and sent immediately. + */ + + else if (dev->d_sndlen > 0 && conn->rx_unackseg > 0) + { + result |= TCP_SNDACK; + conn->rx_unackseg = 0; + } #endif /* Get the IP header length associated with the IP domain configured for