Tcp_Tw_Reuse VS Tcp_Tw_Recycle:Which to Use (Or Both)

Why is tcp_tw_reuse turned off by default?

Saw a great article on this today, that provides a really in depth answer that I thought anyone that ran across this question should have:

http://vincent.bernat.im/en/blog/2014-tcp-time-wait-state-linux.html

After reviewing it, it looks like the change I made to use tcp_tw_reuse doesn't even impact incoming connections, so it appears that my original solution was a fruitless change on my part.

error setting net.ipv4.tcp_tw_reuse & net.ipv4.tcp_tw_recycle in sysctl.conf

So that syntax is for the linux kernel, and you would use 1 or 0 for true/false, not the actual spelled out words. So in your example, it would be:

net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1

If you're trying to adjust this setting in OSX on your Mac, then it's a different syntax. It would be:

net.inet.tcp.msl=1000

Hope that helps.

Why would connect() give EADDRNOTAVAIL?

Check this link

http://www.toptip.ca/2010/02/linux-eaddrnotavail-address-not.html

EDIT: Yes I meant to add more but had to cut it there because of an emergency

Did you close the socket before attempting to reconnect? Closing will tell the system that the socketpair (ip/port) is now free.

Here are additional items too look at:

  • If the local port is already connected to the given remote IP and port (i.e., there's already an identical socketpair), you'll receive this error (see bug link below).
  • Binding a socket address which isn't the local one will produce this error. if the IP addresses of a machine are 127.0.0.1 and 1.2.3.4, and you're trying to bind to 1.2.3.5 you are going to get this error.
  • EADDRNOTAVAIL: The specified address is unavailable on the remote machine or the address field of the name structure is all zeroes.

Link with a bug similar to yours (answer is close to the bottom)

http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4294599

It seems that your socket is basically stuck in one of the TCP internal states and that adding a delay for reconnection might solve your problem as they seem to have done in that bug report.



Related Topics



Leave a reply



Submit