setsockopt with SO_SENDBUF/SO_RECVBUF is not working
I was using setsockopt with SO_SENDBUF/SO_RECVBUF for setting the send/receive buffer of TCP with 256*1024 bytes. But when I see in wireshark, I can see that the TCP's "Window Size" is shown as only 1525. Also wmem_max and rmem_max are set with values 131071(126开发者_如何学运维 kb).So ideally I was expecting it to be at least 128 kbps. can anyone please help with this ? Is this can also be a problem of wireshark where it is showing wrong "Window size".
You need to set that size on the listening socket at the server, before any accepts(), and at the client you need to set it on the socket before you connect it. That way you are allowing TCP's 'window scaling' option to take effect, which can only happen during the connect handshake. After the connection is established it is too late. That way the TCP receive window can be as large as the receive buffer, assuming various other conditions hold.
However unless you have an extraordinarily high-latency network with extraordinary bandwidth, 256k may be too large a size. There is no point whatsoever in setting it higher than the bandwidth-delay product
, which can be calculated as the bandwidth in bytes/second times the delay in seconds, giving a result in bytes.
精彩评论