Click to Rate and Give Feedback
MSDN
MSDN Library
Windows Versions
Specifications
General Information
 TCP Receive Window Size and Window ...
Published Protocols And Royalty-Free License
TCP Receive Window Size and Window Scaling

The Transmission Control Protocol (TCP) receive window size is the maximum amount of received data, in bytes, that can be buffered at one time on the receiving side of a connection. The sending host can send only that amount of data before waiting for an acknowledgment and window update from the receiving host.

Working with Receive Window Size in Windows TCP/IP

In Windows Server 2003, Windows XP, and Windows 2000, the Transmission Control Protocol/Internet Protocol (TCP/IP) stack tunes itself in most environments, using larger default window sizes than in earlier versions of Windows. Instead of using a hard-coded default receive window size, TCP as implemented in Windows Server 2003 adjusts the window size to even increments of the maximum segment size (MSS) negotiated during connection setup. Matching the receive window to even increments of the MSS increases the percentage of full-sized TCP segments used during bulk data transmission and thus helps minimize the number of segments sent when large sets of data are transmitted.

The default receive window size that TCP advertises in Windows Server 2003 depends on the following, in order of precedence:

  • The value for the SO_RCVBUF Windows Sockets option for the connection. This option specifies the total per-socket buffer space reserved for receive operations.
  • The per-interface TcpWindowSize registry value.
  • The GlobalMaxTcpWindowSize registry value.

    Note  For more information about the TcpWindowSize and GlobalMaxTcpWindowSize registry values, see the Windows Server 2003 Resource Kit documentation. To locate this documentation, see Windows Deployment and Resource Kits.

  • Autodetermination based on the bit rate of the transmission media, as reported by the network.

If none of the preceding sets the window size, the default receive window size is set as follows:

  • For a transmission below 1 megabit per second (Mbps), 8 KB.
  • For a 1-100 Mbps transmission, 17 KB.
  • For a transmission greater than 100 Mbps, 64 KB.

Note  For 10 and 100 Mbps Ethernet connections, the receive window is usually set to 17,520 bytes (17 KB rounded up to 12 1460-byte segments).

Working with Window Scaling in Windows TCP/IP

The TCP/IP standard allows for a receive window up to 65,535 octets in size, which is the maximum value that can be specified in the 16-bit TCP window size field. To improve performance on high-bandwidth, high-delay networks, Windows TCP/IP supports the ability to advertise receive window sizes larger than 65,535 octets, by using scalable windows as described in RFC 1323. Using window scaling, hosts in a conversation can negotiate a window size that allows multiple large packets, such as those often used in file transfer protocols, to be pending in the receiver's buffers.

RFC 1323 details a method for supporting larger receive window sizes by allowing TCP to negotiate a scaling factor for the window size at connection establishment. The Window Scale TCP header option enables the programmer to set an option called the shift count, which indicates how many bits to the left to shift the value in the window size field, to arrive at the actual window size. For example, a shift count of 1 shifts the stated window size value once to the left, in effect multiplying it by two (2^1). A shift count of 5 multiplies the stated window size by 32 (2^5). This method allows for an actual receive window of up to 1 gigabyte.

TCP window scaling is negotiated on demand in Windows Server 2003, based on the value set for the SO_RCVBUF Windows Sockets option when a connection is initiated. Additionally, the Window Scale option is used by default on a connection if the received SYN segment for that connection as initiated by a TCP peer contains the Window Scale option. Windows Server 2003 TCP does not initiate connections with window scaling by default. To instruct the Windows Server 2003 TCP stack to attempt to negotiate a larger receive window size by making use of the Window Scale option, set the Tcp1323Opts registry value to 1.

For more information on RFC 1323, see RFC 1323: TCP Extensions for High Performance.

Setting the Receive Window Size to a Specific Value

Two methods can be used to set the receive window size to a specific value:

  • Setting the TcpWindowSize registry value.
  • Calling the Windows Sockets function setsockopt, which sets the receive window on a per-socket basis.
If an application generally always requires the same receive window size any time it is run on a particular computer, or if the application's source code is not available, the window size might be best set using the registry. If, on the other hand, the application connects to many different communication partners whose traffic patterns and thus most efficient receive window sizes differ, it might be advisable to calculate and set the windows size programmatically with setsockopt.

See Also

Windows TCP Implementation Features

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2010 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker