跳到主要内容

Controller

搜索

trait Controller 

源代码
pub trait Controller: Send + Sync {
    // Required methods
    fn on_congestion_event(
        &mut self,
        now: Instant,
        sent: Instant,
        is_persistent_congestion: bool,
        lost_bytes: u64,
    );
    fn on_mtu_update(&mut self, new_mtu: u16);
    fn window(&self) -> u64;
    fn clone_box(&self) -> Box<dyn Controller>;
    fn initial_window(&self) -> u64;
    fn into_any(self: Box<Self>) -> Box<dyn Any>;

    // Provided methods
    fn on_sent(&mut self, now: Instant, bytes: u64, last_packet_number: u64) { ... }
    fn on_ack(
        &mut self,
        now: Instant,
        sent: Instant,
        bytes: u64,
        app_limited: bool,
        rtt: &RttEstimator,
    ) { ... }
    fn on_end_acks(
        &mut self,
        now: Instant,
        in_flight: u64,
        app_limited: bool,
        largest_packet_num_acked: Option<u64>,
    ) { ... }
    fn metrics(&self) -> ControllerMetrics { ... }
}
展开描述

不同拥塞控制器的公共接口

必需方法§

源代码

fn on_congestion_event( &mut self, now: Instant, sent: Instant, is_persistent_congestion: bool, lost_bytes: u64, )

数据包被判定为丢失或被标记为拥塞

in_persistent_congestion 表示在该批次中最近一个包发送之前“持续拥塞阈值”时间段内发送的所有包是否都已丢失。lost_bytes 表示丢失的字节数。对于 ECN 触发,该值为 0。

源代码

fn on_mtu_update(&mut self, new_mtu: u16)

当前网络路径的已知 MTU 已更新

源代码

fn window(&self) -> u64

允许处于飞行中的可触发 ACK 的字节数

源代码

fn clone_box(&self) -> Box<dyn Controller>

复制一份本控制器状态

源代码

fn initial_window(&self) -> u64

初始拥塞窗口

源代码

fn into_any(self: Box<Self>) -> Box<dyn Any>

返回 Self,供向下转型以提取实现细节使用

提供方法§

源代码

fn on_sent(&mut self, now: Instant, bytes: u64, last_packet_number: u64)

刚刚发送了一个或多个包

源代码

fn on_ack( &mut self, now: Instant, sent: Instant, bytes: u64, app_limited: bool, rtt: &RttEstimator, )

数据包的送达已得到确认

app_limited 表示在收到这些确认之前,连接是否因外发应用数据而被阻塞。

源代码

fn on_end_acks( &mut self, now: Instant, in_flight: u64, app_limited: bool, largest_packet_num_acked: Option<u64>, )

包以批次的形式被确认,每个批次使用同一个 now 参数。此方法表示其中某个批次已处理完毕。

源代码

fn metrics(&self) -> ControllerMetrics

获取实现特有的指标,用于在启用 qlog trace 时填充相关字段

实现者§