Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
7 changes: 7 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ set(PICOQUIC_LIBRARY_FILES
picoquic/port_blocking.c
picoquic/prague.c
picoquic/quicctx.c
picoquic/register_all_cc_algorithms.c
picoquic/sacks.c
picoquic/sender.c
picoquic/sim_link.c
Expand All @@ -126,6 +127,12 @@ set(PICOQUIC_CORE_HEADERS
picoquic/picoquic_binlog.h
picoquic/picoquic_config.h
picoquic/picoquic_lb.h
picoquic/picoquic_newreno.h
picoquic/picoquic_cubic.h
picoquic/picoquic_bbr.h
picoquic/picoquic_bbr1.h
picoquic/picoquic_fastcc.h
picoquic/picoquic_prague.h
picoquic/siphash.h)

set(LOGLIB_LIBRARY_FILES
Expand Down
19 changes: 18 additions & 1 deletion picoquic/config.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "picoquic_unified_log.h"
#include "tls_api.h"
#include "picoquic_config.h"
#include "picoquic_bbr.h"

typedef struct st_option_param_t {
char const * param;
Expand Down Expand Up @@ -64,7 +65,7 @@ static option_table_line_t option_table[] = {
{ picoquic_option_DisablePortBlocking, 'X', "disable_block", 0, "", "Disable the check for blocked ports"},
{ picoquic_option_SOLUTION_DIR, 'S', "solution_dir", 1, "folder", "Set the path to the source files to find the default files" },
{ picoquic_option_CC_ALGO, 'G', "cc_algo", 1, "cc_algorithm",
"Use the specified congestion control algorithm: reno, cubic, bbr or fast. Defaults to bbr." },
"Use the specified congestion control algorithm. Defaults to bbr. Supported values are:" },
{ picoquic_option_SPINBIT, 'P', "spinbit", 1, "number", "Set the default spinbit policy" },
{ picoquic_option_LOSSBIT, 'O', "lossbit", 1, "number", "Set the default lossbit policy" },
{ picoquic_option_MULTIPATH, 'M', "multipath", 0, "", "Enable QUIC multipath extension" },
Expand Down Expand Up @@ -482,6 +483,22 @@ void picoquic_config_usage_file(FILE* F)
putc(' ', F);
}
fprintf(F, " %s\n", option_table[i].option_help);
if (option_table[i].option_num == picoquic_option_CC_ALGO){
if (picoquic_congestion_control_algorithms != NULL &&
picoquic_nb_congestion_control_algorithms > 0) {
/* Add a line with supported values. */
for (size_t j = 0; j < 18; j++) {
putc(' ', F);
}
for (size_t k = 0; k < picoquic_nb_congestion_control_algorithms; k++) {
if (k != 0) {
fprintf(F, ", ");
}
fprintf(F, "%s", picoquic_congestion_control_algorithms[k]->congestion_algorithm_id);
}
fprintf(F, ".\n");
}
}
}
}

Expand Down
13 changes: 12 additions & 1 deletion picoquic/picoquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -1565,17 +1565,28 @@ typedef struct st_picoquic_congestion_algorithm_t {
picoquic_congestion_algorithm_observe alg_observe;
} picoquic_congestion_algorithm_t;

#if 1
#else
extern picoquic_congestion_algorithm_t* picoquic_newreno_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_cubic_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_dcubic_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_fastcc_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_bbr_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_prague_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_bbr1_algorithm;
#endif

#define PICOQUIC_DEFAULT_CONGESTION_ALGORITHM picoquic_newreno_algorithm;

picoquic_congestion_algorithm_t const* picoquic_get_congestion_algorithm(char const* alg_name);

extern picoquic_congestion_algorithm_t const** picoquic_congestion_control_algorithms;
extern size_t picoquic_nb_congestion_control_algorithms;
/* Register a custom table of congestion control algorithms */
void picoquic_register_congestion_control_algorithms(picoquic_congestion_algorithm_t const** alg, size_t nb_algorithms);
/* Register a full list of congestion control algorithms */
void picoquic_register_all_congestion_control_algorithms();

picoquic_congestion_algorithm_t const* picoquic_get_congestion_algorithm(char const* alg_id);

void picoquic_set_default_congestion_algorithm(picoquic_quic_t* quic, picoquic_congestion_algorithm_t const* algo);

Expand Down
1 change: 1 addition & 0 deletions picoquic/picoquic.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
<ClCompile Include="quicctx.c" />
<ClCompile Include="packet.c" />
<ClCompile Include="picohash.c" />
<ClCompile Include="register_all_cc_algorithms.c" />
<ClCompile Include="sacks.c" />
<ClCompile Include="sender.c" />
<ClCompile Include="bbr.c" />
Expand Down
3 changes: 3 additions & 0 deletions picoquic/picoquic.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@
<ClCompile Include="siphash.c">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="register_all_cc_algorithms.c">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="picoquic.h">
Expand Down
36 changes: 36 additions & 0 deletions picoquic/picoquic_bbr.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Author: Christian Huitema
* Copyright (c) 2025, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PICOQUIC_BBR_H
#define PICOQUIC_BBR_H

#include "picoquic.h"

#ifdef __cplusplus
extern "C" {
#endif

extern picoquic_congestion_algorithm_t* picoquic_bbr_algorithm;

#ifdef __cplusplus
}
#endif
#endif
29 changes: 29 additions & 0 deletions picoquic/picoquic_bbr1.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Author: Christian Huitema
* Copyright (c) 2025, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PICOQUIC_BBR1_H
#define PICOQUIC_BBR1_H

#include "picoquic.h"

extern picoquic_congestion_algorithm_t* picoquic_bbr1_algorithm;

#endif
37 changes: 37 additions & 0 deletions picoquic/picoquic_cubic.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Author: Christian Huitema
* Copyright (c) 2025, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PICOQUIC_CUBIC_H
#define PICOQUIC_CUBIC_H

#include "picoquic.h"

#ifdef __cplusplus
extern "C" {
#endif

extern picoquic_congestion_algorithm_t* picoquic_cubic_algorithm;
extern picoquic_congestion_algorithm_t* picoquic_dcubic_algorithm;

#ifdef __cplusplus
}
#endif
#endif
30 changes: 30 additions & 0 deletions picoquic/picoquic_fastcc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Author: Christian Huitema
* Copyright (c) 2017, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PICOQUIC_FASTCC_H
#define PICOQUIC_FASTCC_H

#include "picoquic.h"


extern picoquic_congestion_algorithm_t* picoquic_fastcc_algorithm;

#endif
36 changes: 36 additions & 0 deletions picoquic/picoquic_newreno.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Author: Christian Huitema
* Copyright (c) 2025, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PICOQUIC_NEWRENO_H
#define PICOQUIC_NEWRENO_H

#include "picoquic.h"

#ifdef __cplusplus
extern "C" {
#endif

extern picoquic_congestion_algorithm_t* picoquic_newreno_algorithm;

#ifdef __cplusplus
}
#endif
#endif
36 changes: 36 additions & 0 deletions picoquic/picoquic_prague.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* Author: Christian Huitema
* Copyright (c) 2025, Private Octopus, Inc.
* All rights reserved.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/

#ifndef PICOQUIC_PRAGUE_H
#define PICOQUIC_PRAGUE_H

#include "picoquic.h"

#ifdef __cplusplus
extern "C" {
#endif

extern picoquic_congestion_algorithm_t* picoquic_prague_algorithm;

#ifdef __cplusplus
}
#endif
#endif
55 changes: 27 additions & 28 deletions picoquic/quicctx.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <time.h>
#include <errno.h>
#endif

#include "picoquic_newreno.h"

/*
* Supported versions. Specific versions may mandate different processing of different
Expand Down Expand Up @@ -4909,42 +4909,41 @@ picoquic_cnx_t* picoquic_cnx_by_secret(picoquic_quic_t* quic, const uint8_t* res
return ret;
}

/* Get congestion control algorithm by name
* TODO: if we want to minimize code size, we should not require linking a whole library
* of congestion control algorithms. Intead, the application should have a list of
* configured algorithms, and the configuration program should select from that list.
/* Management of congestion control algorithms
* We want to minimize code size, and thus we do not want to require loading the
* entire list of congestion control algorithms in every executable.
* Instead, we require applications to provide a list of the congestion
* control algorithms that they support.
*/

picoquic_congestion_algorithm_t const** picoquic_congestion_control_algorithms = NULL;
size_t picoquic_nb_congestion_control_algorithms = 0;

/* Register a list of congestion control algorithm */
void picoquic_register_congestion_control_algorithms(picoquic_congestion_algorithm_t const** alg, size_t nb_algorithms)
{
picoquic_congestion_control_algorithms = alg;
picoquic_nb_congestion_control_algorithms = nb_algorithms;
}

picoquic_congestion_algorithm_t const* picoquic_get_congestion_algorithm(char const* alg_name)
{
picoquic_congestion_algorithm_t const* alg = NULL;
if (alg_name != NULL) {
if (strcmp(alg_name, "reno") == 0) {
alg = picoquic_newreno_algorithm;
}
else if (strcmp(alg_name, "cubic") == 0) {
alg = picoquic_cubic_algorithm;
}
else if (strcmp(alg_name, "dcubic") == 0) {
alg = picoquic_dcubic_algorithm;
}
else if (strcmp(alg_name, "fast") == 0) {
alg = picoquic_fastcc_algorithm;
}
else if (strcmp(alg_name, "bbr") == 0) {
alg = picoquic_bbr_algorithm;
}
else if (strcmp(alg_name, "prague") == 0) {
alg = picoquic_prague_algorithm;
}
else if (strcmp(alg_name, "bbr1") == 0) {
alg = picoquic_bbr1_algorithm;

if (alg_name != NULL && picoquic_congestion_control_algorithms != NULL) {
for (size_t i = 0; i < picoquic_nb_congestion_control_algorithms; i++) {
if (strcmp(alg_name, picoquic_congestion_control_algorithms[i]->congestion_algorithm_id) == 0) {
alg = picoquic_congestion_control_algorithms[i];
break;
}
}
else {
alg = NULL;
if (alg == NULL && strcmp(alg_name, "reno") == 0) {
alg = picoquic_get_congestion_algorithm("newreno");
}
}
return alg;
}

/*
* Set or reset the congestion control algorithm
*/
Expand Down
Loading
Loading