承接 tourze/quic-recovery 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

tourze/quic-recovery

Composer 安装命令:

composer require tourze/quic-recovery

包简介

QUIC协议丢包检测和恢复机制

README 文档

README

English | 中文

Latest Version PHP Version Build Status Total Downloads License Code Coverage

A complete implementation of QUIC protocol packet loss detection and recovery mechanisms, following RFC 9002 specifications.

Table of Contents

Features

  • RTT Estimation: Implements exponential moving average algorithm for round-trip time estimation
  • Loss Detection: Supports time-based and packet-number-based loss detection algorithms
  • Packet Tracking: Tracks sent packet status and acknowledgment information
  • ACK Management: Automatic ACK frame generation and processing
  • Retransmission Management: Smart retransmission strategy including PTO probing and fast retransmission

Installation

composer require tourze/quic-recovery

Usage

Quick Start

<?php

use Tourze\QUIC\Recovery\Recovery;

// Create recovery instance with initial RTT of 333ms
$recovery = new Recovery(333.0);

// When sending a packet
$recovery->onPacketSent(
    packetNumber: 1,
    packet: $packet,
    sentTime: microtime(true) * 1000,
    ackEliciting: true
);

// When receiving a packet
$recovery->onPacketReceived(
    packetNumber: 1,
    receiveTime: microtime(true) * 1000,
    ackEliciting: true
);

// Check if should send ACK immediately
if ($recovery->shouldSendAckImmediately(microtime(true) * 1000)) {
    $ackFrame = $recovery->generateAckFrame(microtime(true) * 1000);
    // Send ACK frame...
}

Creating Recovery Instance

use Tourze\QUIC\Recovery\Recovery;

// Create recovery mechanism with initial RTT of 333ms
$recovery = new Recovery(333.0);

When Sending Packets

use Tourze\QUIC\Packets\Packet;

// Record sent packet
$recovery->onPacketSent(
    packetNumber: 1,
    packet: $packet,
    sentTime: microtime(true) * 1000,
    ackEliciting: true
);

When Receiving Packets

// Record received packet
$recovery->onPacketReceived(
    packetNumber: 1,
    receiveTime: microtime(true) * 1000,
    ackEliciting: true
);

// Check if should send ACK immediately
if ($recovery->shouldSendAckImmediately(microtime(true) * 1000)) {
    $ackFrame = $recovery->generateAckFrame(microtime(true) * 1000);
    // Send ACK frame...
}

Processing Received ACK

use Tourze\QUIC\Frames\AckFrame;

// When receiving ACK frame
$recovery->onAckReceived($ackFrame, microtime(true) * 1000);

Handling Timeout Events

$currentTime = microtime(true) * 1000;
$actions = $recovery->onTimeout($currentTime);

foreach ($actions as $action) {
    switch ($action['type']) {
        case 'retransmit_lost':
            // Retransmit lost packets
            foreach ($action['packets'] as $packetNumber) {
                // Retransmission logic...
            }
            break;
            
        case 'pto_probe':
            // Send PTO probe packets
            foreach ($action['packets'] as $probeInfo) {
                // Probe logic...
            }
            break;
            
        case 'send_ack':
            // Send ACK frame
            $ackFrame = $action['frame'];
            // Send logic...
            break;
    }
}

Dependencies

  • PHP 8.1 or higher
  • tourze/quic-core - Core QUIC protocol components
  • tourze/quic-packets - QUIC packet structures
  • tourze/quic-frames - QUIC frame structures

Advanced Usage

Getting Statistics

$stats = $recovery->getStats();

echo "Current RTT: " . $recovery->getCurrentRtt() . "ms\n";
echo "Retransmission Rate: " . ($recovery->getRetransmissionRate() * 100) . "%\n";
echo "Connection Healthy: " . ($recovery->isConnectionHealthy() ? 'Yes' : 'No') . "\n";
echo "Congestion Advice: " . $recovery->getCongestionAdvice() . "\n";

Accessing Individual Components

// Get RTT estimator
$rttEstimator = $recovery->getRttEstimator();
$smoothedRtt = $rttEstimator->getSmoothedRtt();

// Get packet tracker
$packetTracker = $recovery->getPacketTracker();
$unackedCount = $packetTracker->getAckElicitingOutstanding();

// Get loss detection
$lossDetection = $recovery->getLossDetection();
$ptoCount = $lossDetection->getPtoCount();

Periodic Cleanup

// Periodic cleanup of expired records (recommended every minute)
$recovery->cleanup(microtime(true) * 1000);

Components

RTTEstimator

  • Implements RFC 9002 RTT estimation algorithm
  • Supports smoothed RTT and RTT variance calculation
  • Provides PTO timeout calculation

PacketTracker

  • Tracks sent packet status
  • Manages ACK acknowledgments and loss marking
  • Supports packet reordering detection

LossDetection

  • Packet number gap-based loss detection
  • Time threshold-based loss detection
  • PTO timeout management

AckManager

  • Automatic ACK frame generation
  • ACK delay control
  • Missing packet detection

RetransmissionManager

  • Smart retransmission strategy
  • Exponential backoff algorithm
  • Retransmission statistics analysis

Configuration

// Custom initial RTT
$recovery = new Recovery(500.0); // 500ms initial RTT

// Reset recovery state
$recovery->reset();

Error Handling

All methods include proper parameter validation and will throw InvalidArgumentException for invalid parameters.

Performance Considerations

  • Periodically call cleanup() method to clean expired records
  • Monitor retransmission rate to avoid retransmission storms
  • Adjust initial RTT value based on network conditions

RFC Compliance

This implementation strictly follows the following RFC specifications:

  • RFC 9000 - QUIC: A UDP-Based Multiplexed and Secure Transport
  • RFC 9002 - QUIC Loss Detection and Congestion Control

Contributing

Please see CONTRIBUTING.md for details.

License

The MIT License (MIT). Please see License File for more information.

tourze/quic-recovery 适用场景与选型建议

tourze/quic-recovery 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 28 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tourze/quic-recovery 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tourze/quic-recovery 我们能提供哪些服务?
定制开发 / 二次开发

基于 tourze/quic-recovery 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 28
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 32
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-03