issue: 4043157 Set initial RTO to 1 second per RFC 6298
Description
Change initial TCP retransmission timeout from 3 seconds to 1 second as recommended by RFC 6298 Section 2.
RFC 6298 states: "Until a round-trip time (RTT) measurement has been made... the sender SHOULD set RTO <- 1 second"
This applies to all new TCP connections until an RTT measurement is made. Once the connection is established and ACKs received, TCP calculates actual RTT and updates RTO accordingly using the Van Jacobson algorithm.
Modified functions:
- tcp_pcb_init(): Set rto/sv to 1000ms (was 3000ms)
- tcp_pcb_recycle(): Set rto/sv to 1000ms (was 3000ms)
This fixes incorrect SYN retransmission timing where the first retry occurred after ~3 seconds instead of ~1 second, causing TCP_USER_TIMEOUT tests to fail and slower connection failure detection.
Benefits:
- TCP/IP standards compliance (RFC 6298)
- Faster connection establishment failure detection
- Matches Linux kernel TCP_TIMEOUT_INIT behavior
What
Set initial RTO to 1 second per RFC 6298
Why ?
RFC Compliance.
How ?
It is optional but for complex PRs please provide information about the design, architecture, approach, etc.
Change type
What kind of change does this PR introduce?
- [X] Bugfix
- [ ] Feature
- [ ] Code style update
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [ ] CI related changes
- [ ] Documentation content changes
- [ ] Tests
- [ ] Other
Check list
- [ ] Code follows the style de facto guidelines of this project
- [ ] Comments have been inserted in hard to understand places
- [ ] Documentation has been updated (if necessary)
- [ ] Test has been added (if possible)
@pasis can you check if we want this fix? Sync with @tomerdbz please.
Greptile Summary
- Initial TCP retransmission timeout changed from 3 seconds to 1 second per RFC 6298 recommendation
- Added 500ms maximum limit on TCP timer resolution per RFC 1122 with validation and clamping
Confidence Score: 5/5
- This PR is safe to merge with no identified risks
- Changes correctly implement RFC 6298 standards for initial RTO using proper ceiling division to ensure at least 1 second timeout. The helper function
get_initial_rto()correctly converts milliseconds to timer ticks. Additional timer resolution validation prevents misconfigurations. All changes are well-commented with RFC references and improve TCP connection failure detection timing. - No files require special attention
Important Files Changed
| Filename | Overview |
|---|---|
| src/core/lwip/tcp.c | Changed initial RTO from 3000ms to 1000ms per RFC 6298 using ceiling division helper function |
| src/core/util/sys_vars.cpp | Added validation to clamp TCP timer resolution to 500ms maximum per RFC 1122 |
Sequence Diagram
sequenceDiagram
participant App as "Application"
participant TCP as "TCP Layer"
participant Timer as "Timer System"
participant Net as "Network"
Note over TCP: "Initial State: New Connection"
App->>TCP: "tcp_pcb_init() or tcp_pcb_recycle()"
TCP->>TCP: "get_initial_rto()"
Note over TCP: "Calculate: (1000 + slow_tmr_interval - 1) / slow_tmr_interval"
TCP->>TCP: "Set rto = 5 ticks (1000ms with default 200ms timer)"
TCP->>TCP: "Set sv = 5 ticks"
App->>TCP: "connect()"
TCP->>Net: "Send SYN"
TCP->>Timer: "Start retransmission timer (rtime=0)"
Timer->>TCP: "tcp_slowtmr() every 200ms"
TCP->>TCP: "Increment rtime"
alt "ACK received before timeout"
Net->>TCP: "Receive SYN-ACK"
TCP->>TCP: "Measure RTT, update RTO using Van Jacobson algorithm"
Note over TCP: "rto = (sa >> 3) + sv (adaptive)"
TCP->>Net: "Send ACK"
TCP->>App: "Connection established"
else "Timeout after ~1 second (5 ticks)"
Timer->>TCP: "tcp_slowtmr() - rtime >= rto"
TCP->>TCP: "Apply backoff: rto = rto << tcp_backoff[nrtx]"
TCP->>Net: "Retransmit SYN"
end
bot:retest