2021-01-06 14:00:05 +00:00
|
|
|
/* Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc. See LICENSE. */
|
2018-03-07 23:46:34 +00:00
|
|
|
#include <assert.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2019-09-11 15:27:58 +00:00
|
|
|
#include <sys/queue.h>
|
2018-03-12 22:25:01 +00:00
|
|
|
#ifndef WIN32
|
2018-03-07 23:46:34 +00:00
|
|
|
#include <unistd.h>
|
2018-03-12 22:25:01 +00:00
|
|
|
#else
|
|
|
|
#include <getopt.h>
|
|
|
|
#endif
|
2018-03-07 23:46:34 +00:00
|
|
|
|
|
|
|
#include "lsquic.h"
|
|
|
|
#include "lsquic_int_types.h"
|
2019-09-11 15:27:58 +00:00
|
|
|
#include "lsquic_cong_ctl.h"
|
2018-03-07 23:46:34 +00:00
|
|
|
#include "lsquic_cubic.h"
|
|
|
|
#include "lsquic_logger.h"
|
2019-09-11 15:27:58 +00:00
|
|
|
#include "lsquic_hash.h"
|
|
|
|
#include "lsquic_conn.h"
|
|
|
|
#include "lsquic_sfcw.h"
|
|
|
|
#include "lsquic_conn_flow.h"
|
|
|
|
#include "lsquic_varint.h"
|
|
|
|
#include "lsquic_hq.h"
|
|
|
|
#include "lsquic_stream.h"
|
|
|
|
#include "lsquic_rtt.h"
|
|
|
|
#include "lsquic_conn_public.h"
|
|
|
|
#include "lsquic_packet_common.h"
|
|
|
|
#include "lsquic_packet_out.h"
|
|
|
|
|
|
|
|
static const struct cong_ctl_if *const cci = &lsquic_cong_cubic_if;
|
2018-03-07 23:46:34 +00:00
|
|
|
|
|
|
|
static void
|
|
|
|
test_post_quiescence_explosion (void)
|
|
|
|
{
|
|
|
|
struct lsquic_cubic cubic;
|
|
|
|
lsquic_time_t const rtt = 10000;
|
|
|
|
lsquic_time_t t = 12345600;
|
2019-09-11 15:27:58 +00:00
|
|
|
struct lsquic_conn lconn = LSCONN_INITIALIZER_CIDLEN(lconn, 8);
|
|
|
|
struct lsquic_conn_public conn_pub = { .lconn = &lconn, };
|
2018-03-07 23:46:34 +00:00
|
|
|
int i;
|
2020-06-03 04:13:30 +00:00
|
|
|
struct lsquic_packet_out packet_out; memset(&packet_out, 0, sizeof(packet_out));
|
2018-03-07 23:46:34 +00:00
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
cci->cci_init(&cubic, &conn_pub, 0);
|
2018-03-07 23:46:34 +00:00
|
|
|
cubic.cu_ssthresh = cubic.cu_cwnd = 32 * 1370;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; ++i)
|
2019-09-11 15:27:58 +00:00
|
|
|
{
|
|
|
|
packet_out.po_sent = t - rtt;
|
|
|
|
cci->cci_ack(&cubic, &packet_out, 1370, t, 0);
|
|
|
|
}
|
2018-03-07 23:46:34 +00:00
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
assert(cci->cci_get_cwnd(&cubic) == 47026);
|
2018-03-07 23:46:34 +00:00
|
|
|
|
|
|
|
t += 25 * 1000 * 1000;
|
2019-09-11 15:27:58 +00:00
|
|
|
cci->cci_was_quiet(&cubic, t, 0 /* bytes in flight (unused) */);
|
|
|
|
packet_out.po_sent = t - rtt;
|
|
|
|
cci->cci_ack(&cubic, &packet_out, 1370, t, 0);
|
|
|
|
assert(cci->cci_get_cwnd(&cubic) == 47060);
|
2018-03-07 23:46:34 +00:00
|
|
|
|
|
|
|
t += 2 * 1000 * 1000;
|
2019-09-11 15:27:58 +00:00
|
|
|
packet_out.po_sent = t - rtt;
|
|
|
|
cci->cci_ack(&cubic, &packet_out, 1370, t, 0);
|
2018-03-07 23:46:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void
|
|
|
|
test_post_quiescence_explosion2 (void)
|
|
|
|
{
|
|
|
|
struct lsquic_cubic cubic;
|
|
|
|
lsquic_time_t const rtt = 10000;
|
|
|
|
lsquic_time_t t = 12345600;
|
2019-09-11 15:27:58 +00:00
|
|
|
struct lsquic_conn lconn = LSCONN_INITIALIZER_CIDLEN(lconn, 8);
|
|
|
|
struct lsquic_conn_public conn_pub = { .lconn = &lconn, };
|
2018-03-07 23:46:34 +00:00
|
|
|
int i;
|
2020-06-03 04:13:30 +00:00
|
|
|
struct lsquic_packet_out packet_out; memset(&packet_out, 0, sizeof(packet_out));
|
2018-03-07 23:46:34 +00:00
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
cci->cci_init(&cubic, &conn_pub, 0);
|
2018-03-07 23:46:34 +00:00
|
|
|
cubic.cu_ssthresh = cubic.cu_cwnd = 32 * 1370;
|
|
|
|
|
|
|
|
for (i = 0; i < 10; ++i)
|
2019-09-11 15:27:58 +00:00
|
|
|
{
|
|
|
|
packet_out.po_sent = t - rtt;
|
|
|
|
cci->cci_ack(&cubic, &packet_out, 1370, t, 1);
|
|
|
|
}
|
2018-03-07 23:46:34 +00:00
|
|
|
|
2019-09-11 15:27:58 +00:00
|
|
|
assert(cci->cci_get_cwnd(&cubic) == 45300);
|
2018-03-07 23:46:34 +00:00
|
|
|
|
|
|
|
t += 25 * 1000 * 1000;
|
2019-09-11 15:27:58 +00:00
|
|
|
cci->cci_was_quiet(&cubic, t, 0 /* bytes in flight (unused) */);
|
|
|
|
packet_out.po_sent = t - rtt;
|
|
|
|
cci->cci_ack(&cubic, &packet_out, 1370, t, 0);
|
|
|
|
assert(cci->cci_get_cwnd(&cubic) == 46754);
|
2018-03-07 23:46:34 +00:00
|
|
|
|
|
|
|
t += 2 * 1000 * 1000;
|
2019-09-11 15:27:58 +00:00
|
|
|
packet_out.po_sent = t - rtt;
|
|
|
|
cci->cci_ack(&cubic, &packet_out, 1370, t, 1);
|
2018-03-07 23:46:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char **argv)
|
|
|
|
{
|
|
|
|
int opt;
|
|
|
|
|
|
|
|
lsquic_log_to_fstream(stderr, LLTS_NONE);
|
|
|
|
|
|
|
|
while (-1 != (opt = getopt(argc, argv, "l:")))
|
|
|
|
{
|
|
|
|
switch (opt)
|
|
|
|
{
|
|
|
|
case 'l':
|
|
|
|
lsquic_logger_lopt(optarg);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
exit(EXIT_FAILURE);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
test_post_quiescence_explosion();
|
|
|
|
test_post_quiescence_explosion2();
|
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|