title: Increasing TCP Window Size
body: <p>I have some doubts over increasing TCP Window Size in application. In my C++ software application, we are sending data packets of size around 1k from client to server using TCP/IP blocking socket. Recently I came across this concept TCP Window Size. So I tried increasing the value to 64K using <code>setsockopt()</code> for both <code>SO_SNDBUF</code> and <code>SO_RCVBUF</code>. After increasing this value, I get some improvements in performance for WAN connection but not in LAN connection.</p>
  
  <p>As per my understanding in TCP Window Size,</p>
  
  <p>Client will send data packets to server. Upon reaching this TCP Window Size, it will wait to make sure ACK received from the server for the first packet in the window size. In case of WAN connection, ACK is getting delayed from the server to the client because of latency in RTT of around 100ms. So in this case, increasing TCP Window Size compensates ACK wait time and thereby improving performance.</p>
  
  <p>I want to understand how the performance improves in my application.</p>
  
  <p>In my application, even though TCP Window Size (Both Send and Receive Buffer) is increased using <code>setsockopt</code> at socket level, we still maintain the same packet size of 1k (i.e the bytes we send from client to server in a single socket send). Also we disabled Nagle algorithm (inbuilt option to consolidate small packets into a large packet thereby avoiding frequent socket call).</p>
  
  <p>My doubts are as follows:</p>
  
  <ol>
  <li><p>Since I am using blocking socket, for each data packet send of 1k, it should block if ACK doesn't come from the server. Then how does the performance improve after improving the TCP window Size in WAN connection alone ? If I misunderstood the concept of TCP Window Size, please correct me.</p></li>
  <li><p>For sending 64K of data, I believe I still need to call socket send function 64 times ( since i am sending 1k per send through blocking socket) even though I increased my TCP Window Size to 64K. Please confirm this.</p></li>
  <li><p>What is the maximum limit of TCP window size with windows scaling enabled with RFC 1323 algorithm ?</p></li>
  </ol>
  
  <p>I am not so good in my English. If you couldn't understand any of the above, please let me know.</p>