Skip to content

Commit

Permalink
Merge pull request #1630 from private-octopus/bbr3-quantum-ratio
Browse files Browse the repository at this point in the history
Port quantum ratio API to BBrv3
  • Loading branch information
huitema authored Feb 9, 2024
2 parents 5a24917 + 39cd7f6 commit e48e4d0
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 3 deletions.
8 changes: 7 additions & 1 deletion picoquic/bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,7 @@ typedef struct st_picoquic_bbr_state_t {

/* Experimental extensions, may or maynot be a good idea. */
uint64_t wifi_shadow_rtt; /* Shadow RTT used for wifi connections. */
double quantum_ratio; /* allow application to use a different default than 0.1% of bandwidth (or 1ms of traffic) */

} picoquic_bbr_state_t;

Expand Down Expand Up @@ -392,6 +393,11 @@ static void BBROnInit(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x,
bbr_state->extra_acked_delivered = 0;
/* Support for the wifi_shadow_rtt hack */
bbr_state->wifi_shadow_rtt = path_x->cnx->quic->wifi_shadow_rtt;
/* Support for experimenting with the send_quantum ratio */
bbr_state->quantum_ratio = path_x->cnx->quic->bbr_quantum_ratio;
if (bbr_state->quantum_ratio == 0) {
bbr_state->quantum_ratio = 0.001;
}

/* TODO, maybe: plug in the "shadow RTT".
*/
Expand Down Expand Up @@ -753,7 +759,7 @@ static void BBRSetSendQuantum(picoquic_bbr_state_t* bbr_state, picoquic_path_t*
floor = 1 * path_x->send_mtu;
}
/* 1 ms = 1000000us/1000 */
bbr_state->send_quantum = (uint64_t)(bbr_state->pacing_rate / 1000.0);
bbr_state->send_quantum = (uint64_t)(bbr_state->pacing_rate * bbr_state->quantum_ratio);
if (bbr_state->send_quantum > 0x10000) {
bbr_state->send_quantum = 0x10000;
}
Expand Down
10 changes: 8 additions & 2 deletions picoquic/bbr1.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,8 @@ typedef struct st_picoquic_bbr1_state_t {
uint64_t cwin_before_suspension; /* So it can be restored if suspension stops. */

uint64_t wifi_shadow_rtt; /* Shadow RTT used for wifi connections. */
double quantum_ratio;

unsigned int filled_pipe : 1;
unsigned int round_start : 1;
unsigned int rt_prop_expired : 1;
Expand Down Expand Up @@ -337,7 +339,7 @@ void BBR1SetSendQuantum(picoquic_bbr1_state_t* bbr1_state, picoquic_path_t* path
bbr1_state->send_quantum = 2ull * path_x->send_mtu;
}
else {
bbr1_state->send_quantum = (uint64_t)(bbr1_state->pacing_rate * 0.001);
bbr1_state->send_quantum = (uint64_t)(bbr1_state->pacing_rate * bbr1_state->quantum_ratio);
if (bbr1_state->send_quantum > 0x10000) {
bbr1_state->send_quantum = 0x10000;
}
Expand Down Expand Up @@ -371,7 +373,11 @@ static void picoquic_bbr1_reset(picoquic_bbr1_state_t* bbr1_state, picoquic_path
memset(bbr1_state, 0, sizeof(picoquic_bbr1_state_t));
path_x->cwin = PICOQUIC_CWIN_INITIAL;
bbr1_state->rt_prop = UINT64_MAX;
bbr1_state->wifi_shadow_rtt = wifi_shadow_rtt;
bbr1_state->wifi_shadow_rtt = path_x->cnx->quic->wifi_shadow_rtt;
bbr1_state->quantum_ratio = path_x->cnx->quic->bbr_quantum_ratio;
if (bbr1_state->quantum_ratio == 0) {
bbr1_state->quantum_ratio = 0.001;
}

bbr1_state->rt_prop_stamp = current_time;
bbr1_state->cycle_stamp = current_time;
Expand Down
10 changes: 10 additions & 0 deletions picoquic/picoquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1464,6 +1464,16 @@ void picoquic_set_congestion_algorithm(picoquic_cnx_t* cnx, picoquic_congestion_
*/
void picoquic_set_default_wifi_shadow_rtt(picoquic_quic_t* quic, uint64_t wifi_shadow_rtt);

/* The experimental API `picoquic_set_default_bbr_quantum_ratio`
* allows application to change the "quantum ratio" parameter of the BBR
* algorithm. The default value is 0.001 (1/1000th of the pacing rate
* in bytes per second). Larger values like 0.01 would increase the
* size of the "leaky bucket" used by the pacing algorithms. Whether
* that's a good idea or not is debatable, probably depends on the
* application.
*/
void picoquic_set_default_bbr_quantum_ratio(picoquic_quic_t* quic, double quantum_ratio);

/* Bandwidth update and congestion control parameters value.
* Congestion control in picoquic is characterized by three values:
* - pacing rate, expressed in bytes per second (for example, 10Mbps would be noted as 1250000)
Expand Down
1 change: 1 addition & 0 deletions picoquic/picoquic_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,7 @@ typedef struct st_picoquic_quic_t {

picoquic_congestion_algorithm_t const* default_congestion_alg;
uint64_t wifi_shadow_rtt;
double bbr_quantum_ratio;

struct st_picoquic_cnx_t* cnx_list;
struct st_picoquic_cnx_t* cnx_last;
Expand Down
5 changes: 5 additions & 0 deletions picoquic/quicctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -4528,6 +4528,11 @@ void picoquic_set_default_wifi_shadow_rtt(picoquic_quic_t* quic, uint64_t wifi_s
quic->wifi_shadow_rtt = wifi_shadow_rtt;
}

void picoquic_set_default_bbr_quantum_ratio(picoquic_quic_t* quic, double quantum_ratio)
{
quic->bbr_quantum_ratio = quantum_ratio;
}

void picoquic_subscribe_pacing_rate_updates(picoquic_cnx_t* cnx, uint64_t decrease_threshold, uint64_t increase_threshold)
{
cnx->pacing_decrease_threshold = decrease_threshold;
Expand Down

0 comments on commit e48e4d0

Please sign in to comment.