I wanted to know if in TCP connection establishment , separate buffers each of size 2^16 bytes are allocated for separate TCP connections to separate Servers?

Question author Shubham-asthana | Source



Yes, separate buffers are allocated for send and receive. The amount of memory reserved initially depends on the default-configuration and if application chooses a different size using set_sockopt(). The initial reserved memory also grows as number of outgoing/incoming packets increase.

On Linux, the default values can be read/modified using the foll sysctls.

sudo sysctl -a | grep tcp | grep mem

net.ipv4.tcp_mem = 191133 254845 16777216

net.ipv4.tcp_rmem = 4096 16384 777216

net.ipv4.tcp_wmem = 4096 16384 16777216

You can use setsockopt() with SO_SNDBUF and SO_RCVBUF to modify it from application.

Answer author Akhil