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? TIME-WAIT
or CLOSED
?
we know in linux system, FIN-WAIT-2 can be set in the file /proc/sys/net/ipv4/tcp_fin_timeout: man tcp(7)
tcp_fin_timeout (integer; default: 60; since Linux 2.2)
This specifies how many seconds to wait for a final FIN packet before the socket is forcibly closed. 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.
TCP_LINGER2 (since Linux 2.4)
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.
I'm not so sure about the state this TCP socket will go after FIN_WAIT2
time runs out, be forcibly closed,transit to CLOSED
? or just jump into the TIME-WAIT
state?
I made a test:
1 : echo 3 > /proc/sys/net/ipv4/tcp_fin_timeout
2 : benchmark the tomcat runs on the linux
It turned out that lots of TIME-WAIT
appeared in netstat
and was accumulating, did that mean after the FIN_WAIT2
time ran out, the socket jumped into TIME-WAIT
?
One more question:
I changed this :
echo 1 > /proc/sys/net/ipv4/tcp_tw_reuse
as the others say: "to reuse the socket",and keep tcp_fin_timeout:3
. but nothing changed, TIME-WAIT
was just accumulating. Does tcp_tw_reuse
have nothing to do with the socket in TIME-WAIT
state, the TIME-WAIT
socket can't be reused ?
It seems like echo 1 > /proc/sys/net/ipv4/tcp_tw_recycle
can reduce the TIME-WAIT
count,and keep it a low level,leave the load balance problem alone.