localhost loopback tcp connection in Windows: increase the bottleneck of 65535 bytes per segment

The scenario that I have is as such: I have a loopback TCP session and I want to improve its performance. I have my socket-like objects (System.Net.Sockets in .NET Framework, to be specific) sending messages of up to about 9MB each flowing in both directions of the TCP connection. I have observed typical delays of about 20ms for such a big message to get to the other side.

With WireShark, I found that the TCP flow is limited by 65535 bytes per segment. I’m suspecting this is the bottleneck of the speed performance. In the TCP headers, the window scaling option is enabled, and the calculated window size is sufficiently huge. I’m suspecting that the “TCP Option – Maximum segment size” (MSS) in the SYN packet is what limits the size of each TCP segment. Please see the WireShark images, and point out if I’m wrong.

the size-limited TCP segments, and the window scaling options
The SYN packet and the MSS

Now comes back to the question in the title. In Windows 7/8/10/11, is there any way to upraise this TCP segment size limit? I’m hoping to find a method that increases the MSS only for loopback connections or only for certain ports or something.

Answer

A TCP segment is encapsulated by an IP packet which is generally limited to 65,535 bytes (2^16-1) since the Total Length field is 16 bit. That’s the end of the ladder for both TCP and IP.

If you can’t achieve the bandwidth you require you need either faster hardware or faster software. By default, my desktop box runs ~35 Gbit/s single-threaded. You might want to ask over at Stack Overflow for optimizing your code.

Attribution
Source : Link , Question Author : yu quan , Answer Author : Zac67

Leave a Comment