net/tcp: add kconfig to support retransmission at a fixed time
Build Documentation / build-html (push) Has been cancelled

the maximum retransmission interval allowed for car projects
cannot exceed 6 seconds, and allows for fixed retransmission intervals.
according to the previous algorithm, the retransmission interval
may be 0.5 * 2 ^ 4 = 8 seconds, which does not meet the requirements.

Signed-off-by: zhanghongyu <zhanghongyu@xiaomi.com>
This commit is contained in:
zhanghongyu
2025-08-04 21:26:55 +08:00
committed by archer
parent 746d68916f
commit 19dcd452ff
3 changed files with 19 additions and 1 deletions
+15 -1
View File
@@ -105,7 +105,21 @@ config NET_TCP_RTO
int "RTO of TCP/IP connections"
default 3
---help---
RTO of TCP/IP connections (all tasks)
Default retransmission timeout (RTO) of TCP/IP connections (all tasks).
In units of half seconds. When the same data packet is retransmitted
multiple times due to timeout, the RTO will be doubled. but the maximum
RTO is NET_TCP_RTO * 16. When this packet is ACKed, the RTO will be
reset to this value. This algorithm helps to reduce network congestion
to some extent.
config NET_TCP_FIXED_RTO
bool "Use fixed RTO"
default n
---help---
Use fixed RTO for TCP/IP connections (all tasks), i.e. do not use
the RTO exponentially increasing algorithm. This is useful for projects
that require a fixed RTO value or have restrictions on the maximum
retransmission time.
config NET_TCP_MAXRTX
int "Maximum retransmitted number of TCP/IP data packet"
+2
View File
@@ -1082,6 +1082,7 @@ found:
}
#endif
#ifndef CONFIG_NET_TCP_FIXED_RTO
/* Do RTT estimation, unless we have done retransmissions. */
if (conn->nrtx == 0)
@@ -1102,6 +1103,7 @@ found:
conn->sv += m;
conn->rto = (conn->sa >> 3) + conn->sv;
}
#endif
/* Set the acknowledged flag. */
+2
View File
@@ -579,7 +579,9 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
/* Exponential backoff. */
#ifndef CONFIG_NET_TCP_FIXED_RTO
conn->rto = TCP_RTO << (conn->nrtx > 4 ? 4: conn->nrtx);
#endif
tcp_update_retrantimer(conn, conn->rto);
conn->nrtx++;