deps: update ngtcp2 to 1.21.0

PR-URL: https://github.com/nodejs/node/pull/62051
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Node.js GitHub Bot authored and GitHub committed 2026-03-30 09:24:20 +00:00
1 parent d9645d75e5
commit b4387bd540
15 files changed
+229 -223

No files matched your search

+5 -5
View File
@@ -1049,7 +1049,7 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
uint8_t *dest, size_t destlen,
ngtcp2_tstamp ts) {
std::array<SharedVec, 16> vec;
std::array<nghttp3_vec, 16> vec;
for (;;) {
int64_t stream_id = -1;
@@ -1057,9 +1057,8 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
nghttp3_ssize sveccnt = 0;
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
sveccnt = nghttp3_conn_writev_stream(
httpconn_, &stream_id, &fin,
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
vec.data(), vec.size());
if (sveccnt < 0) {
std::cerr << "nghttp3_conn_writev_stream: "
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1072,6 +1071,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
}
ngtcp2_ssize ndatalen;
auto v = vec.data();
auto vcnt = static_cast<size_t>(sveccnt);
uint32_t flags = NGTCP2_WRITE_STREAM_FLAG_MORE;
@@ -1081,7 +1081,7 @@ ngtcp2_ssize Client::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
auto nwrite = ngtcp2_conn_writev_stream(
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
if (nwrite < 0) {
switch (nwrite) {
case NGTCP2_ERR_STREAM_DATA_BLOCKED:
+5 -5
View File
@@ -1652,7 +1652,7 @@ ngtcp2_ssize write_pkt(ngtcp2_conn *conn, ngtcp2_path *path,
ngtcp2_ssize Handler::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
uint8_t *dest, size_t destlen,
ngtcp2_tstamp ts) {
std::array<SharedVec, 16> vec;
std::array<nghttp3_vec, 16> vec;
for (;;) {
int64_t stream_id = -1;
@@ -1660,9 +1660,8 @@ ngtcp2_ssize Handler::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
nghttp3_ssize sveccnt = 0;
if (httpconn_ && ngtcp2_conn_get_max_data_left(conn_)) {
sveccnt = nghttp3_conn_writev_stream(
httpconn_, &stream_id, &fin,
reinterpret_cast<nghttp3_vec *>(vec.data()), vec.size());
sveccnt = nghttp3_conn_writev_stream(httpconn_, &stream_id, &fin,
vec.data(), vec.size());
if (sveccnt < 0) {
std::cerr << "nghttp3_conn_writev_stream: "
<< nghttp3_strerror(static_cast<int>(sveccnt)) << std::endl;
@@ -1675,6 +1674,7 @@ ngtcp2_ssize Handler::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
}
ngtcp2_ssize ndatalen;
auto v = vec.data();
auto vcnt = static_cast<size_t>(sveccnt);
uint32_t flags =
@@ -1685,7 +1685,7 @@ ngtcp2_ssize Handler::write_pkt(ngtcp2_path *path, ngtcp2_pkt_info *pi,
auto nwrite = ngtcp2_conn_writev_stream(
conn_, path, pi, dest, destlen, &ndatalen, flags, stream_id,
reinterpret_cast<const ngtcp2_vec *>(vec.data()), vcnt, ts);
reinterpret_cast<const ngtcp2_vec *>(v), vcnt, ts);
if (nwrite < 0) {
switch (nwrite) {
case NGTCP2_ERR_STREAM_DATA_BLOCKED:
-6
View File
@@ -34,7 +34,6 @@
#include <span>
#include <ngtcp2/ngtcp2.h>
#include <nghttp3/nghttp3.h>
#include "network.h"
@@ -64,11 +63,6 @@ inline constexpr uint32_t TLS_ALERT_ECH_REQUIRED = 121;
inline constexpr size_t MAX_RECV_PKTS = 64;
union SharedVec {
ngtcp2_vec v2;
nghttp3_vec v3;
};
// msghdr_get_ecn gets ECN bits from |msg|. |family| is the address
// family from which packet is received.
uint8_t msghdr_get_ecn(msghdr *msg, int family);
+3 -3
View File
@@ -1281,7 +1281,7 @@ typedef struct ngtcp2_sockaddr_in {
} ngtcp2_sockaddr_in;
typedef struct ngtcp2_in6_addr {
uint8_t in6_addr[16];
uint8_t s6_addr[16];
} ngtcp2_in6_addr;
typedef struct ngtcp2_sockaddr_in6 {
@@ -1866,8 +1866,8 @@ typedef struct ngtcp2_settings {
uint64_t max_stream_window;
/**
* :member:`ack_thresh` is the minimum number of the received ACK
* eliciting packets that trigger the immediate acknowledgement from
* the local endpoint.
* eliciting packets that triggers the immediate acknowledgement
* from the local endpoint.
*/
size_t ack_thresh;
/**
+2 -2
View File
@@ -36,7 +36,7 @@
*
* Version number of the ngtcp2 library release.
*/
#define NGTCP2_VERSION "1.20.0"
#define NGTCP2_VERSION "1.21.0"
/**
* @macro
@@ -46,6 +46,6 @@
* number, 8 bits for minor and 8 bits for patch. Version 1.2.3
* becomes 0x010203.
*/
#define NGTCP2_VERSION_NUM 0x011400
#define NGTCP2_VERSION_NUM 0x011500
#endif /* !defined(NGTCP2_VERSION_H) */
+158 -107
View File
@@ -76,13 +76,15 @@ static void bbr_init_round_counting(ngtcp2_cc_bbr *bbr);
static void bbr_reset_full_bw(ngtcp2_cc_bbr *bbr);
static void bbr_init_pacing_rate(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_init_pacing_rate(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static void bbr_set_pacing_rate_with_gain(ngtcp2_cc_bbr *bbr,
static void bbr_set_pacing_rate_with_gain(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
uint64_t pacing_gain_h);
static void bbr_set_pacing_rate(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_set_pacing_rate(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static void bbr_enter_startup(ngtcp2_cc_bbr *bbr);
@@ -100,47 +102,47 @@ static void bbr_update_control_parameters(ngtcp2_cc_bbr *cc,
ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack);
static void bbr_update_on_loss(ngtcp2_cc_bbr *cc, ngtcp2_conn_stat *cstat,
const ngtcp2_cc_pkt *pkt, ngtcp2_tstamp ts);
static void bbr_update_latest_delivery_signals(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
const ngtcp2_conn_stat *cstat);
static void bbr_advance_latest_delivery_signals(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
const ngtcp2_conn_stat *cstat);
static void bbr_update_congestion_signals(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack);
static void bbr_adapt_lower_bounds_from_congestion(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static void
bbr_adapt_lower_bounds_from_congestion(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static void bbr_init_lower_bounds(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_init_lower_bounds(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static void bbr_loss_lower_bounds(ngtcp2_cc_bbr *bbr);
static void bbr_bound_bw_for_model(ngtcp2_cc_bbr *bbr);
static void bbr_update_max_bw(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static void bbr_update_max_bw(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack);
static void bbr_update_round(ngtcp2_cc_bbr *bbr, const ngtcp2_cc_ack *ack);
static void bbr_start_round(ngtcp2_cc_bbr *bbr);
static int bbr_is_in_probe_bw_state(ngtcp2_cc_bbr *bbr);
static int bbr_is_in_probe_bw_state(const ngtcp2_cc_bbr *bbr);
static int bbr_is_probing_bw(ngtcp2_cc_bbr *bbr);
static int bbr_is_probing_bw(const ngtcp2_cc_bbr *bbr);
static void bbr_update_ack_aggregation(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack,
ngtcp2_tstamp ts);
static void bbr_enter_drain(ngtcp2_cc_bbr *bbr);
static void bbr_check_drain_done(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static void bbr_check_drain_done(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat,
ngtcp2_tstamp ts);
static void bbr_enter_probe_bw(ngtcp2_cc_bbr *bbr, ngtcp2_tstamp ts);
@@ -151,57 +153,68 @@ static void bbr_start_probe_bw_cruise(ngtcp2_cc_bbr *bbr);
static void bbr_start_probe_bw_refill(ngtcp2_cc_bbr *bbr);
static void bbr_start_probe_bw_up(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_start_probe_bw_up(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static void bbr_update_probe_bw_cycle_phase(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack,
ngtcp2_tstamp ts);
static int bbr_is_time_to_cruise(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static int bbr_is_time_to_cruise(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static int bbr_is_time_to_go_down(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static int bbr_is_time_to_go_down(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static int bbr_has_elapsed_in_phase(ngtcp2_cc_bbr *bbr,
static int bbr_has_elapsed_in_phase(const ngtcp2_cc_bbr *bbr,
ngtcp2_duration interval, ngtcp2_tstamp ts);
static uint64_t bbr_inflight_with_headroom(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static uint64_t bbr_inflight_with_headroom(const ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static void bbr_raise_inflight_longterm_slope(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
const ngtcp2_conn_stat *cstat);
static void bbr_probe_inflight_longterm_upward(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack);
static void bbr_adapt_longterm_model(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack);
static int bbr_is_time_to_probe_bw(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static int bbr_is_time_to_probe_bw(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat,
ngtcp2_tstamp ts);
static void bbr_pick_probe_wait(ngtcp2_cc_bbr *bbr);
static int bbr_is_reno_coexistence_probe_time(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static int bbr_is_reno_coexistence_probe_time(const ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static uint64_t bbr_target_inflight(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static uint64_t bbr_target_inflight(const ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static int bbr_is_inflight_too_high(ngtcp2_cc_bbr *bbr, const ngtcp2_rs *rs);
static int bbr_is_inflight_too_high(const ngtcp2_cc_bbr *bbr,
const ngtcp2_rs *rs);
static void bbr_handle_inflight_too_high(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_rs *rs, ngtcp2_tstamp ts);
static void bbr_note_loss(ngtcp2_cc_bbr *bbr);
static void bbr_handle_lost_packet(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static void bbr_save_state_upon_loss(ngtcp2_cc_bbr *bbr);
static void bbr_handle_spurious_loss_detection(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static void bbr_handle_lost_packet(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_pkt *pkt, ngtcp2_tstamp ts);
static uint64_t bbr_inflight_at_loss(ngtcp2_cc_bbr *bbr,
static uint64_t bbr_inflight_at_loss(const ngtcp2_cc_bbr *bbr,
const ngtcp2_cc_pkt *pkt,
const ngtcp2_rs *rs);
@@ -220,7 +233,7 @@ static void bbr_check_probe_rtt_done(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat, ngtcp2_tstamp ts);
static void bbr_mark_connection_app_limited(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
const ngtcp2_conn_stat *cstat);
static void bbr_exit_probe_rtt(ngtcp2_cc_bbr *bbr, ngtcp2_tstamp ts);
@@ -231,27 +244,28 @@ static void bbr_handle_restart_from_idle(ngtcp2_cc_bbr *bbr,
static uint64_t bbr_bdp_multiple(ngtcp2_cc_bbr *bbr, uint64_t gain_h);
static uint64_t bbr_quantization_budget(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
uint64_t inflight);
static uint64_t bbr_inflight(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static uint64_t bbr_inflight(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat,
uint64_t gain_h);
static void bbr_update_max_inflight(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
const ngtcp2_conn_stat *cstat);
static void bbr_update_offload_budget(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
const ngtcp2_conn_stat *cstat);
static uint64_t min_pipe_cwnd(size_t max_udp_payload_size);
static void bbr_advance_max_bw_filter(ngtcp2_cc_bbr *bbr);
static void bbr_save_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_save_cwnd(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat);
static void bbr_restore_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_restore_cwnd(const ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static uint64_t bbr_probe_rtt_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static uint64_t bbr_probe_rtt_cwnd(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat);
static void bbr_bound_cwnd_for_probe_rtt(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
@@ -259,10 +273,11 @@ static void bbr_bound_cwnd_for_probe_rtt(ngtcp2_cc_bbr *bbr,
static void bbr_set_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack);
static void bbr_bound_cwnd_for_model(ngtcp2_cc_bbr *bbr,
static void bbr_bound_cwnd_for_model(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static void bbr_set_send_quantum(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat);
static void bbr_set_send_quantum(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat);
static int in_congestion_recovery(const ngtcp2_conn_stat *cstat,
ngtcp2_tstamp sent_time);
@@ -336,6 +351,7 @@ static void bbr_on_init(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
bbr->bdp = 0;
bbr->undo_state = 0;
bbr->undo_bw_shortterm = 0;
bbr->undo_inflight_shortterm = 0;
bbr->undo_inflight_longterm = 0;
@@ -365,7 +381,7 @@ static void bbr_reset_full_bw(ngtcp2_cc_bbr *bbr) {
}
static void bbr_check_full_bw_reached(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
if (bbr->full_bw_now || !bbr->round_start || bbr->rst->rs.is_app_limited) {
return;
}
@@ -404,7 +420,8 @@ static void bbr_check_startup_high_loss(ngtcp2_cc_bbr *bbr) {
bbr_bdp_multiple(bbr, bbr->cwnd_gain_h), bbr->inflight_latest);
}
static void bbr_init_pacing_rate(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_init_pacing_rate(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
cstat->pacing_interval_m = ngtcp2_max_uint64(
((cstat->first_rtt_sample_ts == UINT64_MAX ? NGTCP2_MILLISECONDS
: cstat->smoothed_rtt)
@@ -413,7 +430,7 @@ static void bbr_init_pacing_rate(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
1);
}
static void bbr_set_pacing_rate_with_gain(ngtcp2_cc_bbr *bbr,
static void bbr_set_pacing_rate_with_gain(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
uint64_t pacing_gain_h) {
uint64_t interval_m;
@@ -431,7 +448,8 @@ static void bbr_set_pacing_rate_with_gain(ngtcp2_cc_bbr *bbr,
}
}
static void bbr_set_pacing_rate(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_set_pacing_rate(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
bbr_set_pacing_rate_with_gain(bbr, cstat, bbr->pacing_gain_h);
}
@@ -487,13 +505,8 @@ static void bbr_update_control_parameters(ngtcp2_cc_bbr *bbr,
bbr_set_cwnd(bbr, cstat, ack);
}
static void bbr_update_on_loss(ngtcp2_cc_bbr *cc, ngtcp2_conn_stat *cstat,
const ngtcp2_cc_pkt *pkt, ngtcp2_tstamp ts) {
bbr_handle_lost_packet(cc, cstat, pkt, ts);
}
static void bbr_update_latest_delivery_signals(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
bbr->loss_round_start = 0;
bbr->bw_latest = ngtcp2_max_uint64(bbr->bw_latest, cstat->delivery_rate_sec);
bbr->inflight_latest =
@@ -506,7 +519,7 @@ static void bbr_update_latest_delivery_signals(ngtcp2_cc_bbr *bbr,
}
static void bbr_advance_latest_delivery_signals(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
if (bbr->loss_round_start) {
bbr->bw_latest = cstat->delivery_rate_sec;
bbr->inflight_latest = bbr->rst->rs.delivered;
@@ -514,7 +527,7 @@ static void bbr_advance_latest_delivery_signals(ngtcp2_cc_bbr *bbr,
}
static void bbr_update_congestion_signals(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack) {
bbr_update_max_bw(bbr, cstat, ack);
@@ -532,8 +545,9 @@ static void bbr_update_congestion_signals(ngtcp2_cc_bbr *bbr,
bbr->loss_in_round = 0;
}
static void bbr_adapt_lower_bounds_from_congestion(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
static void
bbr_adapt_lower_bounds_from_congestion(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
if (bbr_is_probing_bw(bbr)) {
return;
}
@@ -544,7 +558,8 @@ static void bbr_adapt_lower_bounds_from_congestion(ngtcp2_cc_bbr *bbr,
}
}
static void bbr_init_lower_bounds(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_init_lower_bounds(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
if (bbr->bw_shortterm == UINT64_MAX) {
bbr->bw_shortterm = bbr->max_bw;
}
@@ -567,7 +582,7 @@ static void bbr_bound_bw_for_model(ngtcp2_cc_bbr *bbr) {
bbr->bw = ngtcp2_min_uint64(bbr->max_bw, bbr->bw_shortterm);
}
static void bbr_update_max_bw(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static void bbr_update_max_bw(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack) {
bbr_update_round(bbr, ack);
@@ -603,7 +618,7 @@ static void bbr_start_round(ngtcp2_cc_bbr *bbr) {
bbr->next_round_delivered = bbr->rst->delivered;
}
static int bbr_is_in_probe_bw_state(ngtcp2_cc_bbr *bbr) {
static int bbr_is_in_probe_bw_state(const ngtcp2_cc_bbr *bbr) {
switch (bbr->state) {
case NGTCP2_BBR_STATE_PROBE_BW_DOWN:
case NGTCP2_BBR_STATE_PROBE_BW_CRUISE:
@@ -615,7 +630,7 @@ static int bbr_is_in_probe_bw_state(ngtcp2_cc_bbr *bbr) {
}
}
static int bbr_is_probing_bw(ngtcp2_cc_bbr *bbr) {
static int bbr_is_probing_bw(const ngtcp2_cc_bbr *bbr) {
switch (bbr->state) {
case NGTCP2_BBR_STATE_STARTUP:
case NGTCP2_BBR_STATE_PROBE_BW_REFILL:
@@ -627,7 +642,7 @@ static int bbr_is_probing_bw(ngtcp2_cc_bbr *bbr) {
}
static void bbr_update_ack_aggregation(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack,
ngtcp2_tstamp ts) {
ngtcp2_duration interval = ts - bbr->extra_acked_interval_start;
@@ -669,7 +684,8 @@ static void bbr_enter_drain(ngtcp2_cc_bbr *bbr) {
bbr->cwnd_gain_h = NGTCP2_BBR_DEFAULT_CWND_GAIN_H;
}
static void bbr_check_drain_done(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static void bbr_check_drain_done(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat,
ngtcp2_tstamp ts) {
if (bbr->state == NGTCP2_BBR_STATE_DRAIN &&
cstat->bytes_in_flight <= bbr_inflight(bbr, cstat, 100)) {
@@ -726,7 +742,8 @@ static void bbr_start_probe_bw_refill(ngtcp2_cc_bbr *bbr) {
bbr->cwnd_gain_h = NGTCP2_BBR_DEFAULT_CWND_GAIN_H;
}
static void bbr_start_probe_bw_up(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_start_probe_bw_up(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
ngtcp2_log_info(bbr->cc.log, NGTCP2_LOG_EVENT_CCA, "bbr start ProbeBW_UP");
bbr->ack_phase = NGTCP2_BBR_ACK_PHASE_ACKS_PROBE_STARTING;
@@ -743,7 +760,7 @@ static void bbr_start_probe_bw_up(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
}
static void bbr_update_probe_bw_cycle_phase(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack,
ngtcp2_tstamp ts) {
if (!bbr->full_bw_reached) {
@@ -791,14 +808,16 @@ static void bbr_update_probe_bw_cycle_phase(ngtcp2_cc_bbr *bbr,
}
}
static int bbr_is_time_to_cruise(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static int bbr_is_time_to_cruise(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
uint64_t inflight = ngtcp2_min_uint64(bbr_inflight_with_headroom(bbr, cstat),
bbr_inflight(bbr, cstat, 100));
return cstat->bytes_in_flight <= inflight;
}
static int bbr_is_time_to_go_down(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static int bbr_is_time_to_go_down(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
if (bbr->rst->is_cwnd_limited && cstat->cwnd >= bbr->inflight_longterm) {
bbr_reset_full_bw(bbr);
bbr->full_bw = cstat->delivery_rate_sec;
@@ -809,14 +828,14 @@ static int bbr_is_time_to_go_down(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
return bbr->full_bw_now;
}
static int bbr_has_elapsed_in_phase(ngtcp2_cc_bbr *bbr,
static int bbr_has_elapsed_in_phase(const ngtcp2_cc_bbr *bbr,
ngtcp2_duration interval,
ngtcp2_tstamp ts) {
return ts > bbr->cycle_stamp + interval;
}
static uint64_t bbr_inflight_with_headroom(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
static uint64_t bbr_inflight_with_headroom(const ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
uint64_t headroom;
uint64_t mpcwnd;
if (bbr->inflight_longterm == UINT64_MAX) {
@@ -837,7 +856,7 @@ static uint64_t bbr_inflight_with_headroom(ngtcp2_cc_bbr *bbr,
}
static void bbr_raise_inflight_longterm_slope(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
uint64_t growth_this_round = cstat->max_tx_udp_payload_size
<< bbr->bw_probe_up_rounds;
@@ -846,7 +865,7 @@ static void bbr_raise_inflight_longterm_slope(ngtcp2_cc_bbr *bbr,
}
static void bbr_probe_inflight_longterm_upward(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack) {
uint64_t delta;
@@ -870,7 +889,7 @@ static void bbr_probe_inflight_longterm_upward(ngtcp2_cc_bbr *bbr,
}
static void bbr_adapt_longterm_model(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_ack *ack) {
if (bbr->ack_phase == NGTCP2_BBR_ACK_PHASE_ACKS_PROBE_STARTING &&
bbr->round_start) {
@@ -899,7 +918,8 @@ static void bbr_adapt_longterm_model(ngtcp2_cc_bbr *bbr,
}
}
static int bbr_is_time_to_probe_bw(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static int bbr_is_time_to_probe_bw(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat,
ngtcp2_tstamp ts) {
if (bbr_has_elapsed_in_phase(bbr, bbr->bw_probe_wait, ts) ||
bbr_is_reno_coexistence_probe_time(bbr, cstat)) {
@@ -917,27 +937,28 @@ static void bbr_pick_probe_wait(ngtcp2_cc_bbr *bbr) {
2 * NGTCP2_SECONDS + ngtcp2_pcg32_rand_n(bbr->pcg, NGTCP2_SECONDS + 1);
}
static int bbr_is_reno_coexistence_probe_time(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
static int bbr_is_reno_coexistence_probe_time(const ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
uint64_t reno_rounds =
bbr_target_inflight(bbr, cstat) / cstat->max_tx_udp_payload_size;
return bbr->rounds_since_bw_probe >= ngtcp2_min_uint64(reno_rounds, 63);
}
static uint64_t bbr_target_inflight(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
static uint64_t bbr_target_inflight(const ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
return ngtcp2_min_uint64(bbr->bdp, cstat->cwnd);
}
static int bbr_is_inflight_too_high(ngtcp2_cc_bbr *bbr, const ngtcp2_rs *rs) {
static int bbr_is_inflight_too_high(const ngtcp2_cc_bbr *bbr,
const ngtcp2_rs *rs) {
(void)bbr;
return rs->lost * NGTCP2_BBR_LOSS_THRESH_DENOM >
rs->tx_in_flight * NGTCP2_BBR_LOSS_THRESH_NUMER;
}
static void bbr_handle_inflight_too_high(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
const ngtcp2_rs *rs,
ngtcp2_tstamp ts) {
bbr->bw_probe_samples = 0;
@@ -956,12 +977,49 @@ static void bbr_handle_inflight_too_high(ngtcp2_cc_bbr *bbr,
static void bbr_note_loss(ngtcp2_cc_bbr *bbr) {
if (!bbr->loss_in_round) {
bbr->loss_round_delivered = bbr->rst->delivered;
bbr_save_state_upon_loss(bbr);
}
bbr->loss_in_round = 1;
}
static void bbr_handle_lost_packet(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static void bbr_save_state_upon_loss(ngtcp2_cc_bbr *bbr) {
bbr->undo_state = bbr->state;
bbr->undo_bw_shortterm = bbr->bw_shortterm;
bbr->undo_inflight_shortterm = bbr->inflight_shortterm;
bbr->undo_inflight_longterm = bbr->inflight_longterm;
}
static void bbr_handle_spurious_loss_detection(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat) {
bbr->loss_in_round = 0;
bbr_reset_full_bw(bbr);
bbr->bw_shortterm =
ngtcp2_max_uint64(bbr->bw_shortterm, bbr->undo_bw_shortterm);
bbr->inflight_shortterm =
ngtcp2_max_uint64(bbr->inflight_shortterm, bbr->undo_inflight_shortterm);
bbr->inflight_longterm =
ngtcp2_max_uint64(bbr->inflight_longterm, bbr->undo_inflight_longterm);
if (bbr->state != NGTCP2_BBR_STATE_PROBE_RTT &&
bbr->state != bbr->undo_state) {
switch (bbr->undo_state) {
case NGTCP2_BBR_STATE_STARTUP:
bbr_enter_startup(bbr);
break;
case NGTCP2_BBR_STATE_PROBE_BW_UP:
bbr_start_probe_bw_up(bbr, cstat);
break;
default:
break;
}
}
}
static void bbr_handle_lost_packet(ngtcp2_cc_bbr *bbr,
const ngtcp2_conn_stat *cstat,
const ngtcp2_cc_pkt *pkt, ngtcp2_tstamp ts) {
ngtcp2_rs rs = {0};
@@ -983,7 +1041,7 @@ static void bbr_handle_lost_packet(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
}
}
static uint64_t bbr_inflight_at_loss(ngtcp2_cc_bbr *bbr,
static uint64_t bbr_inflight_at_loss(const ngtcp2_cc_bbr *bbr,
const ngtcp2_cc_pkt *pkt,
const ngtcp2_rs *rs) {
uint64_t inflight_prev, lost_prev, lost_prefix;
@@ -1100,7 +1158,7 @@ static void bbr_check_probe_rtt_done(ngtcp2_cc_bbr *bbr,
}
static void bbr_mark_connection_app_limited(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
bbr->rst->app_limited =
ngtcp2_max_uint64(bbr->rst->delivered + cstat->bytes_in_flight, 1);
}
@@ -1148,7 +1206,7 @@ static uint64_t min_pipe_cwnd(size_t max_udp_payload_size) {
}
static uint64_t bbr_quantization_budget(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat,
const ngtcp2_conn_stat *cstat,
uint64_t inflight) {
bbr_update_offload_budget(bbr, cstat);
@@ -1163,7 +1221,7 @@ static uint64_t bbr_quantization_budget(ngtcp2_cc_bbr *bbr,
return inflight;
}
static uint64_t bbr_inflight(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
static uint64_t bbr_inflight(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat,
uint64_t gain_h) {
uint64_t inflight = bbr_bdp_multiple(bbr, gain_h);
@@ -1171,7 +1229,7 @@ static uint64_t bbr_inflight(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
}
static void bbr_update_max_inflight(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
uint64_t inflight;
inflight = bbr_bdp_multiple(bbr, bbr->cwnd_gain_h) + bbr->extra_acked;
@@ -1179,7 +1237,7 @@ static void bbr_update_max_inflight(ngtcp2_cc_bbr *bbr,
}
static void bbr_update_offload_budget(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
bbr->offload_budget = 3 * cstat->send_quantum;
}
@@ -1187,7 +1245,7 @@ static void bbr_advance_max_bw_filter(ngtcp2_cc_bbr *bbr) {
++bbr->cycle_count;
}
static void bbr_save_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_save_cwnd(ngtcp2_cc_bbr *bbr, const ngtcp2_conn_stat *cstat) {
if (!bbr->in_loss_recovery && bbr->state != NGTCP2_BBR_STATE_PROBE_RTT) {
bbr->prior_cwnd = cstat->cwnd;
return;
@@ -1196,12 +1254,13 @@ static void bbr_save_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
bbr->prior_cwnd = ngtcp2_max_uint64(bbr->prior_cwnd, cstat->cwnd);
}
static void bbr_restore_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_restore_cwnd(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
cstat->cwnd = ngtcp2_max_uint64(cstat->cwnd, bbr->prior_cwnd);
}
static uint64_t bbr_probe_rtt_cwnd(ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
const ngtcp2_conn_stat *cstat) {
uint64_t probe_rtt_cwnd =
bbr_bdp_multiple(bbr, NGTCP2_BBR_PROBE_RTT_CWND_GAIN_H);
uint64_t mpcwnd = min_pipe_cwnd(cstat->max_tx_udp_payload_size);
@@ -1238,7 +1297,7 @@ static void bbr_set_cwnd(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat,
bbr_bound_cwnd_for_model(bbr, cstat);
}
static void bbr_bound_cwnd_for_model(ngtcp2_cc_bbr *bbr,
static void bbr_bound_cwnd_for_model(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
uint64_t cap = UINT64_MAX;
uint64_t mpcwnd = min_pipe_cwnd(cstat->max_tx_udp_payload_size);
@@ -1257,7 +1316,8 @@ static void bbr_bound_cwnd_for_model(ngtcp2_cc_bbr *bbr,
cstat->cwnd = ngtcp2_min_uint64(cstat->cwnd, cap);
}
static void bbr_set_send_quantum(ngtcp2_cc_bbr *bbr, ngtcp2_conn_stat *cstat) {
static void bbr_set_send_quantum(const ngtcp2_cc_bbr *bbr,
ngtcp2_conn_stat *cstat) {
size_t send_quantum = 64 * 1024;
(void)bbr;
@@ -1293,7 +1353,7 @@ static void bbr_cc_on_pkt_lost(ngtcp2_cc *cc, ngtcp2_conn_stat *cstat,
const ngtcp2_cc_pkt *pkt, ngtcp2_tstamp ts) {
ngtcp2_cc_bbr *bbr = ngtcp2_struct_of(cc, ngtcp2_cc_bbr, cc);
bbr_update_on_loss(bbr, cstat, pkt, ts);
bbr_handle_lost_packet(bbr, cstat, pkt, ts);
}
static void bbr_cc_congestion_event(ngtcp2_cc *cc, ngtcp2_conn_stat *cstat,
@@ -1311,9 +1371,6 @@ static void bbr_cc_congestion_event(ngtcp2_cc *cc, ngtcp2_conn_stat *cstat,
bbr->round_count_at_recovery =
bbr->round_start ? bbr->round_count : bbr->round_count + 1;
bbr_save_cwnd(bbr, cstat);
bbr->undo_bw_shortterm = bbr->bw_shortterm;
bbr->undo_inflight_shortterm = bbr->inflight_shortterm;
bbr->undo_inflight_longterm = bbr->inflight_longterm;
cstat->congestion_recovery_start_ts = ts;
}
@@ -1328,15 +1385,9 @@ static void bbr_cc_on_spurious_congestion(ngtcp2_cc *cc,
bbr->in_loss_recovery = 0;
bbr->round_count_at_recovery = UINT64_MAX;
bbr_reset_full_bw(bbr);
bbr->loss_in_round = 0;
bbr_restore_cwnd(bbr, cstat);
bbr->bw_shortterm =
ngtcp2_max_uint64(bbr->bw_shortterm, bbr->undo_bw_shortterm);
bbr->inflight_shortterm =
ngtcp2_max_uint64(bbr->inflight_shortterm, bbr->undo_inflight_shortterm);
bbr->inflight_longterm =
ngtcp2_max_uint64(bbr->inflight_longterm, bbr->undo_inflight_longterm);
bbr_handle_spurious_loss_detection(bbr, cstat);
}
static void bbr_cc_on_persistent_congestion(ngtcp2_cc *cc,
+1
View File
@@ -107,6 +107,7 @@ typedef struct ngtcp2_cc_bbr {
uint64_t cwnd_gain_h;
/* Backup for spurious losses */
ngtcp2_bbr_state undo_state;
uint64_t undo_bw_shortterm;
uint64_t undo_inflight_shortterm;
uint64_t undo_inflight_longterm;
+3 -1
View File
@@ -11913,6 +11913,8 @@ conn_write_vmsg_wrapper(ngtcp2_conn *conn, ngtcp2_path *path,
return nwrite;
}
assert((size_t)nwrite <= destlen);
if (cstat->bytes_in_flight >= cstat->cwnd) {
conn->rst.is_cwnd_limited = 1;
} else if ((cstat->cwnd >= cstat->ssthresh ||
@@ -12355,7 +12357,7 @@ ngtcp2_ssize ngtcp2_conn_write_vmsg(ngtcp2_conn *conn, ngtcp2_path *path,
/* We only exceed CWND to avoid deadlock. Do no write 1RTT
packet if CWND is depleted. */
if (conn_cwnd_is_zero(conn) && conn->pktns.rtb.probe_pkt_left == 0) {
goto fin;
return res;
}
} else if (destlen == 0) {
res = conn_write_handshake_ack_pkts(conn, pi, dest, origlen, ts);
-24
View File
@@ -31,7 +31,6 @@
#include "ngtcp2_macro.h"
#include "ngtcp2_mem.h"
#include "ngtcp2_range.h"
static ngtcp2_ksl_blk null_blk;
@@ -815,12 +814,6 @@ int ngtcp2_ksl_it_begin(const ngtcp2_ksl_it *it) {
return it->i == 0 && it->blk->prev == NULL;
}
int ngtcp2_ksl_range_compar(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
const ngtcp2_range *a = lhs, *b = rhs;
return a->begin < b->begin;
}
ngtcp2_ksl_search_def(range, ngtcp2_ksl_range_compar)
size_t ngtcp2_ksl_range_search(const ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk,
@@ -828,13 +821,6 @@ size_t ngtcp2_ksl_range_search(const ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk,
return ksl_range_search(ksl, blk, key);
}
int ngtcp2_ksl_range_exclusive_compar(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
const ngtcp2_range *a = lhs, *b = rhs;
return a->begin < b->begin && !(ngtcp2_max_uint64(a->begin, b->begin) <
ngtcp2_min_uint64(a->end, b->end));
}
ngtcp2_ksl_search_def(range_exclusive, ngtcp2_ksl_range_exclusive_compar)
size_t ngtcp2_ksl_range_exclusive_search(const ngtcp2_ksl *ksl,
@@ -843,11 +829,6 @@ size_t ngtcp2_ksl_range_exclusive_search(const ngtcp2_ksl *ksl,
return ksl_range_exclusive_search(ksl, blk, key);
}
int ngtcp2_ksl_uint64_less(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
return *(uint64_t *)lhs < *(uint64_t *)rhs;
}
ngtcp2_ksl_search_def(uint64_less, ngtcp2_ksl_uint64_less)
size_t ngtcp2_ksl_uint64_less_search(const ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk,
@@ -855,11 +836,6 @@ size_t ngtcp2_ksl_uint64_less_search(const ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk,
return ksl_uint64_less_search(ksl, blk, key);
}
int ngtcp2_ksl_int64_greater(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
return *(int64_t *)lhs > *(int64_t *)rhs;
}
ngtcp2_ksl_search_def(int64_greater, ngtcp2_ksl_int64_greater)
size_t ngtcp2_ksl_int64_greater_search(const ngtcp2_ksl *ksl,
+22 -8
View File
@@ -34,6 +34,7 @@
#include <ngtcp2/ngtcp2.h>
#include "ngtcp2_objalloc.h"
#include "ngtcp2_range.h"
#define NGTCP2_KSL_DEGR 16
/* NGTCP2_KSL_MAX_NBLK is the maximum number of nodes which a single
@@ -356,8 +357,12 @@ static inline const ngtcp2_ksl_key *ngtcp2_ksl_it_key(const ngtcp2_ksl_it *it) {
* returns nonzero if ((const ngtcp2_range *)lhs)->begin < ((const
* ngtcp2_range *)rhs)->begin.
*/
int ngtcp2_ksl_range_compar(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs);
static inline int ngtcp2_ksl_range_compar(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
const ngtcp2_range *a = (const ngtcp2_range *)lhs,
*b = (const ngtcp2_range *)rhs;
return a->begin < b->begin;
}
/*
* ngtcp2_ksl_range_search is an implementation of ngtcp2_ksl_search
@@ -373,8 +378,13 @@ size_t ngtcp2_ksl_range_search(const ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk,
* *)lhs)->begin < ((const ngtcp2_range *)rhs)->begin, and the 2
* ranges do not intersect.
*/
int ngtcp2_ksl_range_exclusive_compar(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs);
static inline int ngtcp2_ksl_range_exclusive_compar(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
const ngtcp2_range *a = (const ngtcp2_range *)lhs,
*b = (const ngtcp2_range *)rhs;
return a->begin < b->begin && !(ngtcp2_max_uint64(a->begin, b->begin) <
ngtcp2_min_uint64(a->end, b->end));
}
/*
* ngtcp2_ksl_range_exclusive_search is an implementation of
@@ -389,8 +399,10 @@ size_t ngtcp2_ksl_range_exclusive_search(const ngtcp2_ksl *ksl,
* |lhs| and |rhs| must point to uint64_t objects, and the function
* returns nonzero if *(uint64_t *)|lhs| < *(uint64_t *)|rhs|.
*/
int ngtcp2_ksl_uint64_less(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs);
static inline int ngtcp2_ksl_uint64_less(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
return *(const uint64_t *)lhs < *(const uint64_t *)rhs;
}
/*
* ngtcp2_ksl_uint64_less_search is an implementation of
@@ -404,8 +416,10 @@ size_t ngtcp2_ksl_uint64_less_search(const ngtcp2_ksl *ksl, ngtcp2_ksl_blk *blk,
* |lhs| and |rhs| must point to int64_t objects, and the function
* returns nonzero if *(int64_t *)|lhs| > *(int64_t *)|rhs|.
*/
int ngtcp2_ksl_int64_greater(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs);
static inline int ngtcp2_ksl_int64_greater(const ngtcp2_ksl_key *lhs,
const ngtcp2_ksl_key *rhs) {
return *(const int64_t *)lhs > *(const int64_t *)rhs;
}
/*
* ngtcp2_ksl_int64_greater_search is an implementation of
+9 -26
View File
@@ -146,33 +146,22 @@ static const char *strapperrorcode(uint64_t app_error_code) {
return "(unknown)";
}
static const char *strpkttype_long(uint8_t type) {
switch (type) {
static const char *strpkttype(const ngtcp2_pkt_hd *hd) {
switch (hd->type) {
case NGTCP2_PKT_INITIAL:
return "Initial";
case NGTCP2_PKT_RETRY:
return "Retry";
case NGTCP2_PKT_HANDSHAKE:
return "Handshake";
case NGTCP2_PKT_0RTT:
return "0RTT";
default:
return "(unknown)";
}
}
static const char *strpkttype(const ngtcp2_pkt_hd *hd) {
if (hd->flags & NGTCP2_PKT_FLAG_LONG_FORM) {
return strpkttype_long(hd->type);
}
switch (hd->type) {
case NGTCP2_PKT_HANDSHAKE:
return "Handshake";
case NGTCP2_PKT_RETRY:
return "Retry";
case NGTCP2_PKT_1RTT:
return "1RTT";
case NGTCP2_PKT_VERSION_NEGOTIATION:
return "VN";
case NGTCP2_PKT_STATELESS_RESET:
return "SR";
case NGTCP2_PKT_1RTT:
return "1RTT";
default:
return "(unknown)";
}
@@ -266,7 +255,7 @@ static void log_fr_connection_close(ngtcp2_log *log, const ngtcp2_pkt_hd *hd,
log, NGTCP2_LOG_EVENT_FRM,
NGTCP2_LOG_PKT " CONNECTION_CLOSE(0x%02" PRIx64 ") error_code=%s(0x%" PRIx64
") "
"frame_type=%" PRIx64 " reason_len=%zu reason=[%s]",
"frame_type=0x%" PRIx64 " reason_len=%zu reason=[%s]",
NGTCP2_LOG_PKT_HD_FIELDS(dir), fr->type,
fr->type == NGTCP2_FRAME_CONNECTION_CLOSE ? strerrorcode(fr->error_code)
: strapperrorcode(fr->error_code),
@@ -766,12 +755,6 @@ void ngtcp2_log_tx_pkt_hd(ngtcp2_log *log, const ngtcp2_pkt_hd *hd) {
log_pkt_hd(log, hd, "tx");
}
void ngtcp2_log_tx_cancel(ngtcp2_log *log, const ngtcp2_pkt_hd *hd) {
ngtcp2_log_infof(log, NGTCP2_LOG_EVENT_PKT,
"cancel tx pkn=%" PRId64 " type=%s", hd->pkt_num,
strpkttype(hd));
}
uint64_t ngtcp2_log_timestamp(const ngtcp2_log *log) {
return (log->last_ts - log->ts) / NGTCP2_MILLISECONDS;
}
-2
View File
@@ -119,8 +119,6 @@ void ngtcp2_log_rx_pkt_hd(ngtcp2_log *log, const ngtcp2_pkt_hd *hd);
void ngtcp2_log_tx_pkt_hd(ngtcp2_log *log, const ngtcp2_pkt_hd *hd);
void ngtcp2_log_tx_cancel(ngtcp2_log *log, const ngtcp2_pkt_hd *hd);
#define NGTCP2_LOG_HD "I%08" PRIu64 " 0x%s %s"
uint64_t ngtcp2_log_timestamp(const ngtcp2_log *log);
+8 -10
View File
@@ -543,7 +543,7 @@ ngtcp2_ssize ngtcp2_frame_decoder_decode(ngtcp2_frame_decoder *frd,
return ngtcp2_pkt_decode_path_response_frame(&dest->path_response, payload,
payloadlen);
case NGTCP2_FRAME_CRYPTO:
dest->stream.data = &frd->buf.stream_data;
dest->stream.data = &frd->buf.data;
return ngtcp2_pkt_decode_crypto_frame(&dest->stream, payload, payloadlen);
case NGTCP2_FRAME_NEW_TOKEN:
return ngtcp2_pkt_decode_new_token_frame(&dest->new_token, payload,
@@ -556,11 +556,12 @@ ngtcp2_ssize ngtcp2_frame_decoder_decode(ngtcp2_frame_decoder *frd,
payload, payloadlen);
case NGTCP2_FRAME_DATAGRAM:
case NGTCP2_FRAME_DATAGRAM_LEN:
dest->datagram.data = &frd->buf.data;
return ngtcp2_pkt_decode_datagram_frame(&dest->datagram, payload,
payloadlen);
default:
if ((type & ~(NGTCP2_FRAME_STREAM - 1)) == NGTCP2_FRAME_STREAM) {
dest->stream.data = &frd->buf.stream_data;
dest->stream.data = &frd->buf.data;
return ngtcp2_pkt_decode_stream_frame(&dest->stream, payload, payloadlen);
}
@@ -1490,16 +1491,13 @@ ngtcp2_ssize ngtcp2_pkt_decode_datagram_frame(ngtcp2_datagram *dest,
dest->type = type;
if (datalen == 0) {
dest->datacnt = 0;
dest->data = NULL;
} else {
if (datalen) {
dest->data[0].len = datalen;
dest->data[0].base = (uint8_t *)p;
dest->datacnt = 1;
dest->data = dest->rdata;
dest->rdata[0].len = datalen;
dest->rdata[0].base = (uint8_t *)p;
p += datalen;
} else {
dest->datacnt = 0;
}
assert((size_t)(p - payload) == len);
+3 -7
View File
@@ -340,13 +340,9 @@ typedef struct ngtcp2_datagram {
uint64_t dgram_id;
/* datacnt is the number of elements that data contains. */
size_t datacnt;
/* data is a pointer to ngtcp2_vec array that stores data. */
/* data is a pointer to ngtcp2_vec array that stores data. If
datacnt == 0, this field may be NULL.*/
ngtcp2_vec *data;
/* rdata is conveniently embedded to ngtcp2_datagram, so that data
field can just point to the address of this field to store a
single vector which is the case when DATAGRAM is received from a
remote endpoint. */
ngtcp2_vec rdata[1];
} ngtcp2_datagram;
typedef union ngtcp2_frame {
@@ -457,7 +453,7 @@ ngtcp2_ssize ngtcp2_pkt_encode_hd_short(uint8_t *out, size_t outlen,
*/
typedef struct ngtcp2_frame_decoder {
union {
ngtcp2_vec stream_data;
ngtcp2_vec data;
ngtcp2_ack_range ack_ranges[NGTCP2_MAX_ACK_RANGES];
} buf;
} ngtcp2_frame_decoder;
+10 -17
View File
@@ -223,28 +223,21 @@ static const ngtcp2_vec vec_pkt_type_stateless_reset =
static const ngtcp2_vec vec_pkt_type_unknown = ngtcp2_make_vec_lit("unknown");
static const ngtcp2_vec *qlog_pkt_type(const ngtcp2_pkt_hd *hd) {
if (hd->flags & NGTCP2_PKT_FLAG_LONG_FORM) {
switch (hd->type) {
case NGTCP2_PKT_INITIAL:
return &vec_pkt_type_initial;
case NGTCP2_PKT_HANDSHAKE:
return &vec_pkt_type_handshake;
case NGTCP2_PKT_0RTT:
return &vec_pkt_type_0rtt;
case NGTCP2_PKT_RETRY:
return &vec_pkt_type_retry;
default:
return &vec_pkt_type_unknown;
}
}
switch (hd->type) {
case NGTCP2_PKT_INITIAL:
return &vec_pkt_type_initial;
case NGTCP2_PKT_0RTT:
return &vec_pkt_type_0rtt;
case NGTCP2_PKT_HANDSHAKE:
return &vec_pkt_type_handshake;
case NGTCP2_PKT_RETRY:
return &vec_pkt_type_retry;
case NGTCP2_PKT_1RTT:
return &vec_pkt_type_1rtt;
case NGTCP2_PKT_VERSION_NEGOTIATION:
return &vec_pkt_type_version_negotiation;
case NGTCP2_PKT_STATELESS_RESET:
return &vec_pkt_type_stateless_reset;
case NGTCP2_PKT_1RTT:
return &vec_pkt_type_1rtt;
default:
return &vec_pkt_type_unknown;
}