Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,7 @@ Maps to **XLIO_TCP_TIMER_RESOLUTION_MSEC** environment variable.
Control internal TCP timer resolution (fast timer) in milliseconds.
Minimum value is the thread wakeup timer resolution configured in
performance.threading.internal_handler.timer_msec.
Maximum is 500ms per RFC 1122 Section 4.2.3.2 (delayed ACK timer must not exceed 500ms).
Default value is 100

network.protocols.tcp.timestamps
Expand Down
3 changes: 2 additions & 1 deletion src/core/config/descriptor_providers/xlio_config_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,9 +418,10 @@
"timer_msec": {
"type": "integer",
"minimum": 0,
"maximum": 500,
"default": 100,
"title": "TCP timer interval (msec)",
"description": "Maps to XLIO_TCP_TIMER_RESOLUTION_MSEC environment variable.\nControl internal TCP timer resolution (fast timer) in milliseconds.\nMinimum value is the thread wakeup timer resolution configured in\nperformance.threading.internal_handler.timer_msec."
"description": "Maps to XLIO_TCP_TIMER_RESOLUTION_MSEC environment variable.\nControl internal TCP timer resolution (fast timer) in milliseconds.\nMinimum value is the thread wakeup timer resolution configured in\nperformance.threading.internal_handler.timer_msec.\nMaximum is 500ms per RFC 1122 Section 4.2.3.2 (delayed ACK timer must not exceed 500ms)."
},
"mss": {
"type": "integer",
Expand Down
15 changes: 11 additions & 4 deletions src/core/lwip/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,6 +905,11 @@ err_t tcp_recv_null(void *arg, struct tcp_pcb *pcb, struct pbuf *p, err_t err)
return ERR_OK;
}

static inline u32_t get_initial_rto(void)
{
return (1000 + slow_tmr_interval - 1) / slow_tmr_interval;
}

void tcp_pcb_init(struct tcp_pcb *pcb, u8_t prio, void *container)
{
u32_t iss;
Expand All @@ -927,9 +932,10 @@ void tcp_pcb_init(struct tcp_pcb *pcb, u8_t prio, void *container)
pcb->mss = pcb->advtsd_mss;
pcb->user_timeout_ms = 0;
pcb->ticks_since_data_sent = -1;
pcb->rto = 3000 / slow_tmr_interval;
// Set initial RTO to 1 second as per RFC 6298
pcb->rto = get_initial_rto();
pcb->sa = 0;
pcb->sv = 3000 / slow_tmr_interval;
pcb->sv = get_initial_rto();
pcb->rtime = -1;
#if TCP_CC_ALGO_MOD
switch (lwip_cc_algo_module) {
Expand Down Expand Up @@ -985,9 +991,10 @@ void tcp_pcb_recycle(struct tcp_pcb *pcb)
pcb->flags = 0;
pcb->user_timeout_ms = 0;
pcb->ticks_since_data_sent = -1;
pcb->rto = 3000 / slow_tmr_interval;
// Set initial RTO to 1 second as per RFC 6298
pcb->rto = get_initial_rto();
pcb->sa = 0;
pcb->sv = 3000 / slow_tmr_interval;
pcb->sv = get_initial_rto();
pcb->nrtx = 0;
pcb->dupacks = 0;
pcb->rtime = -1;
Expand Down
20 changes: 20 additions & 0 deletions src/core/util/sys_vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1621,6 +1621,16 @@ void mce_sys_var::get_env_params()
tcp_timer_resolution_msec = timer_resolution_msec;
}

// RFC 1122 Section 4.2.3.2: Delayed ACK timer must not exceed 500ms
// This limits TCP timer resolution to ensure protocol compliance and proper RTO calculations
if (tcp_timer_resolution_msec > 500) {
vlog_printf(VLOG_WARNING,
"TCP timer resolution [%s=%d] exceeds RFC 1122 maximum of 500ms. "
"Clamping to 500ms to ensure protocol compliance.\n",
SYS_VAR_TCP_TIMER_RESOLUTION_MSEC, tcp_timer_resolution_msec);
tcp_timer_resolution_msec = 500;
}

if ((env_ptr = getenv(SYS_VAR_INTERNAL_THREAD_CPUSET))) {
snprintf(internal_thread_cpuset, FILENAME_MAX, "%s", env_ptr);
}
Expand Down Expand Up @@ -2744,6 +2754,16 @@ void mce_sys_var::configure_memory_limits(const config_registry &registry)
tcp_timer_resolution_msec = timer_resolution_msec;
}

// RFC 1122 Section 4.2.3.2: Delayed ACK timer must not exceed 500ms
// This limits TCP timer resolution to ensure protocol compliance and proper RTO calculations
if (tcp_timer_resolution_msec > 500) {
vlog_printf(VLOG_WARNING,
"TCP timer resolution [%s=%d] exceeds RFC 1122 maximum of 500ms. "
"Clamping to 500ms to ensure protocol compliance.\n",
SYS_VAR_TCP_TIMER_RESOLUTION_MSEC, tcp_timer_resolution_msec);
tcp_timer_resolution_msec = 500;
}

if (registry.value_exists("performance.threading.cpuset")) {
snprintf(internal_thread_cpuset, FILENAME_MAX, "%s",
registry.get_value<std::string>("performance.threading.cpuset").c_str());
Expand Down