How to adjust TCP Window Size?
Solution 1:
I'm not 100% convinced your issue is really window-size related. Still, below you can find the relevant info.
The base window size can not exceed 65535 bytes due to limitations of the TCP header. From RFC 1323:
The TCP header uses a 16 bit field to report the receive window size to the sender. Therefore, the largest window that can be used is 2**16 = 65K bytes.
This does not means the TCP window can't be bigger, as modern OSes support (and advertise by default) TCP Window Scaling, where the window size is dynamically increased via scaling by up to 14X factor. However, an upper limit can be configured before hitting maximum scaling.
For reference, these are the relevant parameters (and their defaults) on Ubuntu 20.04:
net.ipv4.tcp_window_scaling = 1 ;scaling enabled
net.ipv4.tcp_rmem = 4096 131072 6291456 ;min, default and max receive window
net.ipv4.tcp_wmem = 4096 16384 4194304 ;min, default and max send window
net.core.rmem_max = 212992 ;max absolute limit for receive buffer
net.core.wmem_max = 212992 ;max absolute limit for send buffer
The actual maximum window size is the smaller between [r|w]mem_max
and the third value of tcp_[r|w]mem
. So on Ubuntu 20.04 you have an actual max receive and send window of 212992 bytes by default. To increase that limit to 4 MB you can do the following:
sysctl -w net.core.rmem_max=4194304
sysctl -w net.core.wmem_max=4194304
If it works, you can persist the settings by editing /etc/sysctl.conf