Skip to content

Commit 1a68d04

Browse files
authored
Merge pull request #337 from Tencent/release/v0.15.0
Release/v0.15.0
2 parents 72f31ab + 04bd6b5 commit 1a68d04

15 files changed

+553
-123
lines changed

CHANGELOG.md

+15
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
1111
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
1212

1313

14+
## [v0.15.0] - 2024-07-18
15+
16+
### Added
17+
- Support building for the `aarch64-apple-ios-sim` target
18+
- Support customized connection id generators
19+
- Add `quic_packet_header_info()` to extract cid-related info from quic packets
20+
- Add `quic_conn_path_stats` to get path level stats
21+
- Add configuration for pacing granularity
22+
- Tweak packet number encoding
23+
24+
### Fixed
25+
- Replace the hashlru crate with the lru crate
26+
27+
1428
## [v0.14.0] - 2024-07-11
1529

1630
### Added
@@ -262,6 +276,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
262276
- Provide example clients and servers.
263277

264278

279+
[v0.15.0]: https://github.com/tencent/tquic/compare/v0.14.0...v0.15.0
265280
[v0.14.0]: https://github.com/tencent/tquic/compare/v0.13.0...v0.14.0
266281
[v0.13.0]: https://github.com/tencent/tquic/compare/v0.12.0...v0.13.0
267282
[v0.12.0]: https://github.com/tencent/tquic/compare/v0.11.0...v0.12.0

Cargo.toml

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "tquic"
3-
version = "0.14.0"
3+
version = "0.15.0"
44
edition = "2021"
55
rust-version = "1.70.0"
66
license = "Apache-2.0"
@@ -42,7 +42,7 @@ strum = "0.24"
4242
strum_macros = "0.24"
4343
rand = "0.8.5"
4444
smallvec = { version = "1.10", features = ["serde", "union"] }
45-
hashlru = "0.11"
45+
lru = "0.12"
4646
serde = { version = "1.0.139", features = ["derive"] }
4747
serde_json = { version = "1.0", features = ["preserve_order"] }
4848
serde_derive = "1.0"

cbindgen.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ sys_includes = ["sys/socket.h", "sys/types.h"]
1919
includes = ["openssl/ssl.h", "tquic_def.h"]
2020

2121
[export]
22-
exclude = ["MAX_CID_LEN", "MIN_CLIENT_INITIAL_LEN", "VINT_MAX"]
22+
exclude = ["MIN_CLIENT_INITIAL_LEN", "VINT_MAX"]
2323

2424
[export.rename]
2525
"Config" = "quic_config_t"

include/tquic.h

+169
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@
2222
*/
2323
#define QUIC_VERSION_V1 1
2424

25+
/**
26+
* The Connection ID MUST NOT exceed 20 bytes in QUIC version 1.
27+
* See RFC 9000 Section 17.2
28+
*/
29+
#define MAX_CID_LEN 20
30+
2531
/**
2632
* Available congestion control algorithms.
2733
*/
@@ -224,6 +230,34 @@ typedef struct quic_packet_send_methods_t {
224230

225231
typedef void *quic_packet_send_context_t;
226232

233+
/**
234+
* Connection Id is an identifier used to identify a QUIC connection
235+
* at an endpoint.
236+
*/
237+
typedef struct ConnectionId {
238+
/**
239+
* length of cid
240+
*/
241+
uint8_t len;
242+
/**
243+
* octets of cid
244+
*/
245+
uint8_t data[MAX_CID_LEN];
246+
} ConnectionId;
247+
248+
typedef struct ConnectionIdGeneratorMethods {
249+
/**
250+
* Generate a new CID
251+
*/
252+
struct ConnectionId (*generate)(void *gctx);
253+
/**
254+
* Return the length of a CID
255+
*/
256+
uint8_t (*cid_len)(void *gctx);
257+
} ConnectionIdGeneratorMethods;
258+
259+
typedef void *ConnectionIdGeneratorContext;
260+
227261
/**
228262
* Meta information of an incoming packet.
229263
*/
@@ -241,6 +275,100 @@ typedef struct quic_path_address_t {
241275
socklen_t remote_addr_len;
242276
} quic_path_address_t;
243277

278+
/**
279+
* Statistics about path
280+
*/
281+
typedef struct PathStats {
282+
/**
283+
* The number of QUIC packets received.
284+
*/
285+
uint64_t recv_count;
286+
/**
287+
* The number of received bytes.
288+
*/
289+
uint64_t recv_bytes;
290+
/**
291+
* The number of QUIC packets sent.
292+
*/
293+
uint64_t sent_count;
294+
/**
295+
* The number of sent bytes.
296+
*/
297+
uint64_t sent_bytes;
298+
/**
299+
* The number of QUIC packets lost.
300+
*/
301+
uint64_t lost_count;
302+
/**
303+
* The number of lost bytes.
304+
*/
305+
uint64_t lost_bytes;
306+
/**
307+
* Total number of bytes acked.
308+
*/
309+
uint64_t acked_bytes;
310+
/**
311+
* Total number of packets acked.
312+
*/
313+
uint64_t acked_count;
314+
/**
315+
* Initial congestion window in bytes.
316+
*/
317+
uint64_t init_cwnd;
318+
/**
319+
* Final congestion window in bytes.
320+
*/
321+
uint64_t final_cwnd;
322+
/**
323+
* Maximum congestion window in bytes.
324+
*/
325+
uint64_t max_cwnd;
326+
/**
327+
* Minimum congestion window in bytes.
328+
*/
329+
uint64_t min_cwnd;
330+
/**
331+
* Maximum inflight data in bytes.
332+
*/
333+
uint64_t max_inflight;
334+
/**
335+
* Total loss events.
336+
*/
337+
uint64_t loss_event_count;
338+
/**
339+
* Total congestion window limited events.
340+
*/
341+
uint64_t cwnd_limited_count;
342+
/**
343+
* Total duration of congestion windowlimited events in microseconds.
344+
*/
345+
uint64_t cwnd_limited_duration;
346+
/**
347+
* Minimum roundtrip time in microseconds.
348+
*/
349+
uint64_t min_rtt;
350+
/**
351+
* Maximum roundtrip time in microseconds.
352+
*/
353+
uint64_t max_rtt;
354+
/**
355+
* Smoothed roundtrip time in microseconds.
356+
*/
357+
uint64_t srtt;
358+
/**
359+
* Roundtrip time variation in microseconds.
360+
*/
361+
uint64_t rttvar;
362+
/**
363+
* Whether the congestion controller is in slow start status.
364+
*/
365+
bool in_slow_start;
366+
/**
367+
* Pacing rate estimated by congestion control algorithm.
368+
*/
369+
uint64_t pacing_rate;
370+
} PathStats;
371+
244372
/**
245373
* Statistics about a QUIC connection.
246374
*/
@@ -478,6 +606,18 @@ void quic_config_set_bbr_probe_bw_cwnd_gain(struct quic_config_t *config, double
478606
*/
479607
void quic_config_set_initial_rtt(struct quic_config_t *config, uint64_t v);
480608

609+
/**
610+
* Enable pacing to smooth the flow of packets sent onto the network.
611+
* The default value is true.
612+
*/
613+
void quic_config_enable_pacing(struct quic_config_t *config, bool v);
614+
615+
/**
616+
* Set clock granularity used by the pacer.
617+
* The default value is 10 milliseconds.
618+
*/
619+
void quic_config_set_pacing_granularity(struct quic_config_t *config, uint64_t v);
620+
481621
/**
482622
* Set the linear factor for calculating the probe timeout.
483623
* The endpoint do not backoff the first `v` consecutive probe timeouts.
@@ -581,6 +721,7 @@ void quic_config_set_send_batch_size(struct quic_config_t *config, uint16_t v);
581721

582722
/**
583723
* Set the buffer size for disordered zerortt packets on the server.
724+
* The default value is `1000`. A value of 0 will be treated as default value.
584725
* Applicable to Server only.
585726
*/
586727
void quic_config_set_zerortt_buffer_size(struct quic_config_t *config, uint16_t v);
@@ -707,6 +848,14 @@ struct quic_endpoint_t *quic_endpoint_new(struct quic_config_t *config,
707848
*/
708849
void quic_endpoint_free(struct quic_endpoint_t *endpoint);
709850

851+
/**
852+
* Set the connection id generator for the endpoint.
853+
* By default, the random connection id generator is used.
854+
*/
855+
void quic_endpoint_set_cid_generator(struct quic_endpoint_t *endpoint,
856+
const struct ConnectionIdGeneratorMethods *cid_gen_methods,
857+
ConnectionIdGeneratorContext cid_gen_ctx);
858+
710859
/**
711860
* Create a client connection.
712861
* If success, the output parameter `index` carrys the index of the connection.
@@ -868,6 +1017,15 @@ bool quic_conn_path_iter_next(struct quic_path_address_iter_t *iter, struct quic
8681017
*/
8691018
bool quic_conn_active_path(const struct quic_conn_t *conn, struct quic_path_address_t *a);
8701019

1020+
/**
1021+
* Return the latest statistics about the specified path.
1022+
*/
1023+
const struct PathStats *quic_conn_path_stats(struct quic_conn_t *conn,
1024+
const struct sockaddr *local,
1025+
socklen_t local_len,
1026+
const struct sockaddr *remote,
1027+
socklen_t remote_len);
1028+
8711029
/**
8721030
* Return statistics about the connection.
8731031
*/
@@ -1069,6 +1227,17 @@ int quic_stream_set_context(struct quic_conn_t *conn, uint64_t stream_id, void *
10691227
*/
10701228
void *quic_stream_context(struct quic_conn_t *conn, uint64_t stream_id);
10711229

1230+
/**
1231+
* Extract the header form, version and destination connection id from the
1232+
* QUIC packet.
1233+
*/
1234+
int quic_packet_header_info(uint8_t *buf,
1235+
size_t buf_len,
1236+
uint8_t dcid_len,
1237+
bool *long_header,
1238+
uint32_t *version,
1239+
struct ConnectionId *dcid);
1240+
10721241
/**
10731242
* Create default config for HTTP3.
10741243
*/

src/build.rs

+27-11
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,43 @@ const CMAKE_PARAMS_ANDROID_NDK: &[(&str, &[(&str, &str)])] = &[
2323
/// Additional parameters for iOS
2424
const CMAKE_PARAMS_IOS: &[(&str, &[(&str, &str)])] = &[
2525
(
26-
"aarch64",
26+
"aarch64-apple-ios",
2727
&[
2828
("CMAKE_OSX_ARCHITECTURES", "arm64"),
2929
("CMAKE_OSX_SYSROOT", "iphoneos"),
30+
("CMAKE_ASM_FLAGS", "-fembed-bitcode -target arm64-apple-ios"),
3031
],
3132
),
3233
(
33-
"x86_64",
34+
"aarch64-apple-ios-sim",
35+
&[
36+
("CMAKE_OSX_ARCHITECTURES", "arm64"),
37+
("CMAKE_OSX_SYSROOT", "iphonesimulator"),
38+
(
39+
"CMAKE_ASM_FLAGS",
40+
"-fembed-bitcode -target arm64-apple-ios-simulator",
41+
),
42+
("CMAKE_THREAD_LIBS_INIT", "-lpthread"),
43+
("CMAKE_HAVE_THREADS_LIBRARY", "1"),
44+
("THREADS_PREFER_PTHREAD_FLAG", "ON"),
45+
],
46+
),
47+
(
48+
"x86_64-apple-ios",
3449
&[
3550
("CMAKE_OSX_ARCHITECTURES", "x86_64"),
3651
("CMAKE_OSX_SYSROOT", "iphonesimulator"),
52+
(
53+
"CMAKE_ASM_FLAGS",
54+
"-fembed-bitcode -target x86_64-apple-ios-simulator",
55+
),
3756
],
3857
),
3958
];
4059

4160
/// Create a cmake::Config for building BoringSSL.
4261
fn new_boringssl_cmake_config() -> cmake::Config {
62+
let target = std::env::var("TARGET").unwrap();
4363
let arch = std::env::var("CARGO_CFG_TARGET_ARCH").unwrap();
4464
let os = std::env::var("CARGO_CFG_TARGET_OS").unwrap();
4565

@@ -68,21 +88,17 @@ fn new_boringssl_cmake_config() -> cmake::Config {
6888
}
6989

7090
"ios" => {
71-
for (ios_arch, params) in CMAKE_PARAMS_IOS {
72-
if *ios_arch == arch {
91+
for (ios_target, params) in CMAKE_PARAMS_IOS {
92+
if *ios_target == target {
7393
for (name, value) in *params {
7494
boringssl_cmake.define(name, value);
95+
if *name == "CMAKE_ASM_FLAGS" {
96+
boringssl_cmake.cflag(value);
97+
}
7598
}
7699
break;
77100
}
78101
}
79-
80-
let mut cflag = "-fembed-bitcode".to_string();
81-
if arch == "x86_64" {
82-
cflag.push_str(" -target x86_64-apple-ios-simulator");
83-
}
84-
boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag);
85-
boringssl_cmake.cflag(&cflag);
86102
}
87103

88104
_ => (),

0 commit comments

Comments
 (0)