Skip to content

Commit

Permalink
Merge remote-tracking branch 'refs/remotes/picoquic/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hfstco committed Aug 20, 2024
2 parents 2b14247 + e78af22 commit dcf1c60
Show file tree
Hide file tree
Showing 22 changed files with 421 additions and 61 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ else()
endif()

project(picoquic
VERSION 1.1.21.8
VERSION 1.1.22.0
DESCRIPTION "picoquic library"
LANGUAGES C CXX)

Expand Down
18 changes: 18 additions & 0 deletions UnitTest1/unittest1.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2268,6 +2268,12 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(mediatest_video2_probe) {
int ret = mediatest_video2_probe_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(mediatest_wifi) {
int ret = mediatest_wifi_test();

Expand All @@ -2286,6 +2292,12 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(mediatest_suspension2) {
int ret = mediatest_suspension2_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(warptest_video) {
int ret = warptest_video_test();

Expand Down Expand Up @@ -2825,6 +2837,12 @@ namespace UnitTest1
Assert::AreEqual(ret, 0);
}

TEST_METHOD(h3zero_get_content_type_by_path) {
int ret = h3zero_get_content_type_by_path_test();

Assert::AreEqual(ret, 0);
}

TEST_METHOD(http_drop) {
int ret = http_drop_test();

Expand Down
10 changes: 5 additions & 5 deletions picohttp/h3zero.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,14 +214,14 @@ h3zero_qpack_static_t qpack_static[] = {
{ 41, http_header_cache_control, "public, max-age=31536000", 0},
{ 42, http_header_content_encoding, "br", 0},
{ 43, http_header_content_encoding, "gzip", 0},
{ 44, http_header_content_type, "application/dns-message", 0},
{ 45, http_header_content_type, "application/javascript", 0},
{ 46, http_header_content_type, "application/json", 0},
{ 47, http_header_content_type, "application/x-www-form-urlencoded", 0},
{ 44, http_header_content_type, "application/dns-message", h3zero_content_type_dns_message},
{ 45, http_header_content_type, "application/javascript", h3zero_content_type_javascript},
{ 46, http_header_content_type, "application/json", h3zero_content_type_json},
{ 47, http_header_content_type, "application/x-www-form-urlencoded", h3zero_content_type_www_form_urlencoded},
{ 48, http_header_content_type, "image/gif", h3zero_content_type_image_gif},
{ 49, http_header_content_type, "image/jpeg", h3zero_content_type_image_jpeg},
{ 50, http_header_content_type, "image/png", h3zero_content_type_image_png},
{ 51, http_header_content_type, "text/css", 0},
{ 51, http_header_content_type, "text/css", h3zero_content_type_text_css},
{ 52, http_header_content_type, "text/html; charset=utf-8", h3zero_content_type_text_html},
{ 53, http_header_content_type, "text/plain", h3zero_content_type_text_plain},
{ 54, http_header_content_type, "text/plain;charset=utf-8", h3zero_content_type_text_plain},
Expand Down
53 changes: 52 additions & 1 deletion picohttp/h3zero_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -914,6 +914,54 @@ int h3zero_find_path_item(const uint8_t * path, size_t path_length, const picoht
return -1;
}

/* TODO find a better place. */
h3zero_content_type_enum h3zero_get_content_type_by_path(const char *path) {
if (path != NULL) {
/* Dots in paths allowed.
* https://datatracker.ietf.org/doc/html/rfc1738
* path -> segment -> xpalphas -> xalpha -> alpha | digit | safe | extra | escape -> safe = $ | - | _ | @ | . |
*/

const char *dot = strrchr(path, '.'); /* recursive to get the last occuraence. */
/* if dot is found. */
if(dot && dot != path) {
const char *ext = dot + 1;

/*
* h3zero_content_type_none = 0,
* h3zero_content_type_not_supported,
* h3zero_content_type_text_html,
* h3zero_content_type_text_plain,
* h3zero_content_type_image_gif,
* h3zero_content_type_image_jpeg,
* h3zero_content_type_image_png,
* h3zero_content_type_dns_message,
* h3zero_content_type_javascript,
* h3zero_content_type_json,
* h3zero_content_type_www_form_urlencoded,
* h3zero_content_type_text_css
*/
if (strcmp(ext, "html") == 0 || strcmp(ext, "htm") == 0) {
return h3zero_content_type_text_html;
} else if (strcmp(ext, "gif") == 0) {
return h3zero_content_type_image_gif;
} else if (strcmp(ext, "jpg") == 0 || strcmp(ext, "jpeg") == 0) {
return h3zero_content_type_image_jpeg;
} else if (strcmp(ext, "png") == 0) {
return h3zero_content_type_image_png;
} else if (strcmp(ext, "js") == 0) {
return h3zero_content_type_javascript;
} else if (strcmp(ext, "json") == 0) {
return h3zero_content_type_json;
} else if (strcmp(ext, "css") == 0) {
return h3zero_content_type_text_css;
}
}
}

/* PATH == NULL OR dot not found OR unknown extension. */
return h3zero_content_type_text_plain;
}

/* Processing of the request frame.
* This function is called after the client's stream is closed,
Expand Down Expand Up @@ -953,7 +1001,10 @@ int h3zero_process_request_frame(
strlen(h3zero_server_default_page) : stream_ctx->echo_length;
o_bytes = h3zero_create_response_header_frame(o_bytes, o_bytes_max,
(stream_ctx->echo_length == 0) ? h3zero_content_type_text_html :
h3zero_content_type_text_plain);
h3zero_get_content_type_by_path(stream_ctx->file_path));
/* TODO handle query string
* Currently picoquic doesn't support query strings.
*/
}
}
else if (stream_ctx->ps.stream_state.header.method == h3zero_method_post) {
Expand Down
2 changes: 2 additions & 0 deletions picohttp/h3zero_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,8 @@ extern "C" {

void h3zero_forget_stream(picoquic_cnx_t* cnx, h3zero_stream_ctx_t* stream_ctx);

h3zero_content_type_enum h3zero_get_content_type_by_path(const char *path);

int h3zero_set_datagram_ready(picoquic_cnx_t* cnx, uint64_t stream_id);
uint8_t* h3zero_provide_datagram_buffer(void* context, size_t length, int ready_to_send);

Expand Down
1 change: 1 addition & 0 deletions picohttp_t/picohttp_t.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ static const picoquic_test_def_t test_table[] = {
{ "h09_multi_file_loss", h09_multi_file_loss_test },
{ "h09_multi_file_preemptive", h09_multi_file_preemptive_test },
{ "h3zero_settings", h3zero_settings_test },
{ "h3zero_get_content_type_by_path", h3zero_get_content_type_by_path_test },
{ "http_stress", http_stress_test },
{ "http_corrupt", http_corrupt_test},
{ "http_corrupt_rdpn", http_corrupt_rdpn_test},
Expand Down
29 changes: 19 additions & 10 deletions picoquic/bbr.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@ typedef struct st_picoquic_bbr_state_t {

/* probe BW parameters */
unsigned int probe_probe_bw_quickly : 1;
uint32_t rounds_since_bw_probe;
uint64_t bw_probe_wait;
uint64_t bw_probe_ceiling; /* If bandwidth grows more than ceiling in probe_bw states, redo startup */
uint64_t cycle_stamp;
uint32_t rounds_since_bw_probe;
uint32_t bw_probe_up_cnt;
uint32_t bw_probe_up_rounds;
uint32_t bw_probe_samples;
Expand Down Expand Up @@ -308,10 +308,11 @@ static void BBREnterDrain(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path
#if 0
static void BBRHandleRestartFromIdle(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time);
#endif
static void BBREnterProbeBW(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time);
static void BBRStartProbeBW_DOWN(picoquic_bbr_state_t* bbr_state, picoquic_path_t * path_x, uint64_t current_time);
static void BBRStartProbeBW_CRUISE(picoquic_bbr_state_t* bbr_state);
static void BBRStartProbeBW_REFILL(picoquic_bbr_state_t* bbr_state, picoquic_path_t * path_x);
static void BBREnterStartup(picoquic_bbr_state_t* bbr_state);
static void BBREnterStartup(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x);
static void BBRReEnterStartup(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time);
static void BBRCheckStartupHighLoss(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, bbr_per_ack_state_t* rs);
static void BBRUpdateRound(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x);
Expand Down Expand Up @@ -443,7 +444,7 @@ static void BBROnInit(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x,
BBRInitRoundCounting(bbr_state, path_x);
BBRInitFullPipe(bbr_state);
BBRInitPacingRate(bbr_state, path_x);
BBREnterStartup(bbr_state);
BBREnterStartup(bbr_state, path_x);
}

static void picoquic_bbr_reset(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time)
Expand Down Expand Up @@ -1288,7 +1289,7 @@ static void BBRExitProbeRTT(picoquic_bbr_state_t* bbr_state, picoquic_path_t * p
BBRStartProbeBW_CRUISE(bbr_state);
}
else {
BBREnterStartup(bbr_state);
BBREnterStartup(bbr_state, path_x);
}
}

Expand Down Expand Up @@ -1335,19 +1336,20 @@ static void BBRHandleProbeRTT(picoquic_bbr_state_t* bbr_state, picoquic_path_t *
}
}

static void BBREnterProbeRTT(picoquic_bbr_state_t* bbr_state)
static void BBREnterProbeRTT(picoquic_bbr_state_t* bbr_state, picoquic_path_t * path_x)
{
bbr_state->state = picoquic_bbr_alg_probe_rtt;
bbr_state->pacing_gain = 1.0;
bbr_state->cwnd_gain = BBRProbeRTTCwndGain; /* 0.5 */
path_x->is_cca_probing_up = 0;
}

static void BBRCheckProbeRTT(picoquic_bbr_state_t* bbr_state, picoquic_path_t * path_x, bbr_per_ack_state_t * rs, uint64_t current_time)
{
if (bbr_state->state != picoquic_bbr_alg_probe_rtt &&
bbr_state->probe_rtt_expired &&
!bbr_state->idle_restart) {
BBREnterProbeRTT(bbr_state);
BBREnterProbeRTT(bbr_state, path_x);
bbr_state->min_rtt = rs->rtt_sample;
bbr_state->prior_cwnd = BBRSaveCwnd(bbr_state, path_x);
bbr_state->probe_rtt_done_stamp = 0;
Expand Down Expand Up @@ -1611,6 +1613,7 @@ static void BBRStartProbeBW_DOWN(picoquic_bbr_state_t* bbr_state, picoquic_path_
BBRStartRound(bbr_state, path_x);
bbr_state->state = picoquic_bbr_alg_probe_bw_down;
bbr_state->nb_rtt_excess = 0;
path_x->is_cca_probing_up = 0;
}

static void BBRStartProbeBW_CRUISE(picoquic_bbr_state_t* bbr_state)
Expand All @@ -1631,6 +1634,7 @@ static void BBRStartProbeBW_REFILL(picoquic_bbr_state_t* bbr_state, picoquic_pat
bbr_state->ack_phase = picoquic_bbr_acks_refilling;
BBRStartRound(bbr_state, path_x);
bbr_state->state = picoquic_bbr_alg_probe_bw_refill;
path_x->is_cca_probing_up = 1;
}

static void BBRStartProbeBW_UP(picoquic_bbr_state_t* bbr_state, picoquic_path_t * path_x, uint64_t current_time)
Expand All @@ -1643,6 +1647,7 @@ static void BBRStartProbeBW_UP(picoquic_bbr_state_t* bbr_state, picoquic_path_t
bbr_state->cycle_stamp = current_time; /* start wall clock */
bbr_state->state = picoquic_bbr_alg_probe_bw_up;
BBRRaiseInflightHiSlope(bbr_state, path_x);
path_x->is_cca_probing_up = 1;
}

/* The core state machine logic for ProbeBW: */
Expand Down Expand Up @@ -1732,6 +1737,8 @@ static void BBREnterDrain(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path
bbr_state->state = picoquic_bbr_alg_drain;
bbr_state->pacing_gain = 1.0 / BBRStartupCwndGain; /* pace slowly */
bbr_state->cwnd_gain = BBRStartupCwndGain; /* maintain cwnd */

path_x->is_cca_probing_up = 0;
}

static void BBRCheckDrain(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time)
Expand Down Expand Up @@ -1778,7 +1785,7 @@ static void BBRCheckStartupResume(picoquic_bbr_state_t* bbr_state, picoquic_path
if (bbr_state->state == picoquic_bbr_alg_startup_resume) {
BBRCheckStartupHighLoss(bbr_state, path_x, rs);
if (!bbr_state->filled_pipe && (double)bbr_state->max_bw > BBRStartupResumeIncreaseThreshold * bbr_state->bdp_seed) {
BBREnterStartup(bbr_state);
BBREnterStartup(bbr_state, path_x);
}
else {
BBRCheckStartupFullBandwidthGeneric(bbr_state, rs, BBRStartupResumeIncreaseThreshold);
Expand Down Expand Up @@ -1828,7 +1835,7 @@ static void BBRCheckStartupFullBandwidth(picoquic_bbr_state_t* bbr_state,
}
}
bbr_state->full_bw_count++; /* another round w/o much growth */
if (bbr_state->full_bw_count >= 3 || rs->ecn_frac >= 0.2) {
if (bbr_state->full_bw_count >= 3 || rs->ecn_frac >= BBRExcessiveEcnCE) {
bbr_state->filled_pipe = 1;
}
}
Expand All @@ -1852,11 +1859,12 @@ static void BBRCheckStartupDone(picoquic_bbr_state_t* bbr_state,
}
}

static void BBREnterStartup(picoquic_bbr_state_t* bbr_state)
static void BBREnterStartup(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x)
{
bbr_state->state = picoquic_bbr_alg_startup;
bbr_state->pacing_gain = BBRStartupPacingGain;
bbr_state->cwnd_gain = BBRStartupCwndGain;
path_x->is_cca_probing_up = 1;
}

static void BBRReEnterStartup(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time)
Expand All @@ -1865,7 +1873,7 @@ static void BBRReEnterStartup(picoquic_bbr_state_t* bbr_state, picoquic_path_t*
bbr_state->filled_pipe = 0;
bbr_state->full_bw_count = 0;
bbr_state->probe_probe_bw_quickly = 1;
BBREnterStartup(bbr_state);
BBREnterStartup(bbr_state, path_x);
}

/* End of BBRv3 startup specific */
Expand All @@ -1890,6 +1898,7 @@ void BBREnterStartupLongRTT(picoquic_bbr_state_t* bbr_state, picoquic_path_t* pa
if (cwnd > path_x->cwin) {
path_x->cwin = cwnd;
}
path_x->is_cca_probing_up = 1;
}

static void BBRExitStartupLongRtt(picoquic_bbr_state_t* bbr_state, picoquic_path_t* path_x, uint64_t current_time)
Expand Down
Loading

0 comments on commit dcf1c60

Please sign in to comment.