Compartilhar via


TCP Receive Window Size Calculation and Window Scaling (Windows CE 5.0)

Send Feedback

The TCP receive window size is the amount of receive data (in bytes) that can be buffered at one time on a connection. The sending host can send only that amount of data before waiting for an acknowledgment and window update from the receiving host. The Windows CE TCP/IP stack was designed to tune itself in most environments, and uses larger default window sizes than earlier versions. Instead of using a hard-coded default receive window size, TCP adjusts 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.

The receive window size defaults to a value calculated as follows:

  1. The first connection request sent to a remote host advertises a receive window size of 16 KB (16,384) in Windows CE 3.0 and later. In Window CE 2.12, the advertised receive window size is 8 KB.

  2. Upon establishing the connection, the receive window size is rounded up to an increment of the maximum TCP segment size (MSS) which was negotiated during connection setup.

  3. If that is not at least four times the value of MSS, then it is adjusted to four times the value of MSS, with a maximum size of 64 KB, unless a window scaling option (RFC 1323) is in effect.

    Note   In the Common.reg file for Windows CE 3.0 and later, TCPWindowSize was changed to 32 KB for Windows CE operating systems. Because USB operates at high speeds, a larger windows size, such as 32 KB, works better. If you do not set TCPWindowSize, the TCP/IP stack is 16 KB by default.

You can set the receive window size to a specific value by setting the **TcpWindowSize****registry entry described in TCP/IPv4 Configurable Registry Settings.

To improve performance on high-bandwidth, high delay networks, RFC 1323 support has been introduced in Windows CE. This RFC details a method for supporting scalable windows by allowing TCP to negotiate a scaling factor for the window size at connection establishment. This allows for an actual receive window of up to 1 gigabyte (GB). RFC 1323 Section 2.2 provides the following description of window scaling:

2.2 Window Scale Option

The three-byte Window Scale option may be sent in a SYN segment by a TCP. It has two purposes: (1) indicate that the TCP is prepared to do both send and receive window scaling, and (2) communicate a scale factor to be applied to its receive window. Thus, a TCP that is prepared to scale windows should send the option, even if its own scale factor is 1. The scale factor is limited to a power of two and encoded logarithmically, so it may be implemented by binary shift operations.

   TCP Window Scale Option (WSopt):

      Kind: 3 Length: 3 bytes

             +---------+---------+---------+
             | Kind=3  |Length=3 |shift.cnt|
             +---------+---------+---------+

This option is an offer, not a promise; both sides must send Window Scale options in their SYN segments to enable window scaling in either direction. If window scaling is enabled, then the TCP that sent this option will right-shift its true receive-window values by Shift.cnt bits for transmission in SEG.WND. The value Shift.cnt can be zero (offering to scale, while applying a scale factor of 1 to the receive window).

This option may be sent in an initial <SYN> segment (for example, a segment with the SYN bit on and the ACK bit off). It may also be sent in a <SYN,ACK> segment, but only if a Window Scale option was received in the initial <SYN> segment. A Window Scale option in a segment without a SYN bit should be ignored.

The Window field in a SYN (for example, a <SYN> or <SYN,ACK>) segment itself is never scaled.

When you read network traces of a connection that was established by two computers that support scalable windows, keep in mind that the window sizes advertised in the trace must be scaled by the negotiated scale factor. The scale factor can be observed in the connection establishment (3-way handshake) packets.

Windows CE uses window scaling automatically if the TcpWindowSize registry entry is set to a value greater than 64 KB. Window scaling can be disabled with the Tcp1323Opts registry entry.

See Also

Transmission Control Protocol (TCP)

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.