I've heard that we can avoid the issue of "too many TIME_WAIT" with the help of IP_TRANSPARENT in TCP/IP connection. In this way, it seems that a RST is used to disconnect, instead of FIN and ACK.

But I don't quite understand how to achieve this.


Note that, since you didn't mentionned which OS you're working with, i'll assume that it's GNU/Linux (which maybe a bad assumption since this is "UNIX & Linux").

Tweaking kernel behaviour

Under Linux, tweaking your TCP stack at runtime is usually achieved using sysctl and/or procfs.

So you probably should start by having a look to:

  • tcp(7) manpage
  • Files under Documentation/sysctl/ on your kernel source code. (You can also use this site).

To see if there's some options/parameter that would allow that.

One step further

After a quick look at kernel source code ( net/ipv4/tcp.c ) it looks that the use of FIN flag to shutdown is "hardcoded" and can't be changed... sorry.

Maybe you can try to write a patch to change this behaviour... but i wouldn't push in production server such a patch ;-)

To conclude

It looks that there's no way to do what you asked for.

Nevertheless, maybe you can mitigate the "too many TIME_WAIT" issue by tweaking some other parameters such as net.ipv4.tcp_fin_timeout (also reachable at /proc/sys/net/ipv4/tcp_fin_timeout).

Note that, if you have the hand on your application source code, you can also tweak its behaviour using setsockopt() on the created socket.

  • I was told that using IP_TRANSPARENT to send a packet to the server and the server will regard this as a new incoming so it will send back an ACK. However, this ACK will send to the client, who is willing to close the connection. And this ACK will make the client send a RST to the server. In the end, the connection is shutdown. – Yves Jan 3 '20 at 1:12
  • you see it might be reasonable, but I can't how figure it out with all details. – Yves Jan 3 '20 at 1:13
  • Use IP_TRANSPARENT where ? – binarym Jan 3 '20 at 9:00
  • You see this is what I don't know and what I'm trying to figure out... What I've known is that it might simulate a RST attack to avoid TIME_WAIT with the help of IP_TRANSPARENT. – Yves Jan 4 '20 at 2:27
  • Source ? Cause IP_TRANSPARENT is a socket option which is actually used for proxying ... (see man 7 ip). Anyway, this option is available with AF_INET socket type, and this socket type doesn't allow you to set headers by yourself ... so it looks like you're looking the wrong direction... – binarym Jan 4 '20 at 10:40

Not IP_TRANSPARENT, but here might be a different solution to your issue.

(Posting as an answer rather than as a comment so that the code block is readable)

If your Linux machine is a client, rather than a server, then you might experiment with the following in /etc/sysctl.conf one at a time or together, then sysctl -p. Please look into what each one does to see if each is appropriate for your use.

net.ipv4.ip_local_port_range = 2000 65535
net.ipv4.tcp_tw_reuse = 1

Great article explaining the gory details: https://vincent.bernat.ch/en/blog/2014-tcp-time-wait-state-linux

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.