"Call it TCP/2. One More Time."
ngtcp2 project is an effort to implement RFC9000 QUIC protocol.
Online documentation is available.
The following endpoints are available to try out ngtcp2implementation:
https://nghttp2.org:4434 (requires address validation token)
https://nghttp2.org (powered by nghttpx)
This endpoints sends Alt-Svc header field to clients if it isaccessed via HTTP/1.1 or HTTP/2 to tell them that HTTP/3 isavailable at UDP 443.
The libngtcp2 C library itself does not depend on any externallibraries. The example client, and server are written in C++17, andshould compile with the modern C++ compilers (e.g., clang >= 8.0, orgcc >= 8.0).
The following packages are required to configure the build system:
libngtcp2 uses cunit for its unit test frame work:
To build sources under the examples directory, libev and nghttp3 arerequired:
ngtcp2 crypto helper library, and client and server under examplesdirectory require at least one of the following TLS backends:
$ git clone --depth 1 -b OpenSSL_1_1_1l+quic https://github.com/quictls/openssl
$ cd openssl
$ # For Linux
$ ./config enable-tls1_3 --prefix=$PWD/build
$ make -j$(nproc)
$ make install_sw
$ cd ..
$ git clone https://github.com/ngtcp2/nghttp3
$ cd nghttp3
$ autoreconf -i
$ ./configure --prefix=$PWD/build --enable-lib-only
$ make -j$(nproc) check
$ make install
$ cd ..
$ git clone https://github.com/ngtcp2/ngtcp2
$ cd ngtcp2
$ autoreconf -i
$ # For Mac users who have installed libev with MacPorts, append
$ # ',-L/opt/local/lib' to LDFLAGS, and also pass
$ # CPPFLAGS="-I/opt/local/include" to ./configure.
$ # For OpenSSL v3.0.0, replace "openssl/build/lib" with
$ # "openssl/build/lib64".
$ ./configure PKG_CONFIG_PATH=$PWD/../openssl/build/lib/pkgconfig:$PWD/../nghttp3/build/lib/pkgconfig LDFLAGS="-Wl,-rpath,$PWD/../openssl/build/lib"
$ make -j$(nproc) check
After successful build, the client and server executable should befound under examples directory. They talk HTTP/3.
$ examples/client [OPTIONS] <HOST> <PORT> [<URI>...]
The notable options are:
-d
, --data=<PATH>
: Read data from <PATH> and send it to apeer.$ examples/server [OPTIONS] <ADDR> <PORT> <PRIVATE_KEY_FILE> <CERTIFICATE_FILE>
The notable options are:
-V
, --validate-addr
: Enforce stateless address validation.There are h09client and h09server which speak HTTP/0.9. They arewritten just for quic-interop-runner. They sharethe basic functionalities with HTTP/3 client and server but have lessfunctions (e.g., h09client does not have a capability to send requestbody, and h09server does not understand numeric request path, like/1000).
In order to resume a session, a session ticket, and a transportparameters must be fetched from server. First, run examples/clientwith --session-file, and --tp-file options which specify a path tosession ticket, and transport parameter files respectively to savethem locally.
Once these files are available, run examples/client with the samearguments again. You will see that session is resumed in your log ifresumption succeeds. Resuming session makes server's first Handshakepacket pretty small because it does not send its certificates.
To send 0-RTT data, after making sure that resumption works, use -doption to specify a file which contains data to send.
QUIC server might send a token to client after connection has beenestablished. Client can send this token in subsequent connection tothe server. Server verifies the token and if it succeeds, the addressvalidation completes and lifts some restrictions on server which mightspeed up transfer. In order to save and/or load a token,use --token-file option of examples/client. The given file isoverwritten if it already exists when storing a token.
In order to make TLS stack integration less painful, we provide acrypto helper library which offers the basic crypto operations.
The header file exists under crypto/includes/ngtcp2 directory.
Each library file is built for a particular TLS backend. Theavailable crypto helper libraries are:
Because BoringSSL is an unversioned product, we only tested itsparticular revision. See Requirements section above.
The examples directory contains client and server that are linked tothose crypto helper libraries and TLS backends. They are only builtif their corresponding crypto helper library is built:
The library implements the following QUIC protocol extensions:
Wireshark can be configured toanalyze QUIC traffic using the following steps:
Set SSLKEYLOGFILE environment variable:
$ export SSLKEYLOGFILE=quic_keylog_file
Set the port that QUIC uses
Go to Preferences->Protocols->QUIC and set the port the programlistens to. In the case of the example application this would bethe port specified on the command line.
Set Pre-Master-Secret logfile
Go to Preferences->Protocols->TLS add set the Pre-Master-Secretlog file to the same value that was specified for SSLKEYLOGFILE.
Choose the correct network interface for capturing
Make sure you choose the correct network interface forcapturing. For example, if using localhost choose the loopbacknetwork interface on macos.
Create a filter
Create A filter for the udp.port and set the port to the port theapplication is listening to. For example:
udp.port == 7777
The MIT License
Copyright (c) 2016 ngtcp2 contributors
一 ngtcp2编译:github有步骤 openssl-OpenSSL_1_1_1m-quic、nghttp3、ngtcp2。 编译example,需要libev库--用了里面的函数。 二 Client 步骤: 1 auto callbacks = ngtcp2_callbacks{ ngtcp2_recv_crypto_data recv_crypto_data; //必须的,回调给ngtc
在上一次的博客中讲述了使用gcc命令行编译的一些简单程序的gdb调试, 但是在我们实际中更多的是一些软件工程,各种文件之间存在着相当大的依赖关系, 仅仅使用gcc来编译肯定是会存在一些问题的。因此此次介绍的是基于Linux下软件工程的gdb调试, 让你轻松搞定复杂的代码工程。 在Linux下的工程管理与Windows下的工程管理有很大的不同,Windows下的有着许多的开发工具帮助我
curl + openssl + ngtcp2 + nghttp3 #!/bin/sh -e # build nghttp3 (for GitHub workflow) git clone --depth 1 -b OpenSSL_1_1_1o+quic https://github.com/quictls/openssl cd openssl # For Linux ./config enab