Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Increase the TCP receive window for a specific socket

How to increase the TCP receive window for a specific socket? - I know how to do so for all the sockets by setting the registry key TcpWindowSize, but how do do that for a specific one?

According to MSFT's documents, the way is

Calling the Windows Sockets function setsockopt, which sets the receive window on a per-socket basis.

But in setsockopt, it is mentioned about SO_RCVBUF :

Specifies the total per-socket buffer space reserved for receives. This is unrelated to SO_MAX_MSG_SIZE and does not necessarily correspond to the size of the TCP receive window.

So is it possible? How?

Thanks.

like image 417
rkellerm Avatar asked May 05 '10 14:05

rkellerm


People also ask

How does TCP increase window size?

On Linux systems, you can check that full TCP window scaling is enabled by looking at the value in /proc/sys/net/ipv4/tcp_window_scaling. On Cisco devices, you can adjust the the window size using the global configuration command, “ip tcp window-size”.

How do I increase the TCP buffer size in Windows?

TCP window scale is an option used to increase the maximum window size from 65,535 bytes to 1 Gigabyte. The window scale option is used only during the TCP three-way handshake. The window scale value represents the number of bits to left-shift the 16-bit window size field.

What is the maximum size of the receive window in a TCP header?

The TCP header value allocated for the window size is two bytes long. This means that the highest possible numeric value for a receive window is 65,535 bytes.


2 Answers

SO_MAX_MSG_SIZE is for UDP. Here's from MSDN:

SO_MAX_MSG_SIZE - Returns the maximum outbound message size for message-oriented sockets supported by the protocol. Has no meaning for stream-oriented sockets.

It's also not settable.

For TCP just use SO_(SND|RCV)BUF.

like image 83
Nikolai Fetissov Avatar answered Nov 15 '22 05:11

Nikolai Fetissov


I am fairly sure that SO_RCVBUF is what you want. The first link says that SO_RCVBUF has the highest priority for determining the TCP window size over and above anything set on the system. From the way I am reading it, I think that all second part is saying is that the SO_RCVBUF size does not have to match the system receive window size. In other words, it can be a different size that you set.

like image 41
Genesis Avatar answered Nov 15 '22 03:11

Genesis