commit ffe7ba4bc229b8622d481aaaa539d8afe630e7f3 Author: Kevin Bowling Date: Tue May 19 18:12:48 2026 -0700 tcp: set initial RTO to 1s per RFC 6298 Lower TCPTV_SRTTDFLT from 3s to 1s and adjust the t_rttvar seed in tcp_tcpcb_template() so the pre-measurement TCP_REXMTVAL() equals TCPTV_SRTTDFLT (was 2*TCPTV_SRTTDFLT). Active opens and SYN|ACK retransmits now start at 1 s and back off 1, 2, 4, ... per RFC 6298 sections 2.1 and 5.5. Post-first-sample RTO is unchanged. Pin tcp_msl_remote_threshold to its previous numeric default (3*PR_SLOWHZ) so the SRTTDFLT change does not move an unrelated TIME_WAIT-shortening tunable. This is conceptually https://reviews.freebsd.org/D18941 which we ran at a large CDN, modified for NetBSD's stack. diff --git a/sys/netinet/tcp_subr.c b/sys/netinet/tcp_subr.c index 38dc53a1d1b0..8b8ed7475b36 100644 --- a/sys/netinet/tcp_subr.c +++ b/sys/netinet/tcp_subr.c @@ -209,7 +209,7 @@ int tcp_msl_enable = 1; /* enable TIME_WAIT truncation */ int tcp_msl_loop = PR_SLOWHZ; /* MSL for loopback */ int tcp_msl_local = 5 * PR_SLOWHZ; /* MSL for 'local' */ int tcp_msl_remote = TCPTV_MSL; /* MSL otherwise */ -int tcp_msl_remote_threshold = TCPTV_SRTTDFLT; /* RTT threshold */ +int tcp_msl_remote_threshold = 3*PR_SLOWHZ; /* RTT threshold */ int tcp_rttlocal = 0; /* Use RTT to decide who's 'local' */ int tcp4_vtw_enable = 0; /* 1 to enable */ @@ -917,10 +917,10 @@ tcp_tcpcb_template(void) /* * Init srtt to TCPTV_SRTTBASE (0), so we can tell that we have no - * rtt estimate. Set rttvar so that srtt + 2 * rttvar gives - * reasonable initial retransmit time. + * rtt estimate. Seed rttvar so the initial RTO computed by + * TCP_REXMTVAL() equals TCPTV_SRTTDFLT (RFC 6298 section 2.1). */ - tp->t_rttvar = tcp_rttdflt * PR_SLOWHZ << (TCP_RTTVAR_SHIFT + 2 - 1); + tp->t_rttvar = tcp_rttdflt * PR_SLOWHZ << TCP_RTTVAR_SHIFT; TCPT_RANGESET(tp->t_rxtcur, TCP_REXMTVAL(tp), TCPTV_MIN, TCPTV_REXMTMAX); diff --git a/sys/netinet/tcp_timer.h b/sys/netinet/tcp_timer.h index ebc0bb0dd765..8d33090cf8c2 100644 --- a/sys/netinet/tcp_timer.h +++ b/sys/netinet/tcp_timer.h @@ -119,7 +119,7 @@ #define TCPTV_MSL ( 30*PR_SLOWHZ) /* max seg lifetime (hah!) */ #define TCPTV_SRTTBASE 0 /* base roundtrip time; if 0, no idea yet */ -#define TCPTV_SRTTDFLT ( 3*PR_SLOWHZ) /* assumed RTT if no info */ +#define TCPTV_SRTTDFLT ( 1*PR_SLOWHZ) /* initial RTO; RFC 6298 (2.1) */ #define TCPTV_PERSMIN ( 5*PR_SLOWHZ) /* retransmit persistance */ #define TCPTV_PERSMAX ( 60*PR_SLOWHZ) /* maximum persist interval */