Skip to content

Commit

Permalink
Rewrite BBR handling of limited applications
Browse files Browse the repository at this point in the history
  • Loading branch information
huitema committed Sep 19, 2023
1 parent 1e2979e commit c157bc5
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 19 deletions.
7 changes: 7 additions & 0 deletions UnitTest1/unittest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,13 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(datagram_small_packet)
{
int ret = datagram_small_packet_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(datagram_wifi)
{
int ret = datagram_wifi_test();
Expand Down
44 changes: 26 additions & 18 deletions picoquic/bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -526,27 +526,35 @@ void BBRUpdateBtlBw(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, ui
BBRltbwSampling(bbr_state, path_x, current_time);

if (bbr_state->round_start) {
/* Forget the oldest BW round, shift by 1, compute the max BTL_BW for
* the remaining rounds, set current round max to current value */

bbr_state->btl_bw = 0;

for (int i = BBR_BTL_BW_FILTER_LENGTH - 2; i >= 0; i--) {
uint64_t b = bbr_state->btl_bw_filter[i];
bbr_state->btl_bw_filter[i + 1] = b;
if (b > bbr_state->btl_bw) {
bbr_state->btl_bw = b;
if (bandwidth_estimate > bbr_state->btl_bw ||
!path_x->last_bw_estimate_path_limited) {
/* Forget the oldest BW round, shift by 1, compute the max BTL_BW for
* the remaining rounds, set current round max to current value */
bbr_state->btl_bw = 0;
for (int i = BBR_BTL_BW_FILTER_LENGTH - 2; i >= 0; i--) {
uint64_t b = bbr_state->btl_bw_filter[i];
bbr_state->btl_bw_filter[i + 1] = b;
if (b > bbr_state->btl_bw) {
bbr_state->btl_bw = b;
}
}
bbr_state->btl_bw_increased |= (bandwidth_estimate > bbr_state->btl_bw_filter[0]);
bbr_state->btl_bw_filter[0] = bandwidth_estimate;
if (bandwidth_estimate > bbr_state->btl_bw) {
bbr_state->btl_bw = bandwidth_estimate;
}
}

bbr_state->btl_bw_filter[0] = 0;
else {
bbr_state->btl_bw_increased = 0;
}
}

if (bandwidth_estimate > bbr_state->btl_bw_filter[0]) {
bbr_state->btl_bw_filter[0] =bandwidth_estimate;
if (bandwidth_estimate > bbr_state->btl_bw) {
bbr_state->btl_bw = bandwidth_estimate;
bbr_state->btl_bw_increased = 1;
else {
if (bandwidth_estimate > bbr_state->btl_bw_filter[0]) {
bbr_state->btl_bw_filter[0] =bandwidth_estimate;
if (bandwidth_estimate > bbr_state->btl_bw) {
bbr_state->btl_bw = bandwidth_estimate;
bbr_state->btl_bw_increased = 1;
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions picoquic_t/picoquic_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ static const picoquic_test_def_t test_table[] = {
{ "datagram_size", datagram_size_test },
{ "datagram_small", datagram_small_test },
{ "datagram_small_new", datagram_small_new_test },
{ "datagram_small_packet", datagram_small_packet_test },
{ "datagram_wifi", datagram_wifi_test },
{ "ddos_amplification", ddos_amplification_test },
{ "ddos_amplification_0rtt", ddos_amplification_0rtt_test },
Expand Down
29 changes: 28 additions & 1 deletion picoquictest/datagram_tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int test_datagram_send(picoquic_cnx_t* cnx, uint64_t unique_path_id,
skipping = 1;
if (dg_ctx->use_extended_provider_api) {
is_active = test_datagram_check_ready(dg_ctx, cnx->client_mode, current_time);
(void)picoquic_provide_datagram_buffer_ex(bytes, 0, is_active);
(void)picoquic_provide_datagram_buffer_ex(bytes, 0, (is_active && !dg_ctx->one_datagram_per_packet));
}
}
else if (!dg_ctx->is_ready[cnx->client_mode] || (dg_ctx->test_affinity && unique_path_id != 0)) {
Expand All @@ -119,7 +119,9 @@ int test_datagram_send(picoquic_cnx_t* cnx, uint64_t unique_path_id,
if (dg_ctx->test_affinity) {
is_active = picoquic_datagram_active_this_path_only;
}
is_active &= !dg_ctx->one_datagram_per_packet;
buffer = picoquic_provide_datagram_buffer_ex(bytes, available, is_active);
dg_ctx->is_ready[cnx->client_mode] = is_active;
}
else {
buffer = picoquic_provide_datagram_buffer(bytes, available);
Expand Down Expand Up @@ -269,6 +271,10 @@ int datagram_test_one(uint8_t test_id, test_datagram_send_recv_ctx_t *dg_ctx, ui
test_ctx->c_to_s_link->microsec_latency = dg_ctx->link_latency;
test_ctx->s_to_c_link->microsec_latency = dg_ctx->link_latency;
}
if (dg_ctx->picosec_per_byte != 0) {
test_ctx->c_to_s_link->picosec_per_byte = dg_ctx->picosec_per_byte;
test_ctx->s_to_c_link->picosec_per_byte = dg_ctx->picosec_per_byte;
}
/* Set parameters */
picoquic_init_transport_parameters(&client_parameters, 1);
client_parameters.max_datagram_frame_size = dg_ctx->dg_max_size;
Expand Down Expand Up @@ -602,3 +608,24 @@ int datagram_wifi_test()

return datagram_test_one(8, &dg_ctx, 0);
}

int datagram_small_packet_test()
{
test_datagram_send_recv_ctx_t dg_ctx = { 0 };
dg_ctx.dg_max_size = 512;
dg_ctx.dg_small_size = 64;
dg_ctx.dg_target[0] = 100;
dg_ctx.dg_target[1] = 20000;
dg_ctx.send_delay = 100;
dg_ctx.next_gen_time[0] = 50000;
dg_ctx.next_gen_time[1] = 50000;
dg_ctx.link_latency = 10000;
dg_ctx.picosec_per_byte = 20000; /* 400 Mbps */
dg_ctx.dg_latency_target[0] = 100000;
dg_ctx.dg_latency_target[1] = 100000;
dg_ctx.use_extended_provider_api = 1;
dg_ctx.one_datagram_per_packet = 1;
dg_ctx.nb_trials_max = 200000;

return datagram_test_one(9, &dg_ctx, 0);
}
1 change: 1 addition & 0 deletions picoquictest/picoquictest.h
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ int datagram_loss_test();
int datagram_size_test();
int datagram_small_test();
int datagram_small_new_test();
int datagram_small_packet_test();
int datagram_wifi_test();
int ddos_amplification_test();
int ddos_amplification_0rtt_test();
Expand Down
2 changes: 2 additions & 0 deletions picoquictest/picoquictest_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ typedef struct st_test_datagram_send_recv_ctx_t {
uint64_t dg_latency_target[2];
uint64_t dg_number_delta_target[2];
uint64_t link_latency;
uint64_t picosec_per_byte;
uint64_t send_delay;
uint64_t next_gen_time[2];
int is_ready[2];
Expand All @@ -82,6 +83,7 @@ typedef struct st_test_datagram_send_recv_ctx_t {
unsigned int is_skipping[2];
unsigned int test_affinity;
unsigned int test_wifi;
unsigned int one_datagram_per_packet;

} test_datagram_send_recv_ctx_t;

Expand Down

0 comments on commit c157bc5

Please sign in to comment.