以下是 BBR 算法的伪代码:

  1. 初始化: 初始化窗口大小为 1 个 MSS; 初始化带宽和延迟; 初始化 RTT 和 RTprop; 初始化 cwnd_gain; 初始化 pacing_gain; 初始化 pacing_rate; 初始化 ACK 计数器; 初始化 最大 ACK 计数器; 初始化 last_ack; 初始化 last_ack_sent; 初始化 last_packet_sent; 初始化 last_packet_acked; 初始化 last_sample; 初始化 last_rtt; 初始化 min_rtt; 初始化 last_rtt_update; 初始化 last_rtt_sample; 初始化 last_rtt_win; 初始化 last_rtt_probe; 初始化 last_rtt_bytes; 初始化 rtt_win_sx; 初始化 rtt_win_cnt; 初始化 rtt_low_cap; 初始化 rtt_high_cap; 初始化 rtt_min_cap; 初始化 rtt_min_cap_cnt; 初始化 rtt_min_cap_inv; 初始化 rtt_max_cap; 初始化 rtt_max_cap_cnt; 初始化 rtt_max_cap_inv; 初始化 rtt_max_cap_time; 初始化 rtt_max_cap_diff; 初始化 rtt_max_cap_delta; 初始化 rtt_max_cap_gain; 初始化 rtt_max_cap_gain_inv; 初始化 rtt_max_cap_gain_sx; 初始化 rtt_max_cap_gain_cnt; 初始化 rtt_max_cap_gain_thresh; 初始化 rtt_max_cap_gain_thresh_cnt; 初始化 rtt_max_cap_gain_thresh_inv; 初始化 rtt_max_cap_gain_thresh_sx; 初始化 rtt_max_cap_gain_thresh_cnt2; 初始化 rtt_max_cap_gain_thresh_inv2; 初始化 rtt_max_cap_gain_thresh_sx2; 初始化 rtt_max_cap_gain_thresh_cnt3; 初始化 rtt_max_cap_gain_thresh_inv3; 初始化 rtt_max_cap_gain_thresh_sx3; 初始化 rtt_max_cap_gain_thresh_cnt4; 初始化 rtt_max_cap_gain_thresh_inv4; 初始化 rtt_max_cap_gain_thresh_sx4; 初始化 rtt_max_cap_gain_thresh_cnt5; 初始化 rtt_max_cap_gain_thresh_inv5; 初始化 rtt_max_cap_gain_thresh_sx5; 初始化 rtt_max_cap_gain_thresh_cnt6; 初始化 rtt_max_cap_gain_thresh_inv6; 初始化 rtt_max_cap_gain_thresh_sx6; 初始化 rtt_max_cap_gain_thresh_cnt7; 初始化 rtt_max_cap_gain_thresh_inv7; 初始化 rtt_max_cap_gain_thresh_sx7; 初始化 rtt_max_cap_gain_thresh_cnt8; 初始化 rtt_max_cap_gain_thresh_inv8; 初始化 rtt_max_cap_gain_thresh_sx8; 初始化 rtt_max_cap_gain_thresh_cnt9; 初始化 rtt_max_cap_gain_thresh_inv9; 初始化 rtt_max_cap_gain_thresh_sx9; 初始化 rtt_max_cap_gain_thresh_cnt10; 初始化 rtt_max_cap_gain_thresh_inv10; 初始化 rtt_max_cap_gain_thresh_sx10; 初始化 rtt_max_cap_gain_thresh_cnt11; 初始化 rtt_max_cap_gain_thresh_inv11; 初始化 rtt_max_cap_gain_thresh_sx11; 初始化 rtt_max_cap_gain_thresh_cnt12; 初始化 rtt_max_cap_gain_thresh_inv12; 初始化 rtt_max_cap_gain_thresh_sx12; 初始化 rtt_max_cap_gain_thresh_cnt13; 初始化 rtt_max_cap_gain_thresh_inv13; 初始化 rtt_max_cap_gain_thresh_sx13; 初始化 rtt_max_cap_gain_thresh_cnt14; 初始化 rtt_max_cap_gain_thresh_inv14; 初始化 rtt_max_cap_gain_thresh_sx14; 初始化 rtt_max_cap_gain_thresh_cnt15; 初始化 rtt_max_cap_gain_thresh_inv15; 初始化 rtt_max_cap_gain_thresh_sx15; 初始化 rtt_max_cap_gain_thresh_cnt16; 初始化 rtt_max_cap_gain_thresh_inv16; 初始化 rtt_max_cap_gain_thresh_sx16; 初始化 rtt_min_cap_gain; 初始化 rtt_min_cap_gain_inv; 初始化 rtt_min_cap_gain_sx; 初始化 rtt_min_cap_gain_cnt; 初始化 rtt_min_cap_gain_thresh; 初始化 rtt_min_cap_gain_thresh_inv; 初始化 rtt_min_cap_gain_thresh_sx; 初始化 rtt_min_cap_gain_thresh_cnt2; 初始化 rtt_min_cap_gain_thresh_inv2; 初始化 rtt_min_cap_gain_thresh_sx2; 初始化 rtt_min_cap_gain_thresh_cnt3; 初始化 rtt_min_cap_gain_thresh_inv3; 初始化 rtt_min_cap_gain_thresh_sx3; 初始化 rtt_min_cap_gain_thresh_cnt4; 初始化 rtt_min_cap_gain_thresh_inv4; 初始化 rtt_min_cap_gain_thresh_sx4; 初始化 rtt_min_cap_gain_thresh_cnt5; 初始化 rtt_min_cap_gain_thresh_inv5; 初始化 rtt_min_cap_gain_thresh_sx5; 初始化 rtt_min_cap_gain_thresh_cnt6; 初始化 rtt_min_cap_gain_thresh_inv6; 初始化 rtt_min_cap_gain_thresh_sx6; 初始化 rtt_min_cap_gain_thresh_cnt7; 初始化 rtt_min_cap_gain_thresh_inv7; 初始化 rtt_min_cap_gain_thresh_sx7; 初始化 rtt_min_cap_gain_thresh_cnt8; 初始化 rtt_min_cap_gain_thresh_inv8; 初始化 rtt_min_cap_gain_thresh_sx8; 初始化 rtt_min_cap_gain_thresh_cnt9; 初始化 rtt_min_cap_gain_thresh_inv9; 初始化 rtt_min_cap_gain_thresh_sx9; 初始化 rtt_min_cap_gain_thresh_cnt10; 初始化 rtt_min_cap_gain_thresh_inv10; 初始化 rtt_min_cap_gain_thresh_sx10; 初始化 rtt_min_cap_gain_thresh_cnt11; 初始化 rtt_min_cap_gain_thresh_inv11; 初始化 rtt_min_cap_gain_thresh_sx11; 初始化 rtt_min_cap_gain_thresh_cnt12; 初始化 rtt_min_cap_gain_thresh_inv12; 初始化 rtt_min_cap_gain_thresh_sx12; 初始化 rtt_min_cap_gain_thresh_cnt13; 初始化 rtt_min_cap_gain_thresh_inv13; 初始化 rtt_min_cap_gain_thresh_sx13; 初始化 rtt_min_cap_gain_thresh_cnt14; 初始化 rtt_min_cap_gain_thresh_inv14; 初始化 rtt_min_cap_gain_thresh_sx14; 初始化 rtt_min_cap_gain_thresh_cnt15; 初始化 rtt_min_cap_gain_thresh_inv15; 初始化 rtt_min_cap_gain_thresh_sx15; 初始化 rtt_min_cap_gain_thresh_cnt16; 初始化 rtt_min_cap_gain_thresh_inv16; 初始化 rtt_min_cap_gain_thresh_sx16; 初始化 rtt_min_cap_probe; 初始化 rtt_min_cap_time; 初始化 rtt_min_cap_diff; 初始化 rtt_min_cap_delta; 初始化 rtt_min_cap_thresh; 初始化 rtt_min_cap_thresh_inv; 初始化 rtt_min_cap_thresh_cnt; 初始化 rtt_min_cap_thresh_sx; 初始化 rtt_min_cap_thresh_cnt2; 初始化 rtt_min_cap_thresh_inv2; 初始化 rtt_min_cap_thresh_sx2; 初始化 rtt_min_cap_thresh_cnt3; 初始化 rtt_min_cap_thresh_inv3; 初始化 rtt_min_cap_thresh_sx3; 初始化 rtt_min_cap_thresh_cnt4; 初始化 rtt_min_cap_thresh_inv4; 初始化 rtt_min_cap_thresh_sx4; 初始化 rtt_min_cap_thresh_cnt5; 初始化 rtt_min_cap_thresh_inv5; 初始化 rtt_min_cap_thresh_sx5; 初始化 rtt_min_cap_thresh_cnt6; 初始化 rtt_min_cap_thresh_inv6; 初始化 rtt_min_cap_thresh_sx6; 初始化 rtt_min_cap_thresh_cnt7; 初始化 rtt_min_cap_thresh_inv7; 初始化 rtt_min_cap_thresh_sx7; 初始化 rtt_min_cap_thresh_cnt8; 初始化 rtt_min_cap_thresh_inv8; 初始化 rtt_min_cap_thresh_sx8; 初始化 rtt_min_cap_thresh_cnt9; 初始化 rtt_min_cap_thresh_inv9; 初始化 rtt_min_cap_thresh_sx9; 初始化 rtt_min_cap_thresh_cnt10; 初始化 rtt_min_cap_thresh_inv10; 初始化 rtt_min_cap_thresh_sx10; 初始化 rtt_min_cap_thresh_cnt11; 初始化 rtt_min_cap_thresh_inv11; 初始化 rtt_min_cap_thresh_sx11; 初始化 rtt_min_cap_thresh_cnt12; 初始化 rtt_min_cap_thresh_inv12; 初始化 rtt_min_cap_thresh_sx12; 初始化 rtt_min_cap_thresh_cnt13; 初始化 rtt_min_cap_thresh_inv13; 初始化 rtt_min_cap_thresh_sx13; 初始化 rtt_min_cap_thresh_cnt14; 初始化 rtt_min_cap_thresh_inv14; 初始化 rtt_min_cap_thresh_sx14; 初始化 rtt_min_cap_thresh_cnt15; 初始化 rtt_min_cap_thresh_inv15; 初始化 rtt_min_cap_thresh_sx15; 初始化 rtt_min_cap_thresh_cnt16; 初始化 rtt_min_cap_thresh_inv16; 初始化 rtt_min_cap_thresh_sx16; 初始化 rtt_probe_thresh; 初始化 rtt_probe_thresh_inv; 初始化 rtt_probe_thresh_cnt; 初始化 rtt_probe_thresh_sx; 初始化 rtt_probe_thresh_cnt2; 初始化 rtt_probe_thresh_inv2; 初始化 rtt_probe_thresh_sx2; 初始化 rtt_probe_thresh_cnt3; 初始化 rtt_probe_thresh_inv3; 初始化 rtt_probe_thresh_sx3; 初始化 rtt_probe_thresh_cnt4; 初始化 rtt_probe_thresh_inv4; 初始化 rtt_probe_thresh_sx4; 初始化 rtt_probe_thresh_cnt5; 初始化 rtt_probe_thresh_inv5; 初始化 rtt_probe_thresh_sx5; 初始化 rtt_probe_thresh_cnt6; 初始化 rtt_probe_thresh_inv6; 初始化 rtt_probe_thresh_sx6; 初始化 rtt_probe_thresh_cnt7; 初始化 rtt_probe_thresh_inv7; 初始化 rtt_probe_thresh_sx7; 初始化 rtt_probe_thresh_cnt8; 初始化 rtt_probe_thresh_inv8; 初始化 rtt_probe_thresh_sx8; 初始化 rtt_probe_thresh_cnt9; 初始化 rtt_probe_thresh_inv9; 初始化 rtt_probe_thresh_sx9; 初始化 rtt_probe_thresh_cnt10; 初始化 rtt_probe_thresh_inv10; 初始化 rtt_probe_thresh_sx10; 初始化 rtt_probe_thresh_cnt11; 初始化 rtt_probe_thresh_inv11; 初始化 rtt_probe_thresh_sx11; 初始化 rtt_probe_thresh_cnt12; 初始化 rtt_probe_thresh_inv12; 初始化 rtt_probe_thresh_sx12; 初始化 rtt_probe_thresh_cnt13; 初始化 rtt_probe_thresh_inv13; 初始化 rtt_probe_thresh_sx13; 初始化 rtt_probe_thresh_cnt14; 初始化 rtt_probe_thresh_inv14; 初始化 rtt_probe_thresh_sx14; 初始化 rtt_probe_thresh_cnt15; 初始化 rtt_probe_thresh_inv15; 初始化 rtt_probe_thresh_sx15; 初始化 rtt_probe_thresh_cnt16; 初始化 rtt_probe_thresh_inv16; 初始化 rtt_probe_thresh_sx16; 初始化 rtt_probe_thresh_cnt17; 初始化 rtt_probe_thresh_inv17; 初始化 rtt_probe_thresh_sx17; 初始化 rtt_probe_thresh_cnt18; 初始化 rtt_probe_thresh_inv18; 初始化 rtt_probe_thresh_sx18; 初始化 rtt_probe_thresh_cnt19; 初始化 rtt_probe_thresh_inv19; 初始化 rtt_probe_thresh_sx19; 初始化 rtt_probe_thresh_cnt20; 初始化 rtt_probe_thresh_inv20; 初始化 rtt_probe_thresh_sx20; 初始化 rtt_probe_thresh_cnt21; 初始化 rtt_probe_thresh_inv21; 初始化 rtt_probe_thresh_sx21; 初始化 rtt_probe_thresh_cnt22; 初始化 rtt_probe_thresh_inv22; 初始化 rtt_probe_thresh_sx22; 初始化 rtt_probe_thresh_cnt23; 初始化 rtt_probe_thresh_inv23; 初始化 rtt_probe_thresh_sx23; 初始化 rtt_probe_thresh_cnt24; 初始化 rtt_probe_thresh_inv24; 初始化 rtt_probe_thresh_sx24; 初始化 rtt_probe_thresh_cnt25; 初始化 rtt_probe_thresh_inv25; 初始化 rtt_probe_thresh_sx25; 初始化 rtt_probe_thresh_cnt26; 初始化 rtt_probe_thresh_inv26; 初始化 rtt_probe_thresh_sx26; 初始化 rtt_probe_thresh_cnt27; 初始化 rtt_probe_thresh_inv27; 初始化 rtt_probe_thresh_sx27; 初始化 rtt_probe_thresh_cnt28; 初始化 rtt_probe_thresh_inv28; 初始化 rtt_probe_thresh_sx28; 初始化 rtt_probe_thresh_cnt29; 初始化 rtt_probe_thresh_inv29; 初始化 rtt_probe_thresh_sx29; 初始化 rtt_probe_thresh_cnt30; 初始化 rtt_probe_thresh_inv30; 初始化 rtt_probe_thresh_sx30; 初始化 rtt_probe_thresh_cnt31; 初始化 rtt_probe_thresh_inv31; 初始化 rtt_probe_thresh_sx31; 初始化 rtt_probe_thresh_cnt32; 初始化 rtt_probe_thresh_inv32; 初始化 rtt_probe_thresh_sx32; 初始化 rtt_probe_thresh_cnt33; 初始化 rtt_probe_thresh_inv33; 初始化 rtt_probe_thresh_sx33; 初始化 rtt_probe_thresh_cnt34; 初始化 rtt_probe_thresh_inv34; 初始化 rtt_probe_thresh_sx34; 初始化 rtt_probe_thresh_cnt35; 初始化 rtt_probe_thresh_inv35; 初始化 rtt_probe_thresh_sx35; 初始化 rtt_probe_thresh_cnt36; 初始化 rtt_probe_thresh_inv36; 初始化 rtt_probe_thresh_sx36; 初始化 rtt_probe_thresh_cnt37; 初始化 rtt_probe_thresh_inv37; 初始化 rtt_probe_thresh_sx37; 初始化 rtt_probe_thresh_cnt38; 初始化 rtt_probe_thresh_inv38; 初始化 rtt_probe_thresh_sx38; 初始化 rtt_probe_thresh_cnt39; 初始化 rtt_probe_thresh_inv39; 初始化 rtt_probe_thresh_sx39; 初始化 rtt_probe_thresh_cnt40; 初始化 rtt_probe_thresh_inv40; 初始化 rtt_probe_thresh_sx40; 初始化 rtt_probe_thresh_cnt41; 初始化 rtt_probe_thresh_inv41; 初始化 rtt_probe_thresh_sx41; 初始化 rtt_probe_thresh_cnt42; 初始化 rtt_probe_thresh_inv42; 初始化 rtt_probe_thresh_sx42; 初始化 rtt_probe_thresh_cnt43; 初始化 rtt_probe_thresh_inv43; 初始化 rtt_probe_thresh_sx43; 初始化 rtt_probe_thresh_cnt44; 初始化 rtt_probe_thresh_inv44; 初始化 rtt_probe_thresh_sx44; 初始化 rtt_probe_thresh_cnt45; 初始化 rtt_probe_thresh_inv45; 初始化 rtt_probe_thresh_sx45; 初始化 rtt_probe_thresh_cnt46; 初始化 rtt_probe_thresh_inv46; 初始化 rtt_probe_thresh_sx46; 初始化 rtt_probe_thresh_cnt47; 初始化 rtt_probe_thresh_inv47; 初始化 rtt_probe_thresh_sx47; 初始化 rtt_probe_thresh_cnt48; 初始化 rtt_probe_thresh_inv48; 初始化 rtt_probe_thresh_sx48; 初始化 rtt_probe_thresh_cnt49; 初始化 rtt_probe_thresh_inv49; 初始化 rtt_probe_thresh_sx49; 初始化 rtt_probe_thresh_cnt50; 初始化 rtt_probe_thresh_inv50; 初始化 rtt_probe_thresh_sx50; 初始化 rtt_probe_thresh_cnt51; 初始化 rtt_probe_thresh_inv51; 初始化 rtt_probe_thresh_sx51; 初始化 rtt_probe_thresh_cnt52; 初始化 rtt_probe_thresh_inv52; 初始化 rtt_probe_thresh_sx52; 初始化 rtt_probe_thresh_cnt53; 初始化 rtt_probe_thresh_inv53; 初始化 rtt_probe_thresh_sx53; 初始化 rtt_probe_thresh_cnt54; 初始化 rtt_probe_thresh_inv54; 初始化 rtt_probe_thresh_sx54; 初始化 rtt_probe_thresh_cnt55; 初始化 rtt_probe_thresh_inv55; 初始化 rtt_probe_thresh_sx55; 初始化 rtt_probe_thresh_cnt56; 初始化 rtt_probe_thresh_inv56; 初始化 rtt_probe_thresh_sx56; 初始化 rtt_probe_thresh_cnt57; 初始化 rtt_probe_thresh_inv57; 初始化 rtt_probe_thresh_sx57; 初始化 rtt_probe_thresh_cnt58; 初始化 rtt_probe_thresh_inv58; 初始化 rtt_probe_thresh_sx58; 初始化 rtt_probe_thresh_cnt59; 初始化 rtt_probe_thresh_inv59; 初始化 rtt_probe_thresh_sx59; 初始化 rtt_probe_thresh_cnt60; 初始化 rtt_probe_thresh_inv60; 初始化 rtt_probe_thresh_sx60; 初始化 rtt_probe_inv; 初始化 rtt_probe_cnt; 初始化 rtt_probe_sx; 初始化 rtt_probe_thresh2; 初始化 rtt_probe_thresh_inv2; 初始化 rtt_probe_thresh_cnt2; 初始化 rtt_probe_thresh_sx2; 初始化 rtt_probe_thresh_cnt3; 初始化 rtt_probe_thresh_inv3; 初始化 rtt_probe_thresh_sx3; 初始化 rtt_probe_thresh_cnt4; 初始化 rtt_probe_thresh_inv4; 初始化 rtt_probe_thresh_sx4; 初始化 rtt_probe_thresh_cnt5; 初始化 rtt_probe_thresh_inv5; 初始化 rtt_probe_thresh_sx5; 初始化 rtt_probe_thresh_cnt6; 初始化 rtt_probe_thresh_inv6; 初始化 rtt_probe_thresh_sx6; 初始化 rtt_probe_thresh_cnt7; 初始化 rtt_probe_thresh_inv7; 初始化 rtt_probe_thresh_sx7; 初始化 rtt_probe_thresh_cnt8; 初始化 rtt_probe_thresh_inv8; 初始化 rtt_probe_thresh_sx8; 初始化 rtt_probe_thresh_cnt9; 初始化 rtt_probe_thresh_inv9; 初始化 rtt_probe_thresh_sx9; 初始化 rtt_probe_thresh_cnt10; 初始化 rtt_probe_thresh_inv10; 初始化 rtt_probe_thresh_sx10; 初始化 rtt_probe_thresh_cnt11; 初始化 rtt_probe_thresh_inv11; 初始化 rtt_probe_thresh_sx11; 初始化 rtt_probe_thresh_cnt12; 初始化 rtt_probe_thresh_inv12; 初始化 rtt_probe_thresh_sx12; 初始化 rtt_probe_thresh_cnt13; 初始化 rtt_probe_thresh_inv13; 初始化 rtt_probe_thresh_sx13; 初始化 rtt_probe_thresh_cnt14; 初始化 rtt_probe_thresh_inv14; 初始化 rtt_probe_thresh_sx14; 初始化 rtt_probe_thresh_cnt15; 初始化 rtt_probe_thresh_inv15; 初始化 rtt_probe_thresh_sx15; 初始化 rtt_probe_thresh_cnt16; 初始化 rtt_probe_thresh_inv16; 初始化 rtt_probe_thresh_sx16;

  2. 主循环: 等待数据包到达; 如果数据包已发送: 更新 last_packet_sent; 如果数据包已确认: 更新 last_packet_acked; 更新 ACK 计数器; 如果 ACK 计数器大于最大 ACK 计数器: 更新最大 ACK 计数器; 如果收到 ACK: 更新 last_ack; 更新 last_ack_sent; 更新 RTT; 更新 last_rtt_sample; 更新 last_rtt_win; 更新 last_rtt_probe; 更新 last_rtt_bytes; 如果 RTT 小于 min_rtt: 更新 min_rtt; 如果 RTT 超过特定阈值: 更新 rtt_win_sx; 更新 rtt_win_cnt; 根据 RTT 和带宽估计更新 cwnd_gain 和 pacing_gain; 根据 cwnd_gain 和 pacing_gain 更新窗口大小和发送速率; 如果发送速率高于带宽估计: 更新带宽和延迟; 如果发送速率低于带宽估计: 执行 RTT 探测; 更新 last_sample; 更新 last_rtt; 更新 last_rtt_update; 更新带宽和延迟;

BBR 算法伪代码 - 深入理解拥塞控制机制

原文地址: https://www.cveoy.top/t/topic/lDq9 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录