Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for choosing congestion control alg #305

Merged
merged 3 commits into from
Oct 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions c_src/quicer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,8 @@ encode_parm_to_eterm(ErlNifEnv *env,
Settings->DisconnectTimeoutMs),
PropTupleAtomInt(ATOM_QUIC_SETTINGS_KeepAliveIntervalMs,
Settings->KeepAliveIntervalMs),
PropTupleAtomInt(ATOM_QUIC_SETTINGS_CongestionControlAlgorithm,
Settings->CongestionControlAlgorithm),
PropTupleAtomInt(ATOM_QUIC_SETTINGS_PeerBidiStreamCount,
Settings->PeerBidiStreamCount),
PropTupleAtomInt(ATOM_QUIC_SETTINGS_PeerUnidiStreamCount,
Expand Down Expand Up @@ -1160,6 +1162,14 @@ create_settings(ErlNifEnv *env,
{
Settings->IsSet.KeepAliveIntervalMs = TRUE;
}
if (get_uint16_from_map(env,
*emap,
ATOM_QUIC_SETTINGS_CongestionControlAlgorithm,
&Settings->CongestionControlAlgorithm))
{
Settings->IsSet.CongestionControlAlgorithm = TRUE;
}

if (get_uint16_from_map(env,
*emap,
ATOM_QUIC_SETTINGS_PeerBidiStreamCount,
Expand Down
1 change: 1 addition & 0 deletions c_src/quicer_eterms.h
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_InitialRttMs;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_MaxAckDelayMs;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_DisconnectTimeoutMs;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_KeepAliveIntervalMs;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_CongestionControlAlgorithm;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_PeerBidiStreamCount;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_PeerUnidiStreamCount;
extern ERL_NIF_TERM ATOM_QUIC_SETTINGS_RetryMemoryLimit;
Expand Down
3 changes: 3 additions & 0 deletions c_src/quicer_nif.c
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ ERL_NIF_TERM ATOM_QUIC_SETTINGS_InitialRttMs;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_MaxAckDelayMs;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_DisconnectTimeoutMs;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_KeepAliveIntervalMs;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_CongestionControlAlgorithm;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_PeerBidiStreamCount;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_PeerUnidiStreamCount;
ERL_NIF_TERM ATOM_QUIC_SETTINGS_RetryMemoryLimit;
Expand Down Expand Up @@ -687,6 +688,8 @@ ERL_NIF_TERM ATOM_QUIC_SEND_ECN_CONGESTION_COUNT;
ATOM(ATOM_QUIC_SETTINGS_MaxAckDelayMs, max_ack_delay_ms); \
ATOM(ATOM_QUIC_SETTINGS_DisconnectTimeoutMs, disconnect_timeout_ms); \
ATOM(ATOM_QUIC_SETTINGS_KeepAliveIntervalMs, keep_alive_interval_ms); \
ATOM(ATOM_QUIC_SETTINGS_CongestionControlAlgorithm, \
congestion_control_algorithm); \
ATOM(ATOM_QUIC_SETTINGS_PeerBidiStreamCount, peer_bidi_stream_count); \
ATOM(ATOM_QUIC_SETTINGS_PeerUnidiStreamCount, peer_unidi_stream_count); \
ATOM(ATOM_QUIC_SETTINGS_RetryMemoryLimit, retry_memory_limit); \
Expand Down
3 changes: 3 additions & 0 deletions include/quicer.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -146,4 +146,7 @@
-define(QUIC_LOAD_BALANCING_COUNT, 3).
-define(QUICER_LOAD_BALANCING_IFIP_AS_SERVER_ID, 100). %% User Network Interface IP as Server ID

-define(QUIC_CONGESTION_CONTROL_ALGORITHM_CUBIC, 0).
-define(QUIC_CONGESTION_CONTROL_ALGORITHM_BBR, 1).

-endif. %% QUICER_HRL
1 change: 1 addition & 0 deletions include/quicer_types.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
max_ack_delay_ms => uint32(),
disconnect_timeout_ms => uint32(),
keep_alive_interval_ms => uint32(),
congestion_control_algorithm => uint16(),
peer_bidi_stream_count => uint16(),
peer_unidi_stream_count => uint16(),
retry_memory_limit => uint16(),
Expand Down
1 change: 1 addition & 0 deletions test/prop_quic_types.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@
| {max_ack_delay_ms, uint32()}
| {disconnect_timeout_ms, uint32()}
| {keep_alive_interval_ms, uint32()}
| {congestion_control_algorithm, uint16()}
| {peer_bidi_stream_count, uint16()}
| {peer_unidi_stream_count, uint16()}
| {retry_memory_limit, uint16()}
Expand Down
47 changes: 39 additions & 8 deletions test/quicer_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
tc_setopt/1,
tc_setopt_remote_addr/1,
tc_getopt_settings/1,
tc_setopt_congestion_control_algorithm/1,

%% @TODO following two tcs are failing due to:
% https://github.com/microsoft/msquic/issues/2033
Expand Down Expand Up @@ -2552,10 +2553,7 @@ tc_event_start_compl_client(Config) ->
{ok, Conn} = quicer:connect(
"localhost",
Port,
[
{disable_1rtt_encryption, true}
| default_conn_opts()
],
default_conn_opts(),
5000
),
%% Stream 1 enabled
Expand Down Expand Up @@ -2615,10 +2613,7 @@ tc_event_start_compl_server(Config) ->
{ok, Conn} = quicer:connect(
"localhost",
Port,
[
{disable_1rtt_encryption, true}
| default_conn_opts()
],
default_conn_opts(),
5000
),
%% Stream 1 enabled
Expand Down Expand Up @@ -3162,6 +3157,42 @@ tc_setopt_global_lb_mode_ifip(_Config) ->
quicer:getopt(quic_global, load_balacing_mode)
).

tc_setopt_congestion_control_algorithm(Config) ->
Port = select_port(),
Owner = self(),
{SPid, _Ref} = spawn_monitor(
fun() ->
echo_server(Owner, Config, Port)
end
),
receive
listener_ready ->
ok
after 5000 ->
ct:fail("listener_timeout")
end,
{ok, Conn} = quicer:connect(
"localhost",
Port,
[
{congestion_control_algorithm, ?QUIC_CONGESTION_CONTROL_ALGORITHM_BBR}
| default_conn_opts()
],
5000
),
{ok, Stm} = quicer:start_stream(Conn, []),
{ok, 4} = quicer:send(Stm, <<"ping">>),

{ok, Settings} = quicer:getopt(Conn, settings),
?assertMatch(
?QUIC_CONGESTION_CONTROL_ALGORITHM_BBR,
proplists:get_value(congestion_control_algorithm, Settings)
),

quicer:shutdown_connection(Conn),
SPid ! done,
ok.

%%% ====================
%%% Internal helpers
%%% ====================
Expand Down
Loading