Skip to content

Commit 5442e47

Browse files
rlubosaescolar
authored andcommitted
net: tcp: Delay ACK if no PSH flag is present
Delay an ACK in case no PSH flag is present in the data packet. as described in RFC 813. This allows to reduce the number of ACK packets we send and thus improve the TCP download throughput. The results achieved on `nucleo_h723zg` board and the zperf sample are as follows: Before: 77.14 Mbps After: 93.14 Mbps Signed-off-by: Robert Lubos <robert.lubos@nordicsemi.no>
1 parent cf870e8 commit 5442e47

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

subsys/net/ip/tcp.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2695,7 +2695,7 @@ static void tcp_queue_recv_data(struct tcp *conn, struct net_pkt *pkt,
26952695
}
26962696

26972697
static enum net_verdict tcp_data_received(struct tcp *conn, struct net_pkt *pkt,
2698-
size_t *len)
2698+
size_t *len, bool psh)
26992699
{
27002700
enum net_verdict ret;
27012701

@@ -2711,7 +2711,7 @@ static enum net_verdict tcp_data_received(struct tcp *conn, struct net_pkt *pkt,
27112711
/* Delay ACK response in case of small window or missing PSH,
27122712
* as described in RFC 813.
27132713
*/
2714-
if (tcp_short_window(conn)) {
2714+
if (tcp_short_window(conn) || !psh) {
27152715
k_work_schedule_for_queue(&tcp_work_q, &conn->ack_timer,
27162716
ACK_DELAY);
27172717
} else {
@@ -3252,7 +3252,9 @@ static enum net_verdict tcp_in(struct tcp *conn, struct net_pkt *pkt)
32523252
if (th) {
32533253
if (th_seq(th) == conn->ack) {
32543254
if (len > 0) {
3255-
verdict = tcp_data_received(conn, pkt, &len);
3255+
bool psh = FL(&fl, &, PSH);
3256+
3257+
verdict = tcp_data_received(conn, pkt, &len, psh);
32563258
if (verdict == NET_OK) {
32573259
/* net_pkt owned by the recv fifo now */
32583260
pkt = NULL;

0 commit comments

Comments
 (0)