In the WinNT network architecture a layer is placed on top of the TCPIP layer called AFD(Ancillary Function Driver for Winsock). The AFD provides the winsock interface, which is used by most network applications in Windows and is also supporting things like DNS and DHCP.
The AFD uses two windows which acts as a flowcontrol for the application creating the socket:
- Send Window: Used when the application is sending data over a connection, if more data is sent than the receiver is able to acknowledge then the AFD-Send-Window will block the transfer for the application, when it reaches the limit of the AFD-Send-Window. The application creating the socket can use setsockopt to adjust SO_SNDBUF.
- Receive Window: Acts just like the TCPIP-Receive Window, and when creating a Winsocket over TCPIP, then AFD will use the TCPIP Receive Window as AFD-Receive Window. The application creating the socket can use setsockopt to adjust SO_RCVBUF.
- 4096 bytes if less than 19 MByte RAM
- 8192 bytes if more than 19 MByte RAM
To set the default size of the AFD-Windows use the following DWORD registry keys :
Note that the AFD-Windows should be rounded to a multiple of memory page size (Usually 4096 Bytes). Not a multiple of the Maximum Segment Size(MSS) which is recommended for the TCPIP-Window.
[HKEY_LOCAL_MACHINE \SYSTEM \CurrentControlSet \Services \Afd \Parameters]
DefaultReceiveWindow = 16384
DefaultSendWindow = 16384
Related : Recommended settings for the TCP/IP stack
More Info MSDN - Write Scalable Winsock Apps Using Completion Ports
More info MS KB214397
More info MS KB246984
More info MS KB311084