title: what state will the active closer go when FIN-WAIT-2 time runs out?
body: <p>when FIN_WAIT2 time runs out and the last FIN doesn't come from the other side,what's the next state will the active closer be? <code>TIME-WAIT</code> or <code>CLOSED</code> ?</p>
  
  <p>we know in linux system, FIN-WAIT-2 can be set in the file /proc/sys/net/ipv4/tcp_fin_timeout: man tcp(7)</p>
  
  <blockquote>
    <ul>
    <li><p>tcp_fin_timeout (integer; default: 60; since Linux 2.2)</p>
    
    <blockquote>
      <p>This specifies how many seconds to wait for a final FIN packet before the socket is <strong><em>forcibly closed</em></strong>.  This is strictly a violation of the TCP specification, but required to prevent denial-of-service attacks.  In Linux 2.2, the default value was 180.</p>
    </blockquote></li>
    <li><p>TCP_LINGER2 (since Linux 2.4)</p>
    
    <blockquote>
      <p>The lifetime of orphaned FIN_WAIT2 state sockets.This option can be used to override the system-wide setting in the file /proc/sys/net/ipv4/tcp_fin_timeout for this socket.  This is not to be confused with the socket(7) level option SO_LINGER.  This option should not be used in code intended to be portable.</p>
    </blockquote></li>
    </ul>
  </blockquote>
  
  <p>I'm not so sure about the state this TCP socket will go after <code>FIN_WAIT2</code> time runs out, be <strong><em>forcibly closed</em></strong>,transit to <code>CLOSED</code>? or just jump into the <code>TIME-WAIT</code> state? </p>
  
  <p>I made a test:</p>
  
  <blockquote>
    <p>1 : echo 3 > /proc/sys/net/ipv4/tcp_fin_timeout</p>
    
    <p>2 : benchmark the tomcat runs on the linux</p>
  </blockquote>
  
  <p>It turned out that lots of <code>TIME-WAIT</code> appeared in <code>netstat</code> and was accumulating, did that mean after the <code>FIN_WAIT2</code> time ran out, the socket jumped into <code>TIME-WAIT</code>?</p>
  
  <p>One more question:
  I changed this : 
  <code>echo 1 &gt; /proc/sys/net/ipv4/tcp_tw_reuse</code> as the others say: "to reuse the socket",and keep <code>tcp_fin_timeout:3</code>. but nothing changed,  <code>TIME-WAIT</code> was just accumulating. Does <code>tcp_tw_reuse</code> have nothing to do with the socket in <code>TIME-WAIT</code> state, the <code>TIME-WAIT</code> socket can't be reused ?</p>
  
  <p>It seems like <code>echo 1 &gt; /proc/sys/net/ipv4/tcp_tw_recycle</code> can reduce the <code>TIME-WAIT</code> count,and keep it a low level,leave the load balance problem alone.</p>