Total Pageviews

Friday 29 April 2022

用rust实现quic协议的方法-neqo和quiche

Neqo, an Implementation of QUIC written in Rust

To run test HTTP/3 programs (neqo-client and neqo-server):

  • cargo build
  • ./target/debug/neqo-server [::]:12345 --db ./test-fixture/db
  • ./target/debug/neqo-client http://127.0.0.1:12345/

Faster Builds with Separate NSS/NSPR

You can clone NSS (https://hg.mozilla.org/projects/nss) and NSPR (https://hg.mozilla.org/projects/nspr) into the same directory and export an environment variable called NSS_DIR pointing to NSS. This causes the build to use the existing NSS checkout. However, in order to run anything that depends on NSS, you need to set $\[DY]LD\_LIBRARY\_PATH to point to $NSS_DIR/../dist/Debug/lib.

Note: If you did not compile NSS separately, you need to have mercurial (hg), installed. NSS builds require gyp, and ninja (or ninja-build) to be present also.

Debugging Neqo

Using SSLKEYLOGFILE to decrypt Wireshark logs

Info here

TODO: What is the minimum Wireshark version needed? TODO: Above link may be incorrect, protocol now called TLS instead of SSL?

Using RUST_LOG effectively

As documented in the env_logger documentation, the RUST_LOG environment variable can be used to selectively enable log messages from Rust code. This works for Neqo's cmdline tools, as well as for when Neqo is incorporated into Gecko, although Gecko needs to be built in debug mode.

Some examples:

  1. RUST_LOG=neqo_transport::dump ./mach run lists sent and received QUIC packets and their frames' contents only.
  2. RUST_LOG=neqo_transport=debug,neqo_http3=trace,info ./mach run sets a 'debug' log level for transport, 'trace' level for http3, and 'info' log level for all other Rust crates, both Neqo and others used by Gecko.
  3. RUST_LOG=neqo=trace,error ./mach run sets trace level for all modules starting with "neqo", and sets error as minimum log level for other unrelated Rust log messages.

Trying In-development Neqo code in Gecko

In a checked-out copy of Gecko source, set paths for the four Neqo crates to local versions in netwerk/socket/neqo_glue/Cargo.toml. For example, if Neqo was checked out to /home/alice/git/neqo, change:

neqo-http3 = { tag = "v0.1.7", git = "https://github.com/mozilla/neqo" }
neqo-transport = { tag = "v0.1.7", git = "https://github.com/mozilla/neqo" }
neqo-common = { tag = "v0.1.7", git = "https://github.com/mozilla/neqo" }

to

neqo-http3 = { path = "/home/alice/git/neqo/neqo-http3" }
neqo-transport = { path = "/home/alice/git/neqo/neqo-transport" }
neqo-common = { path = "/home/alice/git/neqo/neqo-common" }

and

[dependencies.neqo-crypto]
tag = "v0.1.7"
git = "https://github.com/mozilla/neqo"
default-features = false
features = ["gecko"]

to

[dependencies.neqo-crypto]
path = "/home/alice/git/neqo/neqo-crypto"
default-features = false
features = ["gecko"]

Note: Using newer Neqo code with Gecko may also require changes (likely to neqo_glue) if something has changed.

Compile Gecko as usual with ./mach build.

from  https://github.com/mozilla/neqo

-----

Savoury implementation of the QUIC transport protocol and HTTP/3。

https://docs.quic.tech/quiche/

crates.io docs.rs license build

quiche is an implementation of the QUIC transport protocol and HTTP/3 as specified by the IETF. It provides a low level API for processing QUIC packets and handling connection state. The application is responsible for providing I/O (e.g. sockets handling) as well as an event loop with support for timers.

For more information on how quiche came about and some insights into its design you can read a post on Cloudflare's blog that goes into some more detail.

Who uses quiche?

Cloudflare

quiche powers Cloudflare edge network's HTTP/3 support. The cloudflare-quic.com website can be used for testing and experimentation.

curl

quiche can be integrated into curl to provide support for HTTP/3.

NGINX (unofficial)

quiche can be integrated into NGINX using an unofficial patch to provide support for HTTP/3.

Getting Started

Command-line apps

Before diving into the quiche API, here are a few examples on how to use the quiche tools provided as part of the quiche-apps crate.

After cloning the project according to the command mentioned in the building section, the client can be run as follows:

 $ cargo run --bin quiche-client -- https://cloudflare-quic.com/

while the server can be run as follows:

 $ cargo run --bin quiche-server -- --cert apps/src/bin/cert.crt --key apps/src/bin/cert.key

(note that the certificate provided is self-signed and should not be used in production)

Use the --help command-line flag to get a more detailed description of each tool's options.

from  https://github.com/cloudflare/quiche

----

delicious quiche

Quiche is Cloudflare's own open-source implementation of the QUIC and HTTP/3 protocols written in Rust.

The following articles provide some background.

from https://cloudflare-quic.com/
------

https://github.com/quininer/tokio-quiche



No comments:

Post a Comment