Skip to content

masterofdaemon/anti-collision

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Anti-Collision Bandwidth Saturator (two-ip-ru)

This tool is a specialized network utility designed to maintain internet connection stability by proactively managing bandwidth usage.

🎯 The Business Logic (Why this exists)

Some internet connections (especially certain ISP configurations, long-range wireless links, or congested shared channels) suffer from "packet collisions" or degradation when the connection is idle or has low traffic. This manifests as packet loss, high latency, or complete drops during light usage.

The Solution: "Jerk" the connection awake. By forcing high-throughput traffic, we force the network hardware (modems, ISP switches) to prioritize the active stream, renegotiate channel parameters, and clear out collision states.

The Automation Cycle

This tool implements an intelligent state machine to fix the connection only when necessary, avoiding wasted bandwidth.

  1. 🔍 Monitoring (Check Phase)

    • Every cycle, the tool performs a 5-second sample download from a high-speed target (ThinkBroadband).
    • It measures the real-time throughput.
  2. 🧠 Decision Logic

    • Threshold: 30 Mbps
    • Case A (Healthy): If speed is ≥ 30 Mbps, the connection is considered good.
      • Action: Sleep for 1 hour. The tool stays quiet.
    • Case B (Degraded): If speed is < 30 Mbps, the connection is considered "colliding" or unstable.
      • Action: Enter Saturation Mode.
  3. 🌊 Saturation Mode (The Fix)

    • The tool opens 8 concurrent, high-speed download streams.
    • This saturates the bandwidth (typically reaching 100-200+ Mbps).
    • Recovery Condition: It keeps saturating until the speed stays above 30 Mbps for at least 15 continuous seconds.
    • Crash Guard: If saturation does not improve by at least 1 Mbps for 2 minutes, the process exits with code 101 so an external watchdog can restart/report it.
    • Once recovered, it returns to the Sleep cycle.

🚀 Usage

Installation

Ensure you have Rust installed.

cargo build --release

Running

Run the binary directly:

./target/release/two-ip-ru

Or via Cargo:

cargo run --release

Windows builds

The easiest way to produce a Windows .exe from macOS is to let GitHub Actions build it. This repo includes a workflow at .github/workflows/build.yml that uploads:

  • two-ip-ru.exe
  • two-ip-ru-gui.exe

Customization

By default, it targets ThinkBroadband's speed test file. You can override this by passing a URL as an argument:

./target/release/two-ip-ru https://example.com/large-file.bin

When using cargo run, remember to pass args after --:

cargo run --release -- https://example.com/large-file.bin

🛠 Configuration

The behavior is controlled by constants in src/main.rs:

  • THRESHOLD_MBPS: Speed required to be considered "Healthy" (Default: 30.0).
  • SLEEP_DURATION: How long to rest after a healthy check (Default: 3600s / 1 hour).
  • CHECK_DURATION: Duration of the initial speed sample (Default: 5s).
  • STREAMS: Number of parallel download connections (Default: 8).
  • SATURATION_STAGNATION_TIMEOUT: Maximum saturation time without meaningful growth (Default: 120s).
  • SATURATION_MIN_GROWTH_MBPS: Growth required to reset the stagnation timer (Default: 1.0 Mbps).

📊 Logs

The tool logs all actions with timestamps for easy debugging:

[2024-01-31 12:00:00] CHECKING: Measuring current speed (5s sample)...
  Current: 45.20 Mbps
[2024-01-31 12:00:05] OK: Speed is 45.20 Mbps. Sleeping for 1 hour...

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages