Skip to content

Commit

Permalink
Merge pull request #337 from Tencent/release/v0.15.0
Browse files Browse the repository at this point in the history
Release/v0.15.0
  • Loading branch information
iyangsj authored Jul 18, 2024
2 parents 72f31ab + 04bd6b5 commit 1a68d04
Show file tree
Hide file tree
Showing 15 changed files with 553 additions and 123 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,20 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).


## [v0.15.0] - 2024-07-18

### Added
- Support building for the `aarch64-apple-ios-sim` target
- Support customized connection id generators
- Add `quic_packet_header_info()` to extract cid-related info from quic packets
- Add `quic_conn_path_stats` to get path level stats
- Add configuration for pacing granularity
- Tweak packet number encoding

### Fixed
- Replace the hashlru crate with the lru crate


## [v0.14.0] - 2024-07-11

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


[v0.15.0]: https://github.com/tencent/tquic/compare/v0.14.0...v0.15.0
[v0.14.0]: https://github.com/tencent/tquic/compare/v0.13.0...v0.14.0
[v0.13.0]: https://github.com/tencent/tquic/compare/v0.12.0...v0.13.0
[v0.12.0]: https://github.com/tencent/tquic/compare/v0.11.0...v0.12.0
Expand Down
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tquic"
version = "0.14.0"
version = "0.15.0"
edition = "2021"
rust-version = "1.70.0"
license = "Apache-2.0"
Expand Down Expand Up @@ -42,7 +42,7 @@ strum = "0.24"
strum_macros = "0.24"
rand = "0.8.5"
smallvec = { version = "1.10", features = ["serde", "union"] }
hashlru = "0.11"
lru = "0.12"
serde = { version = "1.0.139", features = ["derive"] }
serde_json = { version = "1.0", features = ["preserve_order"] }
serde_derive = "1.0"
Expand Down
2 changes: 1 addition & 1 deletion cbindgen.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ sys_includes = ["sys/socket.h", "sys/types.h"]
includes = ["openssl/ssl.h", "tquic_def.h"]

[export]
exclude = ["MAX_CID_LEN", "MIN_CLIENT_INITIAL_LEN", "VINT_MAX"]
exclude = ["MIN_CLIENT_INITIAL_LEN", "VINT_MAX"]

[export.rename]
"Config" = "quic_config_t"
Expand Down
169 changes: 169 additions & 0 deletions include/tquic.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@
*/
#define QUIC_VERSION_V1 1

/**
* The Connection ID MUST NOT exceed 20 bytes in QUIC version 1.
* See RFC 9000 Section 17.2
*/
#define MAX_CID_LEN 20

/**
* Available congestion control algorithms.
*/
Expand Down Expand Up @@ -224,6 +230,34 @@ typedef struct quic_packet_send_methods_t {

typedef void *quic_packet_send_context_t;

/**
* Connection Id is an identifier used to identify a QUIC connection
* at an endpoint.
*/
typedef struct ConnectionId {
/**
* length of cid
*/
uint8_t len;
/**
* octets of cid
*/
uint8_t data[MAX_CID_LEN];
} ConnectionId;

typedef struct ConnectionIdGeneratorMethods {
/**
* Generate a new CID
*/
struct ConnectionId (*generate)(void *gctx);
/**
* Return the length of a CID
*/
uint8_t (*cid_len)(void *gctx);
} ConnectionIdGeneratorMethods;

typedef void *ConnectionIdGeneratorContext;

/**
* Meta information of an incoming packet.
*/
Expand All @@ -241,6 +275,100 @@ typedef struct quic_path_address_t {
socklen_t remote_addr_len;
} quic_path_address_t;

/**
* Statistics about path
*/
typedef struct PathStats {
/**
* The number of QUIC packets received.
*/
uint64_t recv_count;
/**
* The number of received bytes.
*/
uint64_t recv_bytes;
/**
* The number of QUIC packets sent.
*/
uint64_t sent_count;
/**
* The number of sent bytes.
*/
uint64_t sent_bytes;
/**
* The number of QUIC packets lost.
*/
uint64_t lost_count;
/**
* The number of lost bytes.
*/
uint64_t lost_bytes;
/**
* Total number of bytes acked.
*/
uint64_t acked_bytes;
/**
* Total number of packets acked.
*/
uint64_t acked_count;
/**
* Initial congestion window in bytes.
*/
uint64_t init_cwnd;
/**
* Final congestion window in bytes.
*/
uint64_t final_cwnd;
/**
* Maximum congestion window in bytes.
*/
uint64_t max_cwnd;
/**
* Minimum congestion window in bytes.
*/
uint64_t min_cwnd;
/**
* Maximum inflight data in bytes.
*/
uint64_t max_inflight;
/**
* Total loss events.
*/
uint64_t loss_event_count;
/**
* Total congestion window limited events.
*/
uint64_t cwnd_limited_count;
/**
* Total duration of congestion windowlimited events in microseconds.
*/
uint64_t cwnd_limited_duration;
/**
* Minimum roundtrip time in microseconds.
*/
uint64_t min_rtt;
/**
* Maximum roundtrip time in microseconds.
*/
uint64_t max_rtt;
/**
* Smoothed roundtrip time in microseconds.
*/
uint64_t srtt;
/**
* Roundtrip time variation in microseconds.
*/
uint64_t rttvar;
/**
* Whether the congestion controller is in slow start status.
*/
bool in_slow_start;
/**
* Pacing rate estimated by congestion control algorithm.
*/
uint64_t pacing_rate;
} PathStats;

/**
* Statistics about a QUIC connection.
*/
Expand Down Expand Up @@ -478,6 +606,18 @@ void quic_config_set_bbr_probe_bw_cwnd_gain(struct quic_config_t *config, double
*/
void quic_config_set_initial_rtt(struct quic_config_t *config, uint64_t v);

/**
* Enable pacing to smooth the flow of packets sent onto the network.
* The default value is true.
*/
void quic_config_enable_pacing(struct quic_config_t *config, bool v);

/**
* Set clock granularity used by the pacer.
* The default value is 10 milliseconds.
*/
void quic_config_set_pacing_granularity(struct quic_config_t *config, uint64_t v);

/**
* Set the linear factor for calculating the probe timeout.
* The endpoint do not backoff the first `v` consecutive probe timeouts.
Expand Down Expand Up @@ -581,6 +721,7 @@ void quic_config_set_send_batch_size(struct quic_config_t *config, uint16_t v);

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

/**
* Set the connection id generator for the endpoint.
* By default, the random connection id generator is used.
*/
void quic_endpoint_set_cid_generator(struct quic_endpoint_t *endpoint,
const struct ConnectionIdGeneratorMethods *cid_gen_methods,
ConnectionIdGeneratorContext cid_gen_ctx);

/**
* Create a client connection.
* If success, the output parameter `index` carrys the index of the connection.
Expand Down Expand Up @@ -868,6 +1017,15 @@ bool quic_conn_path_iter_next(struct quic_path_address_iter_t *iter, struct quic
*/
bool quic_conn_active_path(const struct quic_conn_t *conn, struct quic_path_address_t *a);

/**
* Return the latest statistics about the specified path.
*/
const struct PathStats *quic_conn_path_stats(struct quic_conn_t *conn,
const struct sockaddr *local,
socklen_t local_len,
const struct sockaddr *remote,
socklen_t remote_len);

/**
* Return statistics about the connection.
*/
Expand Down Expand Up @@ -1069,6 +1227,17 @@ int quic_stream_set_context(struct quic_conn_t *conn, uint64_t stream_id, void *
*/
void *quic_stream_context(struct quic_conn_t *conn, uint64_t stream_id);

/**
* Extract the header form, version and destination connection id from the
* QUIC packet.
*/
int quic_packet_header_info(uint8_t *buf,
size_t buf_len,
uint8_t dcid_len,
bool *long_header,
uint32_t *version,
struct ConnectionId *dcid);

/**
* Create default config for HTTP3.
*/
Expand Down
38 changes: 27 additions & 11 deletions src/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,23 +23,43 @@ const CMAKE_PARAMS_ANDROID_NDK: &[(&str, &[(&str, &str)])] = &[
/// Additional parameters for iOS
const CMAKE_PARAMS_IOS: &[(&str, &[(&str, &str)])] = &[
(
"aarch64",
"aarch64-apple-ios",
&[
("CMAKE_OSX_ARCHITECTURES", "arm64"),
("CMAKE_OSX_SYSROOT", "iphoneos"),
("CMAKE_ASM_FLAGS", "-fembed-bitcode -target arm64-apple-ios"),
],
),
(
"x86_64",
"aarch64-apple-ios-sim",
&[
("CMAKE_OSX_ARCHITECTURES", "arm64"),
("CMAKE_OSX_SYSROOT", "iphonesimulator"),
(
"CMAKE_ASM_FLAGS",
"-fembed-bitcode -target arm64-apple-ios-simulator",
),
("CMAKE_THREAD_LIBS_INIT", "-lpthread"),
("CMAKE_HAVE_THREADS_LIBRARY", "1"),
("THREADS_PREFER_PTHREAD_FLAG", "ON"),
],
),
(
"x86_64-apple-ios",
&[
("CMAKE_OSX_ARCHITECTURES", "x86_64"),
("CMAKE_OSX_SYSROOT", "iphonesimulator"),
(
"CMAKE_ASM_FLAGS",
"-fembed-bitcode -target x86_64-apple-ios-simulator",
),
],
),
];

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

Expand Down Expand Up @@ -68,21 +88,17 @@ fn new_boringssl_cmake_config() -> cmake::Config {
}

"ios" => {
for (ios_arch, params) in CMAKE_PARAMS_IOS {
if *ios_arch == arch {
for (ios_target, params) in CMAKE_PARAMS_IOS {
if *ios_target == target {
for (name, value) in *params {
boringssl_cmake.define(name, value);
if *name == "CMAKE_ASM_FLAGS" {
boringssl_cmake.cflag(value);
}
}
break;
}
}

let mut cflag = "-fembed-bitcode".to_string();
if arch == "x86_64" {
cflag.push_str(" -target x86_64-apple-ios-simulator");
}
boringssl_cmake.define("CMAKE_ASM_FLAGS", &cflag);
boringssl_cmake.cflag(&cflag);
}

_ => (),
Expand Down
Loading

0 comments on commit 1a68d04

Please sign in to comment.