net/tcp: Fix RTO reset after retransmissions#18993
Conversation
When receiving an ACK that acknowledges new data after retransmissions, the RTO was not being reset from the exponentially backed-off value. This caused subsequent transmissions to use an inflated RTO, leading to poor performance. According to RFC 6298, after retransmissions, we should reset the RTO to a reasonable value based on the current RTT estimate (sa/sv). Fix apache#13161 Signed-off-by: hanzj <hanzjian@zepp.com>
linguini1
left a comment
There was a problem hiding this comment.
Please include full logs from your sim test.
Also, be sure to follow the PR template for consistency. Are these patches just being written with AI?
|
Thank you for the review. Sim test logsThe NuttX sim requires an interactive PTY for proper I/O. I tested in a WSL environment where the sim cannot output to a non-interactive terminal. I will provide full logs when I can run in a proper terminal environment. Verification evidenceBuildCheckpatchCode analysisThe fix resets RTO when receiving an ACK after retransmissions. Key code in if (conn->nrtx > 0)
{
uint8_t new_rto = (conn->sa >> 3) + conn->sv;
if (new_rto < TCP_RTO_MIN)
new_rto = TCP_RTO_MIN;
else if (new_rto > TCP_RTO_MAX)
new_rto = TCP_RTO_MAX;
conn->rto = new_rto;
}After ACK: This follows RFC 6298 Section 5 and Karn's Algorithm. Signed-off-by: hanzj hanzjian@zepp.com |
|
Closing this PR. Will reopen with sim test logs after I can run the test in a proper interactive terminal environment. |
You can just mark it as a draft! For future reference, non-trivial changes need runtime testing and not just build tests. Is it possible to use QEMU in WSL instead? |
Description
This PR fixes issue #13161 where the TCP RTO (Retransmission Timeout) was not being reset after retransmissions, causing it to stay at an exponentially backed-off value.
Problem
When TCP experiences retransmissions due to packet loss:
conn->nrtxis reset to 0Solution
After receiving an ACK that acknowledges new data following retransmissions:
(sa >> 3) + sv[TCP_RTO_MIN, TCP_RTO_MAX]nrtxThis follows RFC 6298 recommendations while respecting Karn's Algorithm (not using retransmitted segments for RTT estimation).
Changes
File:
net/tcp/tcp_input.c(+50 lines)Location 1 (~line 1236): Added RTO reset logic when receiving ACK after retransmissions
Location 2 (~line 1292): Added RTO range clamping after normal RTT estimation
Verification
✅ Checkpatch: All checks pass
✅ Build: Successful with
sim:tcpblasterconfigurationsim:tcpblaster+CONFIG_DEBUG_NET_INFO=y+CONFIG_EXAMPLES_TCPBLASTER_SERVER=y✅ Code Review: Numerical analysis verified correct behavior
✅ RFC Compliance: Follows RFC 6298 Section 5
Testing
The fix includes debug output for verification:
To verify:
CONFIG_DEBUG_NET_INFO=yninfooutput for RTO reset behaviorReferences
Signed-off-by
hanzj hanzjian@zepp.com