Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

setsockopt and tcp window size

1,876 views
Skip to first unread message

Tobias

unread,
Feb 19, 2002, 9:38:48 AM2/19/02
to
Hi everybody,

I've asked this one on comp.os.ms-windows.programmer.tools.winsock
before but could not find much help. So I try again here.

What I'd like to do is to increase the TCP window size for certain
connection by using setsockopt(). After much struggle I found that
I can use (SOL_SOCKET, SO_RVCBUF) or (IPPROTO_TCP, SO_RCVBUF)
options to do this, but only if the specified buffer size is less than
64 kB; if it exceeds this value, everything seems to work fine
(setsockopt() succeeds, and in the case of (SOL_SOCKET, SO_RVCBUF),
getsockopt() reports the specified buffer size, at least on Win2k/WinXP),
but the window size falls back to its standard value of ~8 kB.

Unfortunately, the above mentioned 64 kB are not enough (the connections
in questions are via a satellite link). I need something in the range of 350
kB.
How can I persuade Windows (both NT and 9x) to increase the windows
size above 64 kB (using 1323 enhancements)?

I know that I can adjust some registry settings, but then the increased
window size will apply to all connections, not only those that need it,
and this increased window size creates problems of its own.

The relevant options under
HKLM\CurrentControlSet\Services\TcpIp\Parameters
are Tcp1323Opts = 3, GlobalMaxTcpWindowSize = 1000000, and SackOpts = 1,
TcpWindowSize is not set.

I did not change anything below HKLM\CurrentControlSet\Services\AFD.

TIA
Tobias

arkadyf

unread,
Feb 19, 2002, 11:29:28 AM2/19/02
to
Look at Q224829 & Q263088 for W2K/XP scenario
In 9x/NT you have two options
setsockopt() for single socket and registry for TcpWindowSize which is for
all WinSock as you wrote
Arkady

Tobias <tob...@nospam.org> wrote in message
news:3c726378$0$29260$9b62...@news.freenet.de...

Tobias

unread,
Feb 20, 2002, 2:13:35 AM2/20/02
to
"arkadyf" <ark...@hotmail.com> wrote in message
news:OEqVhKWuBHA.2056@tkmsftngp03...

> Look at Q224829 & Q263088 for W2K/XP scenario
> In 9x/NT you have two options
> setsockopt() for single socket and registry for TcpWindowSize which is for
> all WinSock as you wrote
> Arkady
>

Thanks for your reply. I've already known these two articles. My problem is
that
I don't want to set the window size globally with the TcpWindowSize value,
yet if I use setsockopt() I can increase the window size only up to 2^16-1
Bytes,
even though I enabled the scaling windows option (and timestamps) by setting
Tcp1323Opts to 3 (under Services\TcpIP\Parameters; I did not configure
individual parameters). Once using a buffer of >= 64 kB in setsockopt(),
Win2k falls back to the standard ~ 16kB (or somtimes ~ 8 kB). I verified
this
with tcpdump, and also the throughput reaches only ~ 25 kB over the
satellite link
(instead if 200 kB with a window of 2^16 -1 Bytes).

So what is wrong?

Tobias

arkadyf

unread,
Feb 20, 2002, 3:28:43 AM2/20/02
to
Sorry Tobias ,it was evening and I didn't really understand the problem
but as Q199947 for NT it's impossible and stands that 64 K is max window
size for NT.
Q239705 for Win9x stands that's with Vtcp.386 it's do possible to read
correctly Tcp1323Opts registry data
but TcpWindowSize not in the list so it's the same as NT .
As for W2K I didn't understand If you do set global as you wrote

> even though I enabled the scaling windows option (and timestamps) by
setting
> Tcp1323Opts to 3 (under Services\TcpIP\Parameters;
is it work ( BTW you wrote about tcpdump , but it'd UNIX sniffer , maybe you
mean Windump , just interested ) ?
And other question about numbers

> (instead if 200 kB with a window of 2^16 -1 Bytes
it's have to by 64 K , not 200 K ?
How you can see with a sniffer a TcpWindowSize , it's global buffer size
for send/receive , but sniffer shows individual
frames ( packets ) with max of 1460 MSS ( in ethernet ) ?
More questions then answer :)
Arkady

Tobias <tob...@nospam.org> wrote in message

news:3c734c9f$0$29258$9b62...@news.freenet.de...

Tobias

unread,
Feb 20, 2002, 8:12:05 AM2/20/02
to
"arkadyf" <ark...@hotmail.com> wrote in message
news:#2v1hieuBHA.2204@tkmsftngp04...

> Sorry Tobias ,it was evening and I didn't really understand the problem

no problem :-)

> but as Q199947 for NT it's impossible and stands that 64 K is max window
> size for NT.

Well, that's a pity, bit fortunately not my problem :). I only want to use
1323
on Win98/ME and NT 5.x.

> Q239705 for Win9x stands that's with Vtcp.386 it's do possible to read
> correctly Tcp1323Opts registry data
> but TcpWindowSize not in the list so it's the same as NT .
> As for W2K I didn't understand If you do set global as you wrote
> > even though I enabled the scaling windows option (and timestamps) by
setting
> > Tcp1323Opts to 3 (under Services\TcpIP\Parameters;
> is it work ( BTW you wrote about tcpdump , but it'd UNIX sniffer , maybe
you
> mean Windump , just interested ) ?

No and yes. No, it does not work, i.e., Win2k does not use TCP window
scaling
when I increase the buffer with setsockopt() above 64 kB (but it does work
if I
set TcpWindowSize; but once again: I only want to increase the window size
for connections that need it, i.e., connections over a satellite link);
on Win2k a value of 64 kB or more for the buffer in setsockopt() have
no effect at all (they don't even increase the TCP window to 64 kB, the
maximum
without 1323).

And yes, it's Windump, of course.

> And other question about numbers
> > (instead if 200 kB with a window of 2^16 -1 Bytes
> it's have to by 64 K , not 200 K ?
> How you can see with a sniffer a TcpWindowSize , it's global buffer size
> for send/receive , but sniffer shows individual
> frames ( packets ) with max of 1460 MSS ( in ethernet ) ?
> More questions then answer :)
> Arkady

The current size of the window is included in the header of every TCP packet
that is sent to the peer and just informs the peer how much data it can send
without the overflowing receiver's buffers. Just let Windump analyse the
header
and it will tell you what the window in each packet is. And it shows me a
maximum window of 2^16 - 1 Bytes and no window scaling.

Tobias

arkadyf

unread,
Feb 20, 2002, 9:24:06 AM2/20/02
to
Hi , Tobias !
Oh , I see I need to ask more

this is line from my WinDump :
10:56:30.237959 ARKADY-NT.1025 > 140.1.50.1.139: P 134:258(124) ack 40 win
8448 (DF)

do you mean 8448 in your situation is 64 K ?

But his is window field ( forth word of TCP header ( indexed from 1 ) ,
right WORD of it )
It cannot be more than 64 K because it take 16 bits in all ?
So is it really more that 64 K in the case of W2K
Excuse me my laziness to go to W2K ( I so stick to NT ) and change the
registry :)
TIA
Arkady


Tobias <tob...@nospam.org> wrote in message

news:3c73a0a4$0$12295$9b62...@news.freenet.de...

arkadyf

unread,
Feb 20, 2002, 9:43:33 AM2/20/02
to
Sorry forgot to add about your problems , but Q263088 state exactly this ,
that you cannot in W2K use socket configuration but
only global setting of TCPWindowSize and Q239705 that it's impossible for
9x :(

Next portion of questions :)
Some details to previous my message , as I see from Q224829 they use option
scale because this window size really cannot exceed 64K or Windump show it
like 64K*scale factor in this case ?
TIA
Arkady

arkadyf <ark...@hotmail.com> wrote in message

news:ud#UFphuBHA.2688@tkmsftngp07...

Tobias

unread,
Feb 21, 2002, 1:43:40 AM2/21/02
to
"arkadyf" <ark...@hotmail.com> wrote first:

> Hi , Tobias !
> Oh , I see I need to ask more
>
> this is line from my WinDump :
> 10:56:30.237959 ARKADY-NT.1025 > 140.1.50.1.139: P 134:258(124) ack 40 win
> 8448 (DF)
>
> do you mean 8448 in your situation is 64 K ?

Yes, if I use setsockopt( sock, SOL_SOCKET, SO_RCVBUF, (1 << 16) - 1,
sizeof( int ) ).

> But his is window field ( forth word of TCP header ( indexed from 1 ) ,
> right WORD of it )
> It cannot be more than 64 K because it take 16 bits in all ?

Exactly. To increase the window size the two peers can agree during the
standard three-way TCP handshake that this field does NOT mean the window
but instead a negotiated multiple of this, e.g., twice as much. This is
called
window scaling (please refer to RFC 1323 for this, they can explain this
much
better than I :-)

> So is it really more that 64 K in the case of W2K

No, it is not larger, but if you set the TcpWindowSize value to something
above 64 kB, Win2k uses window scaling and so this window size field
in the TCP header means, say, twice as much as specified.

> Excuse me my laziness to go to W2K ( I so stick to NT ) and change the
> registry :)
> TIA
> Arkady

and later:

> Sorry forgot to add about your problems , but Q263088 state exactly this
,
> that you cannot in W2K use socket configuration but
> only global setting of TCPWindowSize and Q239705 that it's impossible
for
> 9x :(

I think you got something wrong here. If you set TcpWindowSize directly
under
HKLM\System\CurrentControlSet\Services\TcpIP\Parameters, Win2k uses this
window size for ALL connections (with window scaling if necessary).
You can also set TcpWindowSize under
HKLM\System\CurrentControlSet\Services\TcpIP\Parameters\Adapters\<some
interface>
and then Win2k will use this value as the window size for all connections on
this
interface, but Q263088 says that this does not work when this value exceeds
64 kB
because of a bug in the code that parses this calue. There's no such problem
if you use HKLM\System\CurrentControlSet\Services\TcpIP\Parameters instead.

> Next portion of questions :)
> Some details to previous my message , as I see from Q224829 they use
option
> scale because this window size really cannot exceed 64K or Windump show
it
> like 64K*scale factor in this case ?
> TIA
> Arkady

Windump analyzes only one packet at a time and does not keep track of
connections.
The scaling factor is negotiated during connection establishment, and
Windump
does not keep this information. If you want to know whether a particular TCP
connection
uses window scaling and what the real window is, you have to look at the
options
negotiated during connection establishment. Look out for option 3 in all TCP
packets
with the SYN flag set.

Tobias

arkadyf

unread,
Feb 24, 2002, 9:51:57 AM2/24/02
to
Hi , Tobias !
So as resolution of Q263088 state that you need or use TCPWindowSize value
globally ( registry ) or use value on individual
( per interface ) setting use value with less than 64240.
Because you don't like :) both variants , my last proposition .
To make setsockopt with SO_SNDBUF with 0 which mean no Windows buffer but
yours
And use your big buffer. It's not recommended , only but stream apps with
overlapped operations.
Let's assume that it's your case :)
Try it and I believe that you'll write the results here
Arkady

Tobias <tob...@nospam.org> wrote in message

news:3c74971a$0$29268$9b62...@news.freenet.de...

gilles

unread,
Feb 27, 2002, 11:02:06 AM2/27/02
to
arkadyf wrote:

Hi guys an thanx for this interesting thread.
I've a similar problem I think.
I need to tuned tcpwinsize in win98SE registry but the key I use doesn't
works. I see it when I sniff the network. I use DefaultRcvWindow (see
below), a string with a value of 65330 and w98 always uses the default
value of 6*MSS (8340 for me).

So if one of you make it works, I'll be very very gratefull to knox how
cause I try without success since a week.

Thanx
Gilles

Win 98 registry key :
HKLM\System\CurrentControlSet\Services\VxD\MSTCP
DefaultRcvWindow
Data Type: DWORD
For Windows 98, the Data Type is a String value.

arkadyf

unread,
Feb 28, 2002, 4:50:50 AM2/28/02
to
As MSDN stated it's possible only for W2K and XP only
Look at Q239705 for 9x :(
Arkady

gilles <gba...@ifrance.com> wrote in message
news:a5ivua$1447$1...@norfair.nerim.net...

Tobias

unread,
Mar 19, 2002, 4:26:14 AM3/19/02
to
"gilles" <gba...@ifrance.com> wrote in message
news:a5ivua$1447$1...@norfair.nerim.net...

> Hi guys an thanx for this interesting thread.


> I've a similar problem I think.
> I need to tuned tcpwinsize in win98SE registry but the key I use doesn't
> works. I see it when I sniff the network. I use DefaultRcvWindow (see
> below), a string with a value of 65330 and w98 always uses the default
> value of 6*MSS (8340 for me).
>
> So if one of you make it works, I'll be very very gratefull to knox how
> cause I try without success since a week.
>
> Thanx
> Gilles
>
> Win 98 registry key :
> HKLM\System\CurrentControlSet\Services\VxD\MSTCP
> DefaultRcvWindow
> Data Type: DWORD
> For Windows 98, the Data Type is a String value.


Hi Gilles,

we had the same problem. If I remember correctly, Win98SE,
as it comes out of the box, does not read the DefaultRcvWindow
value correctly. The following patch should solve your problem:
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q236926
(even though this article does not mention DefaultRcvWindow; just
give it a try).

Hope this helps

Tobias

arkadyf

unread,
Mar 19, 2002, 11:28:44 AM3/19/02
to
Hi , Tobias !
Did you succeed in the you business at the end , did you read my last
proposition to set setsockopt with SO_SNDBUF with 0 and work with your big
buffer. You didn't put your address so I couldn't ask you before.
Arkady

Tobias <tob...@nospam.org> wrote in message

news:3c970440$0$158$9b62...@news.freenet.de...

0 new messages