Skip to content

Conversation

@aljazdu
Copy link

@aljazdu aljazdu commented Dec 10, 2025

Purpose

This fix solves an issue caused by default Windows behaviour, where the receiver (host) does not send Acknowledgment immediately when receiving packets, but rather waits up to 200ms before sending the ACK. Because of this, the device believes the host is not reading packets fast enough, which causes a warning.

Specification

Immediate acknowledgment is now forced, similar to TCP_QUICKACK

Dependencies & Potential Impact

None / not applicable

Deployment Plan

None / not applicable

Testing & Validation

This was tested on a Windows testbed, with an example where such issues were observed.

@aljazdu aljazdu requested a review from moratom December 10, 2025 11:54
@aljazdu aljazdu self-assigned this Dec 10, 2025
@moratom moratom requested a review from Copilot December 11, 2025 11:49
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses a Windows-specific networking issue where delayed TCP acknowledgments (up to 200ms) cause false warnings about slow packet reading. The fix implements immediate ACK behavior on Windows using WSAIoctl, similar to the existing TCP_QUICKACK implementation for other platforms.

Key Changes:

  • Added Windows-specific code to force immediate TCP acknowledgments using WSAIoctl with the vendor-specific IOC code
  • Positioned the Windows implementation before the existing TCP_QUICKACK block to maintain platform-specific handling

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

#if (defined(_WIN32) || defined(_WIN64) )
// Force immediate ACKs
int freq = 1;
DWORD bytes;
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The magic number 23 in _WSAIOW(IOC_VENDOR, 23) lacks explanation. Add a comment explaining that this is the Windows-specific code for TCP_MAXRT (or the specific ACK behavior being configured), as this vendor-specific ioctl code is not self-documenting.

Suggested change
DWORD bytes;
DWORD bytes;
// The magic number 23 in _WSAIOW(IOC_VENDOR, 23) is a Windows-specific vendor IOCTL code
// used to configure TCP immediate ACK behavior (sometimes referred to as TCP_MAXRT).
// This is not a standard IOCTL and is not self-documenting; see Microsoft documentation for details.

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added this as a macro on top

Comment on lines 1121 to 1123
int freq = 1;
DWORD bytes;
if(WSAIoctl(sock, _WSAIOW(IOC_VENDOR, 23), &freq, sizeof(freq), NULL, 0, &bytes, NULL, NULL) != 0)
Copy link

Copilot AI Dec 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The variable name 'freq' is unclear in this context. Consider renaming to 'enableImmediateAck' or 'immediateAckFlag' to better reflect its purpose of enabling immediate TCP acknowledgments.

Suggested change
int freq = 1;
DWORD bytes;
if(WSAIoctl(sock, _WSAIOW(IOC_VENDOR, 23), &freq, sizeof(freq), NULL, 0, &bytes, NULL, NULL) != 0)
int enableImmediateAck = 1;
DWORD bytes;
if(WSAIoctl(sock, _WSAIOW(IOC_VENDOR, 23), &enableImmediateAck, sizeof(enableImmediateAck), NULL, 0, &bytes, NULL, NULL) != 0)

Copilot uses AI. Check for mistakes.
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this has been clarified in the updated version

@aljazdu
Copy link
Author

aljazdu commented Dec 15, 2025

This has been fixed with server side TCP_NODELAY setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants