bufferbloat but high speed
This commit is contained in:
@@ -14,6 +14,7 @@ pub struct NetworkConfig {
|
||||
pub client_muxer_capacity: usize, // Подушка для 10 ног
|
||||
pub client_tun_capacity: usize, // Стык TUN <-> Engine
|
||||
pub client_stream_capacity: usize, // Быстрый Backpressure для сокета
|
||||
pub client_virtual_stream_capacity: usize,
|
||||
|
||||
// Для Сервера (Дата-центр)
|
||||
pub server_muxer_capacity: usize, // Огромная очередь для входящего трафика
|
||||
@@ -42,19 +43,19 @@ impl NetworkConfig {
|
||||
|
||||
tcp_chunk_size: 16 * 1024,
|
||||
|
||||
client_muxer_capacity: 256,
|
||||
client_muxer_capacity: 32,
|
||||
client_tun_capacity: 16,
|
||||
client_stream_capacity: 32,
|
||||
client_stream_capacity: 16,
|
||||
client_virtual_stream_capacity: 8,
|
||||
|
||||
// --- СЕРВЕР ---
|
||||
server_muxer_capacity: 128,
|
||||
server_stream_capacity: 32,
|
||||
|
||||
tcp_rx_heavy: 256 * 1024,
|
||||
tcp_tx_heavy: 512 * 1024,
|
||||
tcp_rx_heavy: 256 * 1024, //download
|
||||
tcp_tx_heavy: 128 * 1024, //upload
|
||||
|
||||
tcp_rx_light: 256 * 1024,
|
||||
tcp_tx_light: 32 * 1024,
|
||||
tcp_rx_light: 64 * 1024, //download
|
||||
tcp_tx_light: 64 * 1024, //upload
|
||||
|
||||
udp_buf_heavy: 256 * 1024,
|
||||
udp_meta_heavy: 512,
|
||||
|
||||
@@ -127,17 +127,6 @@ impl ClientHandler {
|
||||
tokio::net::TcpSocket::new_v6().map_err(|e| e.to_string())?
|
||||
};
|
||||
|
||||
// 3. 🛡️ БАЛАНСИРУЕМ БУФЕРЫ ЯДРА
|
||||
// 256 KB для отправки (Send) — это "золотая середина" для пинга ~300мс.
|
||||
// Математически это позволит разогнать Upload до ~7-8 Мбит/с без 9-секундных лагов.
|
||||
if let Err(e) = socket.set_send_buffer_size(NetworkConfig::global().tcp_tx_heavy as u32) {
|
||||
warn!("Failed to set SO_SNDBUF on {}: {}", leg_name, e);
|
||||
}
|
||||
|
||||
// 🚨 ВАЖНО: Мы НЕ ставим set_recv_buffer_size вручную.
|
||||
// Это позволяет ОС использовать TCP Window Scaling и Auto-tuning,
|
||||
// что вернет твою скорость Download к 80+ Мбит/с.
|
||||
|
||||
// 4. Подключаемся
|
||||
let stream = socket
|
||||
.connect(addr)
|
||||
|
||||
@@ -2,14 +2,14 @@ use std::time::Duration;
|
||||
|
||||
// --- Лимиты системы ---
|
||||
pub const MAX_SOCKETS: usize = 2048; // Лимит сокетов в SocketSet (Anti-DDoS)
|
||||
pub const MAX_TUNNEL_LEGS: u32 = 10; // Максимальное кол-во физических соединений (Legs)
|
||||
pub const MUXER_POOL_SIZE: usize = 2; // Из скольких лучших Leg-ов выбирать для балансировки
|
||||
pub const MAX_TUNNEL_LEGS: u32 = 6; // Максимальное кол-во физических соединений (Legs)
|
||||
pub const MUXER_POOL_SIZE: usize = 3; // Из скольких лучших Leg-ов выбирать для балансировки
|
||||
|
||||
// --- Таймауты ---
|
||||
pub const TCP_HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(20); // Время на установку SYN/ACK
|
||||
pub const UDP_IDLE_TIMEOUT: Duration = Duration::from_secs(60); // Смерть UDP сессии без данных
|
||||
pub const GLOBAL_IDLE_TIMEOUT: Duration = Duration::from_secs(120); // Очистка Tracker-ом
|
||||
pub const HEALTH_CHECK_INTERVAL: Duration = Duration::from_secs(5); // Частота пинга Leg-ов
|
||||
pub const HEALTH_CHECK_INTERVAL: Duration = Duration::from_secs(10); // Частота пинга Leg-ов
|
||||
pub const HEALTH_CHECK_TIMEOUT: Duration = Duration::from_secs(15);
|
||||
pub const LEG_RECONNECT_DELAY: Duration = Duration::from_secs(5); // Пауза перед реконнектом Leg
|
||||
pub const BRIDGE_IDLE_TIMEOUT: Duration = Duration::from_secs(300); // Таймаут задач-бриджей
|
||||
@@ -25,7 +25,7 @@ pub const AUTH_TIME_STEP: u64 = 60; // Шаг генерации токена (
|
||||
pub const AUTH_WINDOW_SIZE: u64 = 2; // Допуск шагов времени (current +/- 2)
|
||||
|
||||
// --- Настройки Multipath (Legs) ---
|
||||
pub const LEG_STAGGER_DELAY: Duration = Duration::from_millis(250);
|
||||
pub const LEG_STAGGER_DELAY: Duration = Duration::from_millis(1500);
|
||||
pub const TOPOLOGY_PRINT_INTERVAL: Duration = Duration::from_secs(15);
|
||||
|
||||
// --- Настройки Stealth Fallback (Маскировка) ---
|
||||
@@ -34,4 +34,4 @@ pub const FALLBACK_CONNECT_TIMEOUT: Duration = Duration::from_secs(5);
|
||||
|
||||
// --- Таймауты Handshake ---
|
||||
pub const TLS_HELLO_TIMEOUT: Duration = Duration::from_secs(10);
|
||||
pub const SECURE_HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(15);
|
||||
pub const SECURE_HANDSHAKE_TIMEOUT: Duration = Duration::from_secs(20);
|
||||
|
||||
Reference in New Issue
Block a user