Slow performance occurs when you copy data to a TCP server by using a Windows Sockets API program
On This PageSYMPTOMSWhen you run a program that uses the Windows Sockets API, you may experience slow performance when you copy data to a TCP server. If you make a network trace with a network sniffer such as Microsoft Network Monitor, the TCP server sends a TCP ACK segment to the last TCP segment in a TCP data stream in the delayed acknowledgement timer (also known as the delayed ACK timer). By default, for Windows operating systems, the value for this timer is 200 milliseconds (ms). A typical data flow for sending 64 kilobytes (KB) of data looks similar to the following sequence: Client->Server 1460 bytes Client->Server 1460 bytes Server->Client ACK Client->Server 1460 bytes Client->Server 1460 bytes Server->Client ACK .... Client->Server 1460 bytes Client->Server 1460 bytes Server->Client ACK-PUSH Client->Server 1296 bytes -> delayed ACK 200 ms CAUSEThis problem occurs because of the architectural behavior of the Windows Sockets API and Afd.sys. This problem occurs if all the following conditions are true:
WORKAROUNDTo work around this problem, use any of the following methods. Method 1: Use Blocking SocketsThis problem only occurs with non-blocking sockets. When you use a blocking socket, this problem does not occur because Afd.sys handles the socket buffer differently. For more information about blocking and non-blocking socket programming, see the Microsoft Platform SDK documentation.Method 2: Make the Socket Send Buffer Size Larger Than the Program Send Buffer SizeTo modify the socket send buffer, use the Windows Sockets getsockopt function to determine the current socket send buffer size (SO_SNDBUF), and then use the setsockopt function to set the socket send buffer size. When you are finished, the SO_SNDBUF value must be at least 1 byte larger than the program send buffer size.Modify the send call or the WSASend call to specify a buffer size at least 1 byte smaller than the SO_SNDBUF value. In the earlier example in the "Cause" section of this article, you could modify the setsockopt call to the following value, or you could modify the send call to the following value: You could also use any combination of these values.Method 3: Modify the TCP/IP Settings on the TCP ServerImportant This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:322756 (http://support.microsoft.com/kb/322756/) How to back up and restore the registry in Windows Modify the TCP/IP settings on the TCP server to immediately acknowledge incoming TCP segments. This workaround works best in an environment that has a large client installation base and where you cannot change the program's behavior. For scenarios where the remote TCP server runs on a Windows-based server, you must modify the registry of the remote server. For other operating systems, see the operating system's documentation for information about how to change the delayed acknowledgement timer. On a server that runs Windows 2000, follow these steps:
Method 4: Modify the buffering behavior in Afd.sys for non-blocking socketsImportant This section, method, or task contains steps that tell you how to modify the registry. However, serious problems might occur if you modify the registry incorrectly. Therefore, make sure that you follow these steps carefully. For added protection, back up the registry before you modify it. Then, you can restore the registry if a problem occurs. For more information about how to back up and restore the registry, click the following article number to view the article in the Microsoft Knowledge Base:322756 (http://support.microsoft.com/kb/322756/) How to back up and restore the registry in Windows Note This registry key is only available for Windows Server 2003 with Service Pack 1 and subsequent service packs.
STATUSMicrosoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. REFERENCES328890 (http://support.microsoft.com/kb/328890/) New registry entry for controlling the TCP Acknowledgment (ACK) behavior in Windows XP and in Windows Server 2003
APPLIES TO
| Article Translations
|

Back to the top
