This is an automated email from the ASF dual-hosted git repository.

archer pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 19dcd452ff5 net/tcp: add kconfig to support retransmission at a fixed 
time
19dcd452ff5 is described below

commit 19dcd452ff535c2ce3f9e16002bb9eac3d5254ca
Author: zhanghongyu <[email protected]>
AuthorDate: Mon Aug 4 21:26:55 2025 +0800

    net/tcp: add kconfig to support retransmission at a fixed time
    
    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 <[email protected]>
---
 net/tcp/Kconfig     | 16 +++++++++++++++-
 net/tcp/tcp_input.c |  2 ++
 net/tcp/tcp_timer.c |  2 ++
 3 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/net/tcp/Kconfig b/net/tcp/Kconfig
index 734379daa7b..09c1dda7cd5 100644
--- a/net/tcp/Kconfig
+++ b/net/tcp/Kconfig
@@ -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"
diff --git a/net/tcp/tcp_input.c b/net/tcp/tcp_input.c
index 07780467135..df74dcb3d26 100644
--- a/net/tcp/tcp_input.c
+++ b/net/tcp/tcp_input.c
@@ -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. */
 
diff --git a/net/tcp/tcp_timer.c b/net/tcp/tcp_timer.c
index 76715c0471c..5e0fefc1b51 100644
--- a/net/tcp/tcp_timer.c
+++ b/net/tcp/tcp_timer.c
@@ -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++;
 

Reply via email to