Skip to content

Commit ec45231

Browse files
committed
Make addition of CC algorithms modular
1 parent d2a4f98 commit ec45231

39 files changed

+435
-37
lines changed

CMakeLists.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ set(PICOQUIC_LIBRARY_FILES
102102
picoquic/port_blocking.c
103103
picoquic/prague.c
104104
picoquic/quicctx.c
105+
picoquic/register_all_cc_algorithms.c
105106
picoquic/sacks.c
106107
picoquic/sender.c
107108
picoquic/sim_link.c
@@ -126,6 +127,12 @@ set(PICOQUIC_CORE_HEADERS
126127
picoquic/picoquic_binlog.h
127128
picoquic/picoquic_config.h
128129
picoquic/picoquic_lb.h
130+
picoquic/picoquic_newreno.h
131+
picoquic/picoquic_cubic.h
132+
picoquic/picquic_bbr.h
133+
picoquic/picquic_bbr1.h
134+
picoquic/picquic_fastcc.h
135+
picoquic/picquic_prague.h
129136
picoquic/siphash.h)
130137

131138
set(LOGLIB_LIBRARY_FILES

picoquic/config.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "picoquic_unified_log.h"
3535
#include "tls_api.h"
3636
#include "picoquic_config.h"
37+
#include "picoquic_bbr.h"
3738

3839
typedef struct st_option_param_t {
3940
char const * param;
@@ -64,7 +65,7 @@ static option_table_line_t option_table[] = {
6465
{ picoquic_option_DisablePortBlocking, 'X', "disable_block", 0, "", "Disable the check for blocked ports"},
6566
{ picoquic_option_SOLUTION_DIR, 'S', "solution_dir", 1, "folder", "Set the path to the source files to find the default files" },
6667
{ picoquic_option_CC_ALGO, 'G', "cc_algo", 1, "cc_algorithm",
67-
"Use the specified congestion control algorithm: reno, cubic, bbr or fast. Defaults to bbr." },
68+
"Use the specified congestion control algorithm. Defaults to bbr. Supported values are:" },
6869
{ picoquic_option_SPINBIT, 'P', "spinbit", 1, "number", "Set the default spinbit policy" },
6970
{ picoquic_option_LOSSBIT, 'O', "lossbit", 1, "number", "Set the default lossbit policy" },
7071
{ picoquic_option_MULTIPATH, 'M', "multipath", 0, "", "Enable QUIC multipath extension" },
@@ -482,6 +483,22 @@ void picoquic_config_usage_file(FILE* F)
482483
putc(' ', F);
483484
}
484485
fprintf(F, " %s\n", option_table[i].option_help);
486+
if (option_table[i].option_num == picoquic_option_CC_ALGO){
487+
if (picoquic_congestion_control_algorithms != NULL &&
488+
picoquic_nb_congestion_control_algorithms > 0) {
489+
/* Add a line with supported values. */
490+
for (size_t j = 0; j < 18; j++) {
491+
putc(' ', F);
492+
}
493+
for (size_t k = 0; k < picoquic_nb_congestion_control_algorithms; k++) {
494+
if (k != 0) {
495+
fprintf(F, ", ");
496+
}
497+
fprintf(F, "%s", picoquic_congestion_control_algorithms[k]->congestion_algorithm_id);
498+
}
499+
fprintf(F, ".\n");
500+
}
501+
}
485502
}
486503
}
487504

picoquic/picoquic.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1565,17 +1565,28 @@ typedef struct st_picoquic_congestion_algorithm_t {
15651565
picoquic_congestion_algorithm_observe alg_observe;
15661566
} picoquic_congestion_algorithm_t;
15671567

1568+
#if 1
1569+
#else
15681570
extern picoquic_congestion_algorithm_t* picoquic_newreno_algorithm;
15691571
extern picoquic_congestion_algorithm_t* picoquic_cubic_algorithm;
15701572
extern picoquic_congestion_algorithm_t* picoquic_dcubic_algorithm;
15711573
extern picoquic_congestion_algorithm_t* picoquic_fastcc_algorithm;
15721574
extern picoquic_congestion_algorithm_t* picoquic_bbr_algorithm;
15731575
extern picoquic_congestion_algorithm_t* picoquic_prague_algorithm;
15741576
extern picoquic_congestion_algorithm_t* picoquic_bbr1_algorithm;
1577+
#endif
15751578

15761579
#define PICOQUIC_DEFAULT_CONGESTION_ALGORITHM picoquic_newreno_algorithm;
15771580

1578-
picoquic_congestion_algorithm_t const* picoquic_get_congestion_algorithm(char const* alg_name);
1581+
1582+
extern picoquic_congestion_algorithm_t const** picoquic_congestion_control_algorithms;
1583+
extern size_t picoquic_nb_congestion_control_algorithms;
1584+
/* Register a custom table of congestion control algorithms */
1585+
void picoquic_register_congestion_control_algorithms(picoquic_congestion_algorithm_t const** alg, size_t nb_algorithms);
1586+
/* Register a full list of congestion control algorithms */
1587+
void picoquic_register_all_congestion_control_algorithms();
1588+
1589+
picoquic_congestion_algorithm_t const* picoquic_get_congestion_algorithm(char const* alg_id);
15791590

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

picoquic/picoquic.vcxproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,7 @@
171171
<ClCompile Include="quicctx.c" />
172172
<ClCompile Include="packet.c" />
173173
<ClCompile Include="picohash.c" />
174+
<ClCompile Include="register_all_cc_algorithms.c" />
174175
<ClCompile Include="sacks.c" />
175176
<ClCompile Include="sender.c" />
176177
<ClCompile Include="bbr.c" />

picoquic/picoquic.vcxproj.filters

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,9 @@
141141
<ClCompile Include="siphash.c">
142142
<Filter>Source Files</Filter>
143143
</ClCompile>
144+
<ClCompile Include="register_all_cc_algorithms.c">
145+
<Filter>Source Files</Filter>
146+
</ClCompile>
144147
</ItemGroup>
145148
<ItemGroup>
146149
<ClInclude Include="picoquic.h">

picoquic/picoquic_bbr.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Author: Christian Huitema
3+
* Copyright (c) 2025, Private Octopus, Inc.
4+
* All rights reserved.
5+
*
6+
* Permission to use, copy, modify, and distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13+
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
14+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
16+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20+
*/
21+
22+
#ifndef PICOQUIC_BBR_H
23+
#define PICOQUIC_BBR_H
24+
25+
#include "picoquic.h"
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
extern picoquic_congestion_algorithm_t* picoquic_bbr_algorithm;
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
#endif

picoquic/picoquic_bbr1.h

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/*
2+
* Author: Christian Huitema
3+
* Copyright (c) 2025, Private Octopus, Inc.
4+
* All rights reserved.
5+
*
6+
* Permission to use, copy, modify, and distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13+
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
14+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
16+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20+
*/
21+
22+
#ifndef PICOQUIC_BBR1_H
23+
#define PICOQUIC_BBR1_H
24+
25+
#include "picoquic.h"
26+
27+
extern picoquic_congestion_algorithm_t* picoquic_bbr1_algorithm;
28+
29+
#endif

picoquic/picoquic_cubic.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Author: Christian Huitema
3+
* Copyright (c) 2025, Private Octopus, Inc.
4+
* All rights reserved.
5+
*
6+
* Permission to use, copy, modify, and distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13+
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
14+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
16+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20+
*/
21+
22+
#ifndef PICOQUIC_CUBIC_H
23+
#define PICOQUIC_CUBIC_H
24+
25+
#include "picoquic.h"
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
extern picoquic_congestion_algorithm_t* picoquic_cubic_algorithm;
32+
extern picoquic_congestion_algorithm_t* picoquic_dcubic_algorithm;
33+
34+
#ifdef __cplusplus
35+
}
36+
#endif
37+
#endif

picoquic/picoquic_fastcc.h

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/*
2+
* Author: Christian Huitema
3+
* Copyright (c) 2017, Private Octopus, Inc.
4+
* All rights reserved.
5+
*
6+
* Permission to use, copy, modify, and distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13+
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
14+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
16+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20+
*/
21+
22+
#ifndef PICOQUIC_FASTCC_H
23+
#define PICOQUIC_FASTCC_H
24+
25+
#include "picoquic.h"
26+
27+
28+
extern picoquic_congestion_algorithm_t* picoquic_fastcc_algorithm;
29+
30+
#endif

picoquic/picoquic_newreno.h

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Author: Christian Huitema
3+
* Copyright (c) 2025, Private Octopus, Inc.
4+
* All rights reserved.
5+
*
6+
* Permission to use, copy, modify, and distribute this software for any
7+
* purpose with or without fee is hereby granted, provided that the above
8+
* copyright notice and this permission notice appear in all copies.
9+
*
10+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
11+
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
12+
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
13+
* DISCLAIMED. IN NO EVENT SHALL Private Octopus, Inc. BE LIABLE FOR ANY
14+
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
15+
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
16+
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
17+
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
18+
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
19+
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
20+
*/
21+
22+
#ifndef PICOQUIC_NEWRENO_H
23+
#define PICOQUIC_NEWRENO_H
24+
25+
#include "picoquic.h"
26+
27+
#ifdef __cplusplus
28+
extern "C" {
29+
#endif
30+
31+
extern picoquic_congestion_algorithm_t* picoquic_newreno_algorithm;
32+
33+
#ifdef __cplusplus
34+
}
35+
#endif
36+
#endif

0 commit comments

Comments
 (0)