Skip to content

Commit

Permalink
[+] add least_available_cid_count for client option
Browse files Browse the repository at this point in the history
  • Loading branch information
Yanmei-Liu committed Nov 5, 2023
1 parent e1695fa commit 0dc125c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 2 deletions.
2 changes: 2 additions & 0 deletions demo/demo_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ typedef struct xqc_demo_cli_quic_config_s {
uint8_t send_path_standby;
xqc_msec_t path_status_timer_threshold;

uint64_t least_available_cid_count;

} xqc_demo_cli_quic_config_t;


Expand Down
10 changes: 9 additions & 1 deletion demo/demo_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ typedef struct xqc_demo_svr_quic_config_s {
uint32_t reinjection;

uint64_t keyupdate_pkt_threshold;
uint64_t least_available_cid_count;
} xqc_demo_svr_quic_config_t;


Expand Down Expand Up @@ -1220,13 +1221,14 @@ xqc_demo_svr_init_args(xqc_demo_svr_args_t *args)
strncpy(args->env_cfg.cert_pem_path, CERT_PEM_PATH, PATH_LEN - 1);

args->quic_cfg.keyupdate_pkt_threshold = UINT64_MAX;
args->quic_cfg.least_available_cid_count = 1;
}

void
xqc_demo_svr_parse_args(int argc, char *argv[], xqc_demo_svr_args_t *args)
{
int ch = 0;
while ((ch = getopt(argc, argv, "p:c:CD:l:L:6k:rdMPs:R:u:")) != -1) {
while ((ch = getopt(argc, argv, "p:c:CD:l:L:6k:rdMPs:R:u:a:")) != -1) {
switch (ch) {
/* listen port */
case 'p':
Expand Down Expand Up @@ -1331,6 +1333,11 @@ xqc_demo_svr_parse_args(int argc, char *argv[], xqc_demo_svr_args_t *args)
args->quic_cfg.keyupdate_pkt_threshold = atoi(optarg);
break;

case 'a': /* key update packet threshold */
printf("least Available cid counts: %s\n", optarg);
args->quic_cfg.least_available_cid_count = atoi(optarg);
break;

default:
printf("other option :%c\n", ch);
xqc_demo_svr_usage(argc, argv);
Expand Down Expand Up @@ -1445,6 +1452,7 @@ xqc_demo_svr_init_conn_settings(xqc_demo_svr_args_t *args)
.mp_enable_reinjection = args->quic_cfg.reinjection,
.standby_path_probe_timeout = 1000,
.keyupdate_pkt_threshold = args->quic_cfg.keyupdate_pkt_threshold,
.least_available_cid_count = args->quic_cfg.least_available_cid_count,
};

xqc_server_set_conn_settings(&conn_settings);
Expand Down
2 changes: 1 addition & 1 deletion include/xquic/xquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1171,7 +1171,7 @@ typedef struct xqc_conn_settings_s {
*/
uint64_t enable_multipath;
xqc_multipath_version_t multipath_version;

uint64_t least_available_cid_count;

/*
* reinjection option:
Expand Down
3 changes: 3 additions & 0 deletions src/transport/xqc_conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -4108,6 +4108,9 @@ xqc_conn_try_add_new_conn_id(xqc_connection_t *conn, uint64_t retire_prior_to)
uint64_t unused_limit = 1;
#else
uint64_t unused_limit = conn->enable_multipath ? 2 : 1;
if (conn->enable_multipath) {
unused_limit = xqc_max(unused_limit, conn->conn_settings.least_available_cid_count);
}
#endif
if (xqc_conn_is_handshake_confirmed(conn)) {
while (active_cid_cnt < conn->remote_settings.active_connection_id_limit
Expand Down

0 comments on commit 0dc125c

Please sign in to comment.