• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2434
  • Last Modified:

How do I change TCP_NODELAY in Linux

I want to disable the nagle algo on my NIC's due to the type of streaming I am doing, but I cannot find a resouce that says how this is done.
0
ericluoma
Asked:
ericluoma
  • 4
1 Solution
 
T1750Commented:
Here is how to do it for a single socket so you could patch your program. I'll have a further look around for mangling with the filters to do it with all traffic.

int sock = socket( AF_INET, SOCK_STREAM, 0 );
int flag = 1;
int ret = setsockopt( sock, IPPROTO_TCP, TCP_NODELAY, (char *)&flag, sizeof(flag) );
if (ret < 0 ) {
  perror("TCP_NODELAY");
  exit( EXIT_FAILURE );
}
0
 
T1750Commented:
You can run a simple proxy server that does nothing but proxy your connection through a socket with TCP_NODELAY set and have iptables transparently NAT it, but coding that is a bit beyond my skill and would take a couple of hours research. A good idea might be to download a SOCKS proxy server and patch it so it's outbound sockets are set as above then run your streaming through the proxy.
0
 
T1750Commented:
Another solution would be to compile a module that exports socket as a symbol, creates the socket and then returns the value of the socket. You could inject it into your programs with LD_PRELOAD.
0
 
T1750Commented:
On solaris you can disable nagle system-wide with:

sysctl -w net.ipv4.tcp_abc=0

I just put the same into my Linux box and it accepted the command so I assume it has done the same, but I don't have time to test it.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now