From 14bf23c4962430af34f4f88cc033eaf250b1f41e Mon Sep 17 00:00:00 2001 From: Martin Michelsen Date: Sat, 24 Feb 2024 10:23:48 -0800 Subject: [PATCH] only send next TCP PSH if client's acked seq has changed --- src/IPStackSimulator.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/IPStackSimulator.cc b/src/IPStackSimulator.cc index ebd2b5bf..7a503298 100644 --- a/src/IPStackSimulator.cc +++ b/src/IPStackSimulator.cc @@ -1166,6 +1166,7 @@ void IPStackSimulator::on_client_tcp_frame( throw runtime_error("non-SYN frame does not correspond to any open TCP connection"); } bool conn_valid = true; + bool acked_seq_changed = false; if (fi.tcp->flags & TCPHeader::Flag::ACK) { ip_stack_simulator_log.debug("Client sent ACK %08" PRIX32, fi.tcp->ack_num.load()); @@ -1189,6 +1190,7 @@ void IPStackSimulator::on_client_tcp_frame( conn->acked_server_seq += ack_delta; conn->resend_push_usecs = DEFAULT_RESEND_PUSH_USECS; conn->next_push_max_frame_size = conn->max_frame_size; + acked_seq_changed = true; ip_stack_simulator_log.debug("Removed %08" PRIX32 " bytes from pending buffer and advanced acked_server_seq to %08" PRIX32, ack_delta, conn->acked_server_seq); @@ -1298,7 +1300,7 @@ void IPStackSimulator::on_client_tcp_frame( conn_str.c_str(), conn->acked_server_seq, conn->next_client_seq, conn->bytes_received); } - if (conn_valid) { + if (conn_valid && acked_seq_changed) { // Try to send some more data if the client is waiting on it this->send_pending_push_frame(c, *conn); } @@ -1385,8 +1387,7 @@ void IPStackSimulator::send_pending_push_frame(shared_ptr c, IPClient: if (conn.resend_push_usecs > 5000000) { conn.resend_push_usecs = 5000000; } - conn.next_push_max_frame_size = max( - 0x100, conn.next_push_max_frame_size - 0x100); + conn.next_push_max_frame_size = max(0x100, conn.next_push_max_frame_size - 0x100); } void IPStackSimulator::send_tcp_frame(