Linux – Change congestion control algorithms per connection

congestion-controllinuxsysctl

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:

  • Does there exist a way where I can change the congestion control algorithm being used per TCP connection?

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

Best Answer

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

Related Topic