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++;