tourze/quic-congestion
Composer 安装命令:
composer require tourze/quic-congestion
包简介
QUIC协议拥塞控制算法实现 - 支持NewReno和BBR算法
README 文档
README
A PHP implementation of QUIC protocol congestion control algorithms, supporting NewReno and BBR algorithms for high-performance network communication.
Table of Contents
- Features
- Installation
- Quick Start
- Testing
- Performance Features
- API Documentation
- Dependencies
- Contributing
- License
- Development Status
Features
Supported Congestion Control Algorithms
-
NewReno Algorithm
- Traditional loss-based congestion control
- Slow start and congestion avoidance mechanisms
- Fast retransmit and fast recovery
- Ideal for stable network environments
-
BBR Algorithm
- Google's model-based congestion control
- Bandwidth estimation and RTT measurement
- Four states: startup, drain, probe_bw, probe_rtt
- Optimized for high-bandwidth networks
Core Components
- CongestionControlInterface: Standard interface for congestion control algorithms
- CongestionWindow: Congestion window management class
- CongestionController: Congestion control coordinator
- NewReno: NewReno algorithm implementation
- BBR: BBR algorithm implementation
Installation
Requirements
- PHP 8.1 or higher
tourze/quic-corepackagetourze/quic-recoverypackage
Using Composer
composer require tourze/quic-congestion
Quick Start
Basic Usage
<?php use Tourze\QUIC\Congestion\NewReno; use Tourze\QUIC\Congestion\BBR; use Tourze\QUIC\Congestion\CongestionController; // Using NewReno algorithm $newReno = new NewReno(); $controller = new CongestionController($newReno); // Sending a packet $controller->onPacketSent(1, 1200, microtime(true)); // Receiving ACK $controller->onPacketAcked(1, 1200, $sentTime, microtime(true)); // Check if can send if ($controller->canSend(1200)) { // Can send packet } // Switch to BBR algorithm $bbr = new BBR(); $controller->switchAlgorithm($bbr);
Using BBR Algorithm
<?php use Tourze\QUIC\Congestion\BBR; $bbr = new BBR(12000); // Initial congestion window 12KB // Handle packet acknowledgment $bbr->onPacketAcked($packetNumber, $bytes, $sentTime, $ackTime); // Get sending rate $pacingRate = $bbr->getSendingRate(); // Get detailed statistics $stats = $bbr->getStats(); echo "Current state: " . $stats['state']; // startup, drain, probe_bw, probe_rtt echo "Bandwidth estimate: " . $stats['bandwidth_estimate'] . " bytes/s"; echo "Min RTT: " . $stats['min_rtt'] . " seconds";
Congestion Window Management
<?php use Tourze\QUIC\Congestion\CongestionWindow; $window = new CongestionWindow(); // Slow start growth $window->onPacketAcked(1200, true); // In slow start phase // Congestion avoidance growth $window->onPacketAcked(1200, false); // In congestion avoidance phase // Handle packet loss $window->onPacketLost(); // Get current window size $size = $window->getWindowSize();
Testing
The package includes comprehensive test coverage with 58 unit tests and 163 assertions covering:
BBR Algorithm Tests (17 tests)
- Initial state validation
- Packet sending and acknowledgment
- RTT measurement and bandwidth estimation
- State transition mechanisms
- Packet loss handling
- Statistics accuracy
NewReno Algorithm Tests (13 tests)
- Slow start and congestion avoidance
- Fast retransmit and fast recovery
- Packet loss detection and window adjustment
- Duplicate ACK handling
- Timeout retransmission
Congestion Window Tests (11 tests)
- Window initialization and growth
- Minimum/maximum window limits
- Window reduction after packet loss
- Statistics collection
Congestion Controller Tests (14 tests)
- Algorithm switching functionality
- Batch ACK and loss handling
- RTT calculation and statistics
- Edge case handling
- Performance metrics collection
Running Tests
./vendor/bin/phpunit packages/quic-congestion/tests
Performance Features
- High-frequency packet processing support
- Memory usage optimization with automatic history cleanup
- Precise bandwidth and RTT measurement
- Configurable algorithm parameters
- Detailed performance statistics
API Documentation
CongestionControlInterface
interface CongestionControlInterface { public function onPacketAcked(int $packetNumber, int $bytes, float $sentTime, float $ackTime): void; public function onPacketLost(int $packetNumber, int $bytes, float $sentTime, float $lossTime): void; public function onPacketSent(int $packetNumber, int $bytes, float $sentTime): void; public function getCongestionWindow(): int; public function getSlowStartThreshold(): int; public function canSend(int $bytes, int $bytesInFlight): bool; public function getSendingRate(): ?float; public function isInSlowStart(): bool; public function reset(): void; public function getStats(): array; public function getAlgorithmName(): string; }
Dependencies
tourze/quic-core: QUIC protocol core componentstourze/quic-recovery: Packet loss detection and RTT estimation
Contributing
Please see CONTRIBUTING.md for details on how to contribute to this project.
License
The MIT License (MIT). Please see License File for more information.
Development Status
✅ Complete - All core features implemented and tested
- NewReno congestion control algorithm
- BBR congestion control algorithm
- Congestion window management
- Congestion controller coordination
- Complete unit test coverage
tourze/quic-congestion 适用场景与选型建议
tourze/quic-congestion 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「network」 「protocol」 「quic」 「congestion-control」 「newreno」 「bbr」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 tourze/quic-congestion 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tourze/quic-congestion 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 tourze/quic-congestion 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A small client implementing the Measurement Protocol for Google Analytics 4.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
LinkedIn API PHP SDK with OAuth 2.0 & CSRF support. Can be used for social sign in or sharing on LinkedIn. Examples. Documentation.
PHP SDK for Bands In Town API
Yii2 Extension for sending push notification with both Firebase Cloud Messaging (FCM) HTTP Server Protocols (APIs).
This bundle contains functionality concerning privacy and the European Union's "General Data Protection Regulation" (GDPR, in German: "Datenschutz-Grundverordnung", DSGVO).
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 13
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-06-03