Solved

How do I change TCP_NODELAY in Linux

Posted on 2010-09-15
4
2,146 Views
Last Modified: 2012-05-10
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
Comment
Question by:ericluoma
  • 4
4 Comments
 
LVL 3

Accepted Solution

by:
T1750 earned 500 total points
ID: 33687422
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
 
LVL 3

Expert Comment

by:T1750
ID: 33687456
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
 
LVL 3

Expert Comment

by:T1750
ID: 33687464
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
 
LVL 3

Expert Comment

by:T1750
ID: 33687503
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

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question