Role of the TCP Stack
The TCP (Transmission Control Protocol) stack is part of the OS kernel that- Manages Reliable Transport
- Handles packet ordering, retransmission, and acknowledgment (ACKs).
- Ensures no data is lost, duplicated, or delivered out of order.
- Implements Flow Control
- Uses the sliding window mechanism to prevent overwhelming the receiver.
- Implements Congestion Control
- Reacts to network conditions (e.g., packet loss or delay) to adjust transmission rates.
- Integrates with the OS Networking Subsystem
- Interacts with the IP layer, NIC drivers, and user-space sockets (bind(), send(), etc.).
- Supports features like NAT traversal, QoS, TCP Fast Open, and ECN (Explicit Congestion Notification).
Role of Congestion Algorithms
Congestion Algorithms determine how fast TCP can send data, especially under varying network conditions. Modern algorithms:- Adjust the congestion window (cwnd) dynamically.
- Try to avoid congestion (proactively) and recover quickly if it happens.
Let's deep dive into options we have in FreeBSD 14 and how we can use them ...
TCP Stack
FreeBSD 14.2 currently supports three TCP stacks.
- freebsd (default FreeBSD TCP stack)
- rack (RACK-TLP Loss Detection Algorithm for TCP aka Recent ACKnowledgment is modern loss recovery stack)
- bbr (Bottleneck Bandwidth and Round-Trip Time Algorithm)
We can check current TCP stack
root@FBSD-01:~ # sysctl -a | grep net.inet.tcp.functions_default
net.inet.tcp.functions_default: freebsd
Now we can change TCP stack to TCP stack rack
kldload tcp_rack
sysctl net.inet.tcp.functions_default=rack
and check current TCP stack again
root@FBSD-01:~ # sysctl -a | grep net.inet.tcp.functions_default
net.inet.tcp.functions_default: rack
Now we can change TCP stack to TCP stack bbr
kldload tcp_bbr
sysctl net.inet.tcp.functions_default=bbr
and check current TCP stack again
root@FBSD-01:~ # sysctl -a | grep net.inet.tcp.functions_default
net.inet.tcp.functions_default: bbr
If we want to switch it back to default FreeBSD TCP stack, we can use command below
sysctl net.inet.tcp.functions_default=freebsd
and can check current TCP stack
root@FBSD-01:~ # sysctl -a | grep net.inet.tcp.functions_default
net.inet.tcp.functions_default: freebsd
Congestion Algorithms
FreeBSD 14.2 supports following congestion algorithms
- cubic (default)
- newreno
- htcp
- vegas
- cdg
- chd
To change congestion algorithm, we have to load cc module and switch algorithm as shown below.
root@FBSD-01:~ # kldload cc_newreno
root@FBSD-01:~ # sysctl net.inet.tcp.cc.algorithm=newreno
net.inet.tcp.cc.algorithm: cubic -> newreno
We can check current CC algoritm
The procedure to change other algorithms is the same, the only change is algorithm name.
No comments:
Post a Comment