Skip to content
This repository was archived by the owner on May 18, 2025. It is now read-only.

v2TLS/TCP-Brutal

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

61 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

TCP Brutal (Enhanced Version)

Overview

TCP Brutal is an enhanced version of the original TCP Brutal, offering a user-friendly, maintainable, and extensible TCP congestion control kernel module. It introduces advanced runtime configuration and monitoring features, making it suitable for operators, developers, and researchers.

Key Differences from the Original Brutal:

  • Runtime Parameter Tuning: Supports hot-updating key algorithm parameters via both sysfs and procfs, without requiring module reload.
  • Machine-Readable Monitoring: Exposes detailed, machine-friendly statistics under /proc/brutal_stats for easy automated collection.
  • Sysfs Integration: All tunable parameters are visible and writable in /sys/module/brutal/parameters/.
  • Better Logging & Robustness: Enhanced error logging, boundary checks, and documentation for easier debugging and integration.
  • Full Backward Compatibility: All core TCP Brutal logic is preserved; only the configuration and monitoring experience is extended.

For Users

Installation

Quick install script:

bash <(curl -fsSL https://tcp.hy2.sh/)

Manual build and load:

# Ensure kernel headers are installed (e.g. Ubuntu: apt install linux-headers-$(uname -r))
make && make load

Requires Linux kernel 4.9 or later (5.8+ recommended).
On kernels older than 5.8, IPv6 is not supported.
On kernels older than 4.13, you MUST manually enable fq pacing:
tc qdisc add dev eth0 root fq pacing

Monitoring and Tuning

  • All key parameters (initial rate, cwnd_gain) can be viewed and changed at runtime:
    • Sysfs:
      cat /sys/module/brutal/parameters/param_init_rate
      echo 200000 > /sys/module/brutal/parameters/param_init_rate
      
    • Procfs (stats):
      cat /proc/brutal_stats
      
      Output is machine-readable, e.g.:
      initial_rate:125000
      initial_cwnd_gain:20
      min_pacing_rate:62500
      ...
      
  • No kernel reload or module reload is needed for parameter changes.

For Developers

This kernel module provides the brutal TCP congestion control algorithm, which can be enabled in any TCP socket using TCP_CONGESTION:

s.setsockopt(socket.IPPROTO_TCP, TCP_CONGESTION, b"brutal")

Setting Algorithm Parameters

To set the send rate and congestion window gain at runtime (recommended: cwnd_gain 1.5x–2x, i.e. 15–20):

struct brutal_params {
    u64 rate;      // Send rate in bytes per second
    u32 cwnd_gain; // CWND gain in tenths (10=1.0)
} __packed;
import socket, struct
TCP_BRUTAL_PARAMS = 23301
rate = 2_000_000  # 2 MB/s
cwnd_gain = 15
brutal_params_value = struct.pack("QI", rate, cwnd_gain)
conn.setsockopt(socket.IPPROTO_TCP, TCP_BRUTAL_PARAMS, brutal_params_value)

Compatibility

  • TCP BrutalX does not change the TCP protocol, only congestion control—works unilaterally on client or server.
  • Programs must use the custom sockopt to fully leverage BrutalX (most do not by default).
  • All features of the original Brutal are preserved; BrutalX simply makes the system easier to operate and monitor.

Example: Speed Test

The example directory contains a simple Python speed test client/server:

# Server: listens on TCP port 1234
python server.py -p 1234

# Client: connects to example.com:1234, requests 50 Mbps
python client.py -p 1234 example.com 50

Why choose TCP BrutalX over original Brutal?

  • No more module reloads for parameter tuning—change settings on the fly!
  • Easier monitoring: /proc/brutal_stats is ready for your scripts and dashboards.
  • Cleaner codebase: More robust error handling, easier to maintain and extend.
  • Perfect for automation and research: Integrate with your configuration management and observability stack.

License

GPL v3. See LICENSE.


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •