Skip to content

Commit

Permalink
Try wifi-shadow-rtt
Browse files Browse the repository at this point in the history
  • Loading branch information
huitema committed Sep 1, 2023
1 parent 1e2979e commit b5799de
Show file tree
Hide file tree
Showing 13 changed files with 124 additions and 77 deletions.
6 changes: 6 additions & 0 deletions UnitTest1/unittest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2020,6 +2020,12 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(wifi_bbr_shadow) {
int ret = wifi_bbr_shadow_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(wifi_cubic) {
int ret = wifi_cubic_test();

Expand Down
18 changes: 13 additions & 5 deletions picoquic/bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ typedef struct st_picoquic_bbr_state_t {
uint64_t loss_interval_start; /* Time in microsec when last loss considered */
uint64_t congestion_sequence; /* sequence number after congestion notification */

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

unsigned int filled_pipe : 1;
unsigned int round_start : 1;
unsigned int rt_prop_expired : 1;
Expand Down Expand Up @@ -322,7 +324,11 @@ uint64_t BBRInflight(picoquic_bbr_state_t* bbr_state, double gain)
uint64_t cwnd = PICOQUIC_CWIN_INITIAL;
if (bbr_state->rt_prop != UINT64_MAX){
/* Bandwidth is estimated in bytes per second, rtt in microseconds*/
double estimated_bdp = (((double)BBRGetBtlBW(bbr_state) * (double)bbr_state->rt_prop) / 1000000.0);
uint64_t rt_target = bbr_state->rt_prop;
if (bbr_state->rt_prop < bbr_state->wifi_shadow_rtt) {
rt_target = bbr_state->wifi_shadow_rtt;
}
double estimated_bdp = (((double)BBRGetBtlBW(bbr_state) * (double)rt_target) / 1000000.0);
uint64_t quanta = 3 * bbr_state->send_quantum;
cwnd = (uint64_t)(gain * estimated_bdp) + quanta;
}
Expand All @@ -335,11 +341,12 @@ void BBRUpdateTargetCwnd(picoquic_bbr_state_t* bbr_state)
bbr_state->target_cwnd = BBRInflight(bbr_state, bbr_state->cwnd_gain);
}

static void picoquic_bbr_reset(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time)
static void picoquic_bbr_reset(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time, uint64_t wifi_shadow_rtt)
{
memset(bbr_state, 0, sizeof(picoquic_bbr_state_t));
path_x->cwin = PICOQUIC_CWIN_INITIAL;
bbr_state->rt_prop = UINT64_MAX;
bbr_state->wifi_shadow_rtt = wifi_shadow_rtt;

bbr_state->rt_prop_stamp = current_time;
bbr_state->cycle_stamp = current_time;
Expand All @@ -351,13 +358,14 @@ static void picoquic_bbr_reset(picoquic_bbr_state_t* bbr_state, picoquic_path_t*
BBRUpdateTargetCwnd(bbr_state);
}

static void picoquic_bbr_init(picoquic_path_t* path_x, uint64_t current_time)
static void picoquic_bbr_init(picoquic_cnx_t * cnx, picoquic_path_t* path_x, uint64_t current_time)
{
/* Initialize the state of the congestion control algorithm */
picoquic_bbr_state_t* bbr_state = (picoquic_bbr_state_t*)malloc(sizeof(picoquic_bbr_state_t));

path_x->congestion_alg_state = (void*)bbr_state;
if (bbr_state != NULL) {
picoquic_bbr_reset(bbr_state, path_x, current_time);
picoquic_bbr_reset(bbr_state, path_x, current_time, cnx->quic->wifi_shadow_rtt);
}
}

Expand Down Expand Up @@ -1127,7 +1135,7 @@ static void picoquic_bbr_notify(
case picoquic_congestion_notification_cwin_blocked:
break;
case picoquic_congestion_notification_reset:
picoquic_bbr_reset(bbr_state, path_x, current_time);
picoquic_bbr_reset(bbr_state, path_x, current_time, cnx->quic->wifi_shadow_rtt);
break;
case picoquic_congestion_notification_seed_cwin:
if (bbr_state->state == picoquic_bbr_alg_startup_long_rtt) {
Expand Down
5 changes: 4 additions & 1 deletion picoquic/cubic.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,13 @@ static void picoquic_cubic_reset(picoquic_cubic_state_t* cubic_state, picoquic_p
path_x->cwin = PICOQUIC_CWIN_INITIAL;
}

static void picoquic_cubic_init(picoquic_path_t* path_x, uint64_t current_time)
static void picoquic_cubic_init(picoquic_cnx_t * cnx, picoquic_path_t* path_x, uint64_t current_time)
{
/* Initialize the state of the congestion control algorithm */
picoquic_cubic_state_t* cubic_state = (picoquic_cubic_state_t*)malloc(sizeof(picoquic_cubic_state_t));
#ifdef _WINDOWS
UNREFERENCED_PARAMETER(cnx);
#endif
path_x->congestion_alg_state = (void*)cubic_state;
if (cubic_state != NULL) {
picoquic_cubic_reset(cubic_state, path_x, current_time);
Expand Down
5 changes: 4 additions & 1 deletion picoquic/fastcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,13 @@ void picoquic_fastcc_seed_cwin(picoquic_fastcc_state_t* fastcc_state, picoquic_p
}
}

void picoquic_fastcc_init(picoquic_path_t* path_x, uint64_t current_time)
void picoquic_fastcc_init(picoquic_cnx_t * cnx, picoquic_path_t* path_x, uint64_t current_time)
{
/* Initialize the state of the congestion control algorithm */
picoquic_fastcc_state_t* fastcc_state = path_x->congestion_alg_state;
#ifdef _WINDOWS
UNREFERENCED_PARAMETER(cnx);
#endif

if (fastcc_state == NULL) {
fastcc_state = (picoquic_fastcc_state_t*)malloc(sizeof(picoquic_fastcc_state_t));
Expand Down
3 changes: 2 additions & 1 deletion picoquic/newreno.c
Original file line number Diff line number Diff line change
Expand Up @@ -183,12 +183,13 @@ static void picoquic_newreno_reset(picoquic_newreno_state_t* nr_state, picoquic_
path_x->cwin = nr_state->nrss.cwin;
}

static void picoquic_newreno_init(picoquic_path_t* path_x, uint64_t current_time)
static void picoquic_newreno_init(picoquic_cnx_t * cnx, picoquic_path_t* path_x, uint64_t current_time)
{
/* Initialize the state of the congestion control algorithm */
picoquic_newreno_state_t* nr_state = (picoquic_newreno_state_t*)malloc(sizeof(picoquic_newreno_state_t));
#ifdef _WINDOWS
UNREFERENCED_PARAMETER(current_time);
UNREFERENCED_PARAMETER(cnx);
#endif

if (nr_state != NULL) {
Expand Down
16 changes: 15 additions & 1 deletion picoquic/picoquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1339,7 +1339,7 @@ typedef enum {
picoquic_congestion_notification_reset
} picoquic_congestion_notification_t;

typedef void (*picoquic_congestion_algorithm_init)(picoquic_path_t* path_x, uint64_t current_time);
typedef void (*picoquic_congestion_algorithm_init)(picoquic_cnx_t* cnx, picoquic_path_t* path_x, uint64_t current_time);
typedef void (*picoquic_congestion_algorithm_notify)(
picoquic_cnx_t* cnx,
picoquic_path_t* path_x,
Expand Down Expand Up @@ -1379,6 +1379,20 @@ void picoquic_set_default_congestion_algorithm_by_name(picoquic_quic_t* quic, ch

void picoquic_set_congestion_algorithm(picoquic_cnx_t* cnx, picoquic_congestion_algorithm_t const* algo);

/* Special code for Wi-Fi network. These networks are subject to occasional
* "suspension", for power saving reasons. If the suspension is too long,
* it causes transmission to stop after cngestion control credits are
* exhausted. We expect that the effects of suspension are not so bad if
* the congestion control parameters allow for transmission through the
* suspension. The "wifi shadow RTT" parameter tells the congestion control
* algorithm BBR to set the CWIN large enough to sustain transmission through
* that duration. The value is in microseconds.
*
* This parameter should be set before the first connections are started.
* Changing the settings will not affect existing connections.
*/
void picoquic_set_default_wifi_shadow_rtt(picoquic_quic_t* quic, uint64_t wifi_shadow_rtt);

/* 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 @@ -665,6 +665,7 @@ typedef struct st_picoquic_quic_t {
picoquic_stateless_packet_t* pending_stateless_packet;

picoquic_congestion_algorithm_t const* default_congestion_alg;
uint64_t wifi_shadow_rtt;

struct st_picoquic_cnx_t* cnx_list;
struct st_picoquic_cnx_t* cnx_last;
Expand Down
5 changes: 4 additions & 1 deletion picoquic/prague.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,13 @@ static void picoquic_prague_init_reno(picoquic_prague_state_t* pr_state, picoqui
path_x->cwin = PICOQUIC_CWIN_INITIAL;
}

void picoquic_prague_init(picoquic_path_t* path_x, uint64_t current_time)
void picoquic_prague_init(picoquic_cnx_t * cnx, picoquic_path_t* path_x, uint64_t current_time)
{
/* Initialize the state of the congestion control algorithm */
picoquic_prague_state_t* pr_state = (picoquic_prague_state_t*)malloc(sizeof(picoquic_prague_state_t));
#ifdef _WINDOWS
UNREFERENCED_PARAMETER(cnx);
#endif

if (pr_state != NULL) {
memset(pr_state, 0, sizeof(picoquic_prague_state_t));
Expand Down
11 changes: 8 additions & 3 deletions picoquic/quicctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -1814,7 +1814,7 @@ void picoquic_promote_path_to_default(picoquic_cnx_t* cnx, int path_index, uint6

/* Set the congestion algorithm for the new path */
if (cnx->congestion_alg != NULL) {
cnx->congestion_alg->alg_init(path_x, current_time);
cnx->congestion_alg->alg_init(cnx, path_x, current_time);
}

/* Mark old path as demoted */
Expand Down Expand Up @@ -3583,7 +3583,7 @@ picoquic_cnx_t* picoquic_create_cnx(picoquic_quic_t* quic,

cnx->congestion_alg = cnx->quic->default_congestion_alg;
if (cnx->congestion_alg != NULL) {
cnx->congestion_alg->alg_init(cnx->path[0], start_time);
cnx->congestion_alg->alg_init(cnx, cnx->path[0], start_time);
}
}

Expand Down Expand Up @@ -4510,12 +4510,17 @@ void picoquic_set_congestion_algorithm(picoquic_cnx_t* cnx, picoquic_congestion_
if (cnx->congestion_alg != NULL) {
if (cnx->path != NULL) {
for (int i = 0; i < cnx->nb_paths; i++) {
cnx->congestion_alg->alg_init(cnx->path[i], picoquic_get_quic_time(cnx->quic));
cnx->congestion_alg->alg_init(cnx, cnx->path[i], picoquic_get_quic_time(cnx->quic));
}
}
}
}

void picoquic_set_default_wifi_shadow_rtt(picoquic_quic_t* quic, uint64_t wifi_shadow_rtt)
{
quic->wifi_shadow_rtt = wifi_shadow_rtt;
}

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
2 changes: 1 addition & 1 deletion picoquic/sender.c
Original file line number Diff line number Diff line change
Expand Up @@ -4503,7 +4503,7 @@ static int picoquic_select_next_path_mp(picoquic_cnx_t* cnx, uint64_t current_ti
int is_new_priority = 0;
/* Set the congestion algorithm for the new path */
if (cnx->congestion_alg != NULL && cnx->path[i]->congestion_alg_state == NULL) {
cnx->congestion_alg->alg_init(cnx->path[i], current_time);
cnx->congestion_alg->alg_init(cnx, cnx->path[i], current_time);
}

if (cnx->path[i]->path_priority > highest_priority) {
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 @@ -358,6 +358,7 @@ static const picoquic_test_def_t test_table[] = {
{ "wifi_bbr", wifi_bbr_test },
{ "wifi_bbr_hard", wifi_bbr_hard_test },
{ "wifi_bbr_long", wifi_bbr_long_test },
{ "wifi_bbr_shadow", wifi_bbr_shadow_test },
{ "wifi_cubic", wifi_cubic_test },
{ "wifi_cubic_hard", wifi_cubic_hard_test },
{ "wifi_cubic_long", wifi_cubic_long_test },
Expand Down
1 change: 1 addition & 0 deletions picoquictest/picoquictest.h
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,7 @@ int warptest_param_test();
int wifi_bbr_test();
int wifi_bbr_hard_test();
int wifi_bbr_long_test();
int wifi_bbr_shadow_test();
int wifi_cubic_test();
int wifi_cubic_hard_test();
int wifi_cubic_long_test();
Expand Down
Loading

0 comments on commit b5799de

Please sign in to comment.