From 239918ccc173cb2c2a62f41a40fd893f57faf1d6 Mon Sep 17 00:00:00 2001 From: yuanjm Date: Wed, 15 Apr 2020 10:26:04 +0800 Subject: [PATCH] tcp: Make retransmission timeout (RTO) configurable --- src/core/tcp.c | 6 ++++-- src/include/lwip/opt.h | 9 +++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/core/tcp.c b/src/core/tcp.c index 5b4f4e5e..1abea8e0 100644 --- a/src/core/tcp.c +++ b/src/core/tcp.c @@ -1901,8 +1901,10 @@ tcp_alloc(u8_t prio) /* As initial send MSS, we use TCP_MSS but limit it to 536. The send MSS is updated when an MSS option is received. */ pcb->mss = INITIAL_MSS; - pcb->rto = 3000 / TCP_SLOW_INTERVAL; - pcb->sv = 3000 / TCP_SLOW_INTERVAL; + /* Set initial TCP's retransmission timeout to 3000 ms by default. + This value could be configured in lwipopts */ + pcb->rto = LWIP_TCP_RTO_TIME / TCP_SLOW_INTERVAL; + pcb->sv = LWIP_TCP_RTO_TIME / TCP_SLOW_INTERVAL; pcb->rtime = -1; pcb->cwnd = 1; pcb->tmr = tcp_ticks; diff --git a/src/include/lwip/opt.h b/src/include/lwip/opt.h index 9fe0bf04..08c2628a 100644 --- a/src/include/lwip/opt.h +++ b/src/include/lwip/opt.h @@ -1337,6 +1337,15 @@ #define TCP_CALCULATE_EFF_SEND_MSS 1 #endif +/** + * LWIP_TCP_RTO_TIME: Initial TCP retransmission timeout (ms). + * This defaults to 3 seconds as traditionally defined in the TCP protocol. + * For improving timely recovery on faster networks, this value could + * be lowered down to 1 second (RFC 6298) + */ +#if !defined LWIP_TCP_RTO_TIME || defined __DOXYGEN__ +#define LWIP_TCP_RTO_TIME 3000 +#endif /** * TCP_SND_BUF: TCP sender buffer space (bytes).