Post by AnandI tried SO_RCVBUF also but SYN packet not advertising with the
value set by SO_RCVBUF option. It advertising default value only :-(
The MSDN article at http://www.microsoft.com/technet/treeview/default.asp?url=/technet/prodtechnol/windows2000serv/reskit/tcpip/part1/tcpch02.asp
implies that you can set receive window size with setsockopt(), but
neglects to mention which option! Good ol' M$. This implies that the
writer of the article didn't know much about Winsock, which means he
could be completely mistaken. Good article, well worth reading,
though. Snippet following.
The main takeaway for me is that the specific behavior of the TCP
stack is highly dependent on Windows version, so any tuning needs to
be version aware.
-- Chris
TCP Receive Window Size Calculation and Window Scaling
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
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 acknowledgments for
data sent and window updates from the receiving host. Windows 2000
TCP/IP is 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 kilobytes (KB) or 16,384 bytes.
2. Upon establishing the connection, the receive window size is
rounded up to an integral multiple of the TCP maximum segment size
(MSS) that was negotiated during connection setup.
3. If the rounded-up value is not at least four times the MSS, then it
is adjusted to 4 * MSS, with a maximum size of 64 KB, unless a window
scaling option (RFC 1323) is in effect.
For Ethernet-based TCP connections, the window is normally set to
17,520 bytes, or 16 KB rounded up to twelve 1,460-byte segments. In
previous versions of Microsoft® Windows NT® TCP/IP, the Ethernet
window used was 8,760 bytes, or six MSS-sized segments.
There are two methods for setting the receive window size to specific
values:
- The TcpWindowSize registry entry
(HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Interface\
<interface>).
- On a per-socket basis with the setsockopt( ) Windows Sockets
function.
To improve performance on high-bandwidth, high-delay networks, Windows
2000 TCP supports TCP window scaling described in RFC 1323. TCP window
scaling supports TCP receive window sizes larger that 64 KB by
negotiating a window scaling factor during the TCP three-way
handshake. This allows for a receive window of up to 1 gigabyte (GB).
When you read captures of a connection that was established by two
computers that support scalable windows, keep in mind that the window
sizes advertised in the segment must be scaled by the negotiated scale
factor. The window scale factor only appears in the first two segments
of the TCP three-way handshake. The scale factor is 2s, where s is the
negotiated scale factor. For example, for an advertised window size of
65535 and a scale factor of 3, the actual receive window size is
524280, or 23 * 65535.