Tweaking TCP's Congestion Control Algorithm

This document describes how to configure Transmission on Linux to use TCP-LP, a low-priority variant of TCP, for peer-to-peer connections.

Background

BitTorrent is a rather greedy protocol: we're all familiar with how a BitTorrent peer will happily gobble all the bandwidth that's available, leaving none for web browsing or online gaming. The standard solution is to artificially limit the throughput of a BitTorrent peer, typically to 80% or so of your line's available throughput. Doing this is not ideal: on the one hand, we're using just 80% of the available throughput, wasting the rest; on the other hand, the throughput used by BitTorrent remains constant, whle we'd like it to automatically drop when somebody starts browsing the web or playing online games.

The proper solution is to send the BitTorrent traffic at lower priority than the regular traffic, so that it automatically yields to normal priority traffic. Such low-priority traffic is sometimes called "less than best-effort" (LTBE) traffic, since it has lower priority than the normal "best-effort" traffic.

µTP   µTP is µTorrent's LTBE solution. µTP uses a fairly advanced congestion controller called LEDBAT, which is designed to minimise the delay caused by BitTorrent traffic. Unfortunately, µTP puts the data in a framing that is completely incompatible with TCP — you can only speak µTP with other µTP peers. (Additionally, the µTP framing has a number of flaws.) Transmissino supports µTP since version 2.10.

TCP-LP   TCP-LP is another LTBE solution. TCP-LP uses a more primitive congestion controller than µTP, but puts it within ordinary TCP framing: you can speak TCP-LP with ordinary TCP peers. Only traffic coming from the TCP-LP peer will actually be LTBE: TCP-LP is a sender-only modification of TCP.

Setting up your system for TCP-LP

In order to make TCP-LP available to Transmission, you need to run the following commands (as root):

modprobe tcp_lp
echo cubic reno lp > /proc/sys/net/ipv4/tcp_allowed_congestion_control

The first line loads TCP-LP into the kernel; the second one makes it available to non-root processes.

The simplest way to make this change permanent is to put these commands in /etc/rc.local.

Setting up Transmission for TCP-LP

By default, Transmission does not tweak TCP's congestion control algorithm, but uses the system's default (usually CuBIC). In order to make it use TCP-LP, you will need to make the following change to Transmission's settings file (see Transmission's documentation if you don't know how to do that):

peer-congestion-algorithm: "lp",

Since TCP-LP is a sender-only modification to TCP, you will still need to throttle your download throughput; it's only the upload throughput that will be automatically throttled by TCP-LP.