Hrishikesh Murali
Hrishikesh Murali

Reputation: 99

Change congestion control algorithms per connection

The command 'sysctl' in linux as of now changes the congestion control algorithm globally for the entire system. But congestion control, where the TCP window size and other similar parameters are varied, are normally done per TCP connection. So my question is:

Or am I missing something trivial here? If so, what is it?

Upvotes: 5

Views: 7054

Answers (5)

Mikko Rantalainen
Mikko Rantalainen

Reputation: 15925

As far as I know, there's no way to change default TCP congestion control per process (I'd love bash script being able to say that whatever is executed by this script should default the congestion control lp).

The only user mode API I'm aware of is as follows:

setsockopt(socket, SOL_TCP, TCP_CONGESTION, congestion_alg, strlen(congestion_alg));

where socket is an open socket, and congestion_alg is a string containing one of the words in /proc/sys/net/ipv4/tcp_allowed_congestion_control.

Upvotes: 0

FormerNcp
FormerNcp

Reputation: 126

In newer versions of Linux it is possible to set the congestion control for a specific destination using ip route ... congctl .

If anyone are familiar with this approach, please edit this post.

Upvotes: 1

rupello
rupello

Reputation: 8491

This is done in iperf using the -Z option - the patch is here.

This is how it is implemented (PerfSocket.cpp, line 93) :

    if ( isCongestionControl( inSettings ) ) {
#ifdef TCP_CONGESTION
    Socklen_t len = strlen( inSettings->mCongestion ) + 1;
    int rc = setsockopt( inSettings->mSock, IPPROTO_TCP, TCP_CONGESTION,
                 inSettings->mCongestion, len);
    if (rc == SOCKET_ERROR ) {
        fprintf(stderr, "Attempt to set '%s' congestion control failed: %s\n",
            inSettings->mCongestion, strerror(errno));
        exit(1);
    }
#else
    fprintf( stderr, "The -Z option is not available on this operating system\n");
#endif

Where mCongestion is a string containing the name of the algorithm to use

Upvotes: 7

Jan
Jan

Reputation: 31

It seems this is possible via get/setsockopt. The only documentation i found is: http://lkml.indiana.edu/hypermail/linux/net/0811.2/00020.html

Upvotes: 3

ismail
ismail

Reputation: 47572

Linux has pluggable congestion algorithms which can change the algorithm used on the fly but this is a system wide setting not per connection.

Upvotes: -1

Related Questions