- BIC (kernel module)
- New Reno (kernel module)
- CUBIC (kernel module)
- HSTCP (kernel module)
- HTCP (kernel module)
- Hybla (kernel module)
- Illinois (kernel module)
- Vegas (kernel module)
- Veno (kernel module)
- Westwood+ (kernel module)
- YeAH (kernel module)
$ cat /proc/sys/net/ipv4/tcp_congestion_controlSo, to change system-wide default you only have to write a name of congestion control algorithm to the same file. For example, to change it to reno you would do it this way:
cubic
# echo reno > /proc/sys/net/ipv4/tcp_congestion_controlNote that, to change the value, you have to be the root user. As the root you can specify any available congestion algorithm you wish. In the case the algorithm you specified isn't loaded into the kernel, via standard kernel module mechanism, it will be automatically loaded. To see what congestion control algorithms are currently loaded take a look into the content of the file /proc/sys/net/ipv4/tcp_available_congestion_control:
# cat /proc/sys/net/ipv4/tcp_congestion_control
reno
$ cat /proc/sys/net/ipv4/tcp_available_congestion_controlIt is also possible to change congestion control algorithm on a per-socket basis using setsockopt(2) system call. Here is the essential part of the code to do that:
vegas lp reno cubic
...In this fragment we are setting congestion control algorithm to reno. Note that that the constant TCP_CA_NAME_MAX (value 16) isn't defined in system include files so they have to be explicitly defined in your sources.
int s, ns, optlen;
char optval[TCP_CA_NAME_MAX];
...
s = socket(AF_INET, SOCK_STREAM, 0);
...
ns = accept(s, ...);
...
strcpy(optval, "reno");
optlen = strlen(optval);
if (setsockopt(ns, IPPROTO_TCP, TCP_CONGESTION, optval, optlen) < 0) {
perror("setsockopt");
return 1;
}
When you are using this way of defining congestion control algorithm, you should be aware of few things:
- You can change congestion control algorithm as an ordinary user.
- If you are not root user, then you are only allowed to use congestion control algorithms specified in the file /proc/sys/net/ipv4/tcp_allowed_congestion_control. For all the other you'll receive error message.
- No congestion control algorithm is bound to socket until it is in the connected state.
optlen = TCP_CA_NAME_MAX;Here you can download a code you can compile and run. To compile it just run gcc on it without any special options. This code will start server (it will listen on port 10000). Connect to it using telnet (telnet localhost 10000) in another terminal and the moment you do that you'll see that the example code printed default congestion control algorithm and then it changed it to reno. It will then close connection.
if (getsockopt(ns, IPPROTO_TCP, TCP_CONGESTION, optval, &optlen) < 0) {
perror("getsockopt");
return 1;
}
Instead of the conclusion I'll warn you that this congestion control algorithm manipulation isn't portable to other systems and if you use this in your code you are bound to Linux kernel.