This is an automated email from the ASF dual-hosted git repository. acassis pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 872bff9cae4e0d08133190408e26e51a06d0d091 Author: Marco Casaroli <[email protected]> AuthorDate: Mon Nov 16 21:22:26 2026 +0100 net/tcp: Double the retransmission timeout at the first expiry too. tcp_timer() set conn->rto = TCP_RTO << nrtx before it counted the expiry in nrtx, so the timeouts of one segment were 1.5 s, 1.5 s, 3 s, 6 s, ...: the first back-off step came one expiry late. RFC 6298, section 5.5: when the timer expires, back off the timer (RTO = RTO * 2). Now nrtx counts the expiry first: 1.5 s, 3 s, 6 s, ... The limits (TCP_MAXRTX, TCP_MAXSYNRTX, the shift of at most 4) do not change. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <[email protected]> --- net/tcp/tcp_timer.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c index 3084006a6ed..9e17d944311 100644 --- a/net/tcp/tcp_timer.c +++ b/net/tcp/tcp_timer.c @@ -591,13 +591,15 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn) goto done; } - /* Exponential backoff. */ + /* Exponential backoff: this timeout doubles the wait for + * the next one (RFC 6298, section 5.5). + */ + conn->nrtx++; #ifndef CONFIG_NET_TCP_FIXED_RTO - conn->rto = TCP_RTO << (conn->nrtx > 4 ? 4: conn->nrtx); + conn->rto = TCP_RTO << (conn->nrtx > 4 ? 4 : conn->nrtx); #endif tcp_update_retrantimer(conn, conn->rto); - conn->nrtx++; /* Ok, so we need to retransmit. We do this differently * depending on which state we are in. In ESTABLISHED, we
