Skip to content

Commit

Permalink
Reproduced the link-cut issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
huitema committed Nov 22, 2023
1 parent 7231b3e commit b5984e0
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
14 changes: 14 additions & 0 deletions UnitTest1/unittest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1027,6 +1027,20 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(heavy_loss_inter)
{
int ret = heavy_loss_inter_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(heavy_loss_total)
{
int ret = heavy_loss_total_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(test_spurious_retransmit)
{
int ret = spurious_retransmit_test();
Expand Down
2 changes: 2 additions & 0 deletions picoquic_t/picoquic_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ static const picoquic_test_def_t test_table[] = {
{ "multi_segment", multi_segment_test },
{ "pacing_cc", pacing_cc_test },
{ "heavy_loss", heavy_loss_test },
{ "heavy_loss_inter", heavy_loss_inter_test },
{ "heavy_loss_total", heavy_loss_total_test },
{ "spurious_retransmit", spurious_retransmit_test },
{ "tls_zero_share", tls_zero_share_test },
{ "transport_param_log", transport_param_log_test },
Expand Down
2 changes: 2 additions & 0 deletions picoquictest/picoquictest.h
Original file line number Diff line number Diff line change
Expand Up @@ -428,6 +428,8 @@ int red_cc_test();
int multi_segment_test();
int pacing_cc_test();
int heavy_loss_test();
int heavy_loss_inter_test();
int heavy_loss_total_test();
int integrity_limit_test();
int excess_repeat_test();
int netperf_basic_test();
Expand Down
62 changes: 60 additions & 2 deletions picoquictest/tls_api_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -11499,6 +11499,31 @@ int pacing_cc_test()
* up and the transfer completes.
*/

test_api_stream_desc_t* heavy_loss_inter_scenario(size_t* scenario_size)
{
size_t nb_rounds = 100;
size_t sc_z = sizeof(test_api_stream_desc_t) * nb_rounds;
test_api_stream_desc_t* sc;
uint64_t previous_stream_id = 0;
uint64_t next_stream_id = 4;

sc = (test_api_stream_desc_t*)malloc(sc_z);
if (sc != NULL) {
memset(sc, 0, sc_z);

for (int i = 0; i < nb_rounds; i++) {
sc[i].previous_stream_id = previous_stream_id;
sc[i].stream_id = next_stream_id;
sc[i].q_len = 255;
sc[i].r_len = 1000;
previous_stream_id = next_stream_id;
next_stream_id += 4;
}
*scenario_size = sc_z;
}
return sc;
}

int heavy_loss_test_one(int scenario_id, uint64_t completion_target)
{
uint64_t simulated_time = 0;
Expand All @@ -11520,6 +11545,22 @@ int heavy_loss_test_one(int scenario_id, uint64_t completion_target)
test_ctx->qserver->use_long_log = 1;
}

if (ret == 0 && scenario_id == 1) {
allocated_scenario = heavy_loss_inter_scenario(&scenario_size);
if (allocated_scenario == NULL) {
DBG_PRINTF("%s", "Could not allocate interactive scenario");
ret = -1;
}
else {
scenario = allocated_scenario;
}
}

if (ret == 0 && scenario_id == 2) {
test_ctx->qserver->default_tp.idle_timeout = 60000000;
test_ctx->cnx_client->local_parameters.idle_timeout = 60000000;
}

if (ret == 0) {
ret = tls_api_connection_loop(test_ctx, &loss_mask, 0, &simulated_time);
}
Expand All @@ -11535,11 +11576,12 @@ int heavy_loss_test_one(int scenario_id, uint64_t completion_target)
}

/* Send for up to 30 seconds, with 50% packet loss rate.
* Stop earlier if somehin breaks, or if all the required
* Stop earlier if something breaks, or if all the required
* data is sent.
* In scenario 2, simulate "total loss".
*/
if (ret == 0) {
loss_mask = 0x13596ac77ca69531ull;
loss_mask = (scenario_id == 2)?UINT64_MAX:0x13596ac77ca69531ull;
for (int i = 0; ret == 0 && !test_ctx->test_finished && i < 30; i++) {
ret = tls_api_wait_for_timeout(test_ctx, &simulated_time, 1000000);
}
Expand All @@ -11561,6 +11603,10 @@ int heavy_loss_test_one(int scenario_id, uint64_t completion_target)
test_ctx = NULL;
}

if (allocated_scenario != NULL) {
free(allocated_scenario);
}

return ret;
}

Expand All @@ -11569,6 +11615,18 @@ int heavy_loss_test()
return heavy_loss_test_one(0, 33000000);
}

int heavy_loss_inter_test()
{
return heavy_loss_test_one(1, 33000000);
}

int heavy_loss_total_test()
{
return heavy_loss_test_one(2, 33000000);
}



int integrity_limit_test()
{
uint64_t simulated_time = 0;
Expand Down

0 comments on commit b5984e0

Please sign in to comment.