Skip to content

samples: modbus: tcp_server: improve server latency #89099

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed

Conversation

araneusdiadema
Copy link
Contributor

Add TCP_NODELAY to disable Nagle's algorithm - significantly reduces server latency

When reading or writing modbus registers in continuous mode without closing connection (or port) between each read or write, the server latency increases from few milliseconds to above 50ms. This behavior was observed independently of different hardware configurations, e. g. ESP32-S3-DevKitC-1 (connected by Wi-Fi), XMC4700-Relax-kit or a custom board with Wiznet W5500 + STM32G0B1RE (both connected by ethernet).

After logging packets with Wireshark, cause was found in long delay between client query and server response. Disabling Nagle's algorithm in TCP stack completely solved this issue.

Add TCP_NODELAY to disable Nagle's algorithm - significantly reduces server latency

Signed-off-by: Petr Vilím <[email protected]>
Add TCP_NODELAY to disable Nagle's algorithm (fixed code formating)

Signed-off-by: Petr Vilím <[email protected]>
@araneusdiadema araneusdiadema deleted the pv_modbus_tcp branch April 25, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants