Linux - NetworkingThis forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
I'm trying to decrease the tcp TIME_WAIT state which, from what I understand, occurs on the host that initiates the closing of a socket by sending a packet with the FIN bit set.
Most people say to change /proc/sys/net/ipv4/tcp_fin_timeout to a lesser value. I have tried this many times and it makes no difference. The TIME_WAIT's still linger for ~ 60 seconds.
Time to hold socket in state FIN-WAIT-2, if it was closed by our side. Peer can be broken and never close its side, or even died unexpectedly. Default value is 60sec. Usual value used in 2.2 was 180 seconds, you may restore it, but remember that if your machine is even underloaded WEB server, you risk to overflow memory with kilotons of dead sockets, FIN-WAIT-2 sockets are less dangerous than FIN-WAIT-1, because they eat maximum 1.5K of memory, but they tend to live longer. Cf. tcp_max_orphans.
Here's what the netstat man page says about these two different states:
Quote:
TIME_WAIT
The socket is waiting after close to handle packets still in the network.
FIN_WAIT2
Connection is closed, and the socket is waiting for a shutdown from the remote end.
Can someone tell me how to actually decrease the TIME_WAIT state?
Well first of all I would like to say that TIME_WAIT is for maintaining the reliability. It is not a good idea to close a connection forcefully when it is in TIME_WAIT state.
Although I would not suggest but you can change the TIME_WAIT settings in the following files to lower the limit. Default is 0 which means it will wait until the connection clears itself:
/proc/sys/net/ipv4/tcp_tw_recycle
and
/proc/sys/net/ipv4/tcp_tw_reuse
Also an easy way of clearing up the time_wait connection is to restart your network service which I think you would not like to do: service network restart.
To me, TIME_WAIT is not so much about "reliability." It is there just in case the host receives any stray packets after the connection has already been closed.
Changing /proc/sys/net/ipv4/tcp_tw_recycle and /proc/sys/net/ipv4/tcp_tw_reuse to 1 seem to allow the OS to quickly reuse those TIME_WAIT sockets;however this seems a bit too aggressive. I still would like the TIME_WAIT to expire, just would like to do it quickly, like after 5 seconds instead of ~ 1 minute.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.