Skip to content

Commit 19dcd45

Browse files
zhhyu7anchao
authored andcommitted
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 <zhanghongyu@xiaomi.com>
1 parent 746d689 commit 19dcd45

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

net/tcp/Kconfig

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,21 @@ config NET_TCP_RTO
105105
int "RTO of TCP/IP connections"
106106
default 3
107107
---help---
108-
RTO of TCP/IP connections (all tasks)
108+
Default retransmission timeout (RTO) of TCP/IP connections (all tasks).
109+
In units of half seconds. When the same data packet is retransmitted
110+
multiple times due to timeout, the RTO will be doubled. but the maximum
111+
RTO is NET_TCP_RTO * 16. When this packet is ACKed, the RTO will be
112+
reset to this value. This algorithm helps to reduce network congestion
113+
to some extent.
114+
115+
config NET_TCP_FIXED_RTO
116+
bool "Use fixed RTO"
117+
default n
118+
---help---
119+
Use fixed RTO for TCP/IP connections (all tasks), i.e. do not use
120+
the RTO exponentially increasing algorithm. This is useful for projects
121+
that require a fixed RTO value or have restrictions on the maximum
122+
retransmission time.
109123

110124
config NET_TCP_MAXRTX
111125
int "Maximum retransmitted number of TCP/IP data packet"

net/tcp/tcp_input.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1082,6 +1082,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
10821082
}
10831083
#endif
10841084

1085+
#ifndef CONFIG_NET_TCP_FIXED_RTO
10851086
/* Do RTT estimation, unless we have done retransmissions. */
10861087

10871088
if (conn->nrtx == 0)
@@ -1102,6 +1103,7 @@ static void tcp_input(FAR struct net_driver_s *dev, uint8_t domain,
11021103
conn->sv += m;
11031104
conn->rto = (conn->sa >> 3) + conn->sv;
11041105
}
1106+
#endif
11051107

11061108
/* Set the acknowledged flag. */
11071109

net/tcp/tcp_timer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,7 +579,9 @@ void tcp_timer(FAR struct net_driver_s *dev, FAR struct tcp_conn_s *conn)
579579

580580
/* Exponential backoff. */
581581

582+
#ifndef CONFIG_NET_TCP_FIXED_RTO
582583
conn->rto = TCP_RTO << (conn->nrtx > 4 ? 4: conn->nrtx);
584+
#endif
583585
tcp_update_retrantimer(conn, conn->rto);
584586
conn->nrtx++;
585587

0 commit comments

Comments
 (0)