Discussion:
How to change TCP SYN window advertisement size
(too old to reply)
Anand
2003-09-08 07:25:05 UTC
Permalink
Hi Group,

Anybody know how to change the advertise window size of TCP SYN
packet. Is it possible to do this without editing registry settings?
Is there any SOCKET option for this?
* SO_SNDBUF option not actually changing the advertise window size
value. When I tried this option TCP sending SYN with default window
size only. i.e if SO_SNDBUF size is less than default windows size
then it advertising default window size only.

I want to set advertise windows size less than 4K for testing purpose.
Any idea?

Thanks in advance.
Vadim
2003-09-08 12:22:31 UTC
Permalink
Hi

It can be set globally for all interfaces or for the specified one. See
registry parameters below (quote from C-header file):

// The TcpWindowSize parameter can be used to set the receive window on a
per-interface
// basis. This parameter can be used to set a global limit for the TCP
window size on a
// system-wide basis.
// System Key:
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters]
// Name: GlobalMaxTcpWindowSize
// Type: REG_DWORD (DWORD Value)
// Value: 0?0x3FFFFFFF (Default = 0xFFFF)
#define REGSTR_VAL_GLOBAL_MAX_TCP_WINDOW_SIZE TEXT("GlobalMaxTcpWindowSize")
#define GLOBAL_MAX_TCP_WINDOW_SIZE_DEFAULT 0xFFFF

// TcpWindowSize
// Key: Tcpip\Parameters, Tcpip\Parameters\Interface\interface
// Value Type: REG_DWORD?number of bytes
// Valid Range: 0?0x3FFFFFFF (1073741823 decimal). In practice the TCP/IP
stack will round the number set to the nearest multiple of maximum segment
size (MSS). Values greater than 64 KB can be achieved only when connecting
to other systems that support RFC 1323 Window Scaling, which is discussed in
the "Transmission Control Protocoal (TCP)" section of this document.
// Default: The smaller of the following values:
// - 0xFFFF
// - GlobalMaxTcpWindowSize (another registry parameter)
// - The larger of four times the maximum TCP data size on the network
// - 16384 rounded up to an even multiple of the network TCP data size
// The default can start at 17520 for Ethernet, but may shrink slightly when
the connection
// is established to another computer that supports extended TCP head
options, such as SACK
// and TIMESTAMPS, because these options increase the TCP header beyond the
usual 20 bytes,
// leaving slightly less room for data.
// Description: This parameter determines the maximum TCP receive window
size offered.
// The receive window specifies the number of bytes that a sender can
transmit without
// receiving an acknowledgment. In general, larger receive windows improve
performance over
// high-delay, high-bandwidth networks. For greatest efficiency, the receive
window should
// be an even multiple of the TCP Maximum Segment Size (MSS). This parameter
is both a
// per-interface parameter and a global parameter, depending upon where the
registry key is
// located. If there is a value for a specific interface, that value
overrides the
// system-wide value. See also GlobalMaxTcpWindowSize.
#define REGSTR_VAL_TCP_WINDOW_SIZE TEXT ("TcpWindowSize")


Regards,
Vadim Smirnov
http://www.ntkernel.com
Post by Anand
Hi Group,
Anybody know how to change the advertise window size of TCP SYN
packet. Is it possible to do this without editing registry settings?
Is there any SOCKET option for this?
* SO_SNDBUF option not actually changing the advertise window size
value. When I tried this option TCP sending SYN with default window
size only. i.e if SO_SNDBUF size is less than default windows size
then it advertising default window size only.
I want to set advertise windows size less than 4K for testing purpose.
Any idea?
Thanks in advance.
Anand
2003-09-09 02:01:06 UTC
Permalink
Post by Vadim
It can be set globally for all interfaces or for the specified one. See
Changing registry settings will affect all the TCP connections in the
interface. I want to set only for particular connections. How about in
Linux or FreeBSD?
Michael Fuhr
2003-09-09 03:48:45 UTC
Permalink
Post by Anand
Post by Vadim
It can be set globally for all interfaces or for the specified one. See
Changing registry settings will affect all the TCP connections in the
interface. I want to set only for particular connections. How about in
Linux or FreeBSD?
In your original message you said that you had tried setting the
SO_SNDBUF socket option. The window size tells how much data you're
prepared to *receive*, so you should be changing the receive buffer
size, not the send buffer size. Try setting SO_RCVBUF.

Depending on the operating system, you may or may not get the exact
buffer size you requested. Your original message said that you
wanted a window size less than 4K for testing, so getting a specific
size may not matter as long as it's less than 4K.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
arkadyf
2003-09-11 18:35:03 UTC
Permalink
But anycase , SO_RCVBUF/SO_SNDBUF is size of buffers winsock use to collect
the data
on system level before it will be moved to driver, and TcpWindowSize is
parameter used by driver
Arkady
Post by Michael Fuhr
Post by Anand
Post by Vadim
It can be set globally for all interfaces or for the specified one. See
Changing registry settings will affect all the TCP connections in the
interface. I want to set only for particular connections. How about in
Linux or FreeBSD?
In your original message you said that you had tried setting the
SO_SNDBUF socket option. The window size tells how much data you're
prepared to *receive*, so you should be changing the receive buffer
size, not the send buffer size. Try setting SO_RCVBUF.
Depending on the operating system, you may or may not get the exact
buffer size you requested. Your original message said that you
wanted a window size less than 4K for testing, so getting a specific
size may not matter as long as it's less than 4K.
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
Anand
2003-09-16 02:16:27 UTC
Permalink
Post by arkadyf
But anycase , SO_RCVBUF/SO_SNDBUF is size of buffers winsock use to collect
the data
on system level before it will be moved to driver, and TcpWindowSize is
parameter used by driver
Yes. I tried SO_RCVBUF also but SYN packet not advertising with the
value set by SO_RCVBUF option. It advertising default value only :-(
Arkady Frenkel
2003-09-16 08:21:11 UTC
Permalink
Sounds strange because SO_RCVBUF/SO_SNDBUF parameter is for setting winsock
buffer , which still app level and kernel ( driver's ) level
Arkady
Post by Anand
Post by arkadyf
But anycase , SO_RCVBUF/SO_SNDBUF is size of buffers winsock use to collect
the data
on system level before it will be moved to driver, and TcpWindowSize is
parameter used by driver
Yes. I tried SO_RCVBUF also but SYN packet not advertising with the
value set by SO_RCVBUF option. It advertising default value only :-(
Rick Jones
2003-09-16 17:24:04 UTC
Permalink
Post by Anand
Yes. I tried SO_RCVBUF also but SYN packet not advertising with the
value set by SO_RCVBUF option. It advertising default value only :-(
It is likely a silly question, but you are making the setsockopt()
call(s) before calling connect() or listen() yes?

Also, after the SYN exchange, does the advertised window change to
more closely match your setsockopt() call?

rick jones
--
Wisdom Teeth are impacted, people are affected by the effects of events.
these opinions are mine, all mine; HP might not want them anyway... :)
feel free to post, OR email to raj in cup.hp.com but NOT BOTH...
Anand
2003-09-18 03:10:52 UTC
Permalink
Post by Rick Jones
It is likely a silly question, but you are making the setsockopt()
call(s) before calling connect() or listen() yes?
Yes.
Post by Rick Jones
Also, after the SYN exchange, does the advertised window change to
more closely match your setsockopt() call?
rick jones
No. I'm using windows'XP. It does not advertising with the value set
in setsockopt. As far as I know SO_RCVBUF/SO_SNDBUF options are meant
for internal buffer size to be used by the TCP and its not related to
SYN advertisement window value.

(Again if change registry settings then it will affect all the TCP
connections in the PC).

There should be someother ways to do this. I'm looking for that. And I
dont know it is possible or not.

Thanks.
inf
2003-10-19 06:45:42 UTC
Permalink
Post by Anand
Post by arkadyf
But anycase , SO_RCVBUF/SO_SNDBUF is size of buffers winsock use to collect
the data
on system level before it will be moved to driver, and TcpWindowSize is
parameter used by driver
Yes. I tried SO_RCVBUF also but SYN packet not advertising with the
value set by SO_RCVBUF option. It advertising default value only :-(
i did a test, i ran a simple cli/serv that exchanges a file on
localhost. i changed the servers socketsendbuffer size TWICE on both
sockets just to be anal. none of the resulting packets from the server
ever advertised a window greater than the default. now i havent gotten
far enuf in tcp vol 2 yet, but iirc i read that the send buffer sizes
are for individual sockets, i.e. they dont have an effect on the actual
tcp buffer sizes. i think it is a kernel buffer(not sure if that's the
righ term), as in how much the kernel will queue for you before telling
you it's full, but not directly related to the tcp buffer.
inf
2003-10-19 06:46:25 UTC
Permalink
Post by Anand
Post by arkadyf
But anycase , SO_RCVBUF/SO_SNDBUF is size of buffers winsock use to collect
the data
on system level before it will be moved to driver, and TcpWindowSize is
parameter used by driver
Yes. I tried SO_RCVBUF also but SYN packet not advertising with the
value set by SO_RCVBUF option. It advertising default value only :-(
i did a test, i ran a simple cli/serv that exchanges a file on
localhost. i changed the servers socketsendbuffer size TWICE on both
sockets just to be anal. none of the resulting packets from the server
ever advertised a window greater than the default. now i havent gotten
far enuf in tcp vol 2 yet, but iirc i read that the send buffer sizes
are for individual sockets, i.e. they dont have an effect on the actual
tcp buffer sizes. i think it is a kernel buffer(not sure if that's the
righ term), as in how much the kernel will queue for you before telling
you it's full, but not directly related to the tcp buffer.
Chris Pearson
2003-10-20 17:21:21 UTC
Permalink
Post by Anand
I 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.

Loading...