当前位置: 首页 > 软件库 > 程序开发 > 网络工具包 >

ngtcp2

授权协议 MIT License
开发语言 C/C++
所属分类 程序开发、 网络工具包
软件类型 开源软件
地区 不详
投 递 者 麹耘豪
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

ngtcp2

"Call it TCP/2. One More Time."

ngtcp2 project is an effort to implement RFC9000 QUIC protocol.

Documentation

Online documentation is available.

Public test server

The following endpoints are available to try out ngtcp2implementation:

Requirements

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:

  • pkg-config >= 0.20
  • autoconf
  • automake
  • autotools-dev
  • libtool

libngtcp2 uses cunit for its unit test frame work:

  • cunit >= 2.1

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:

Build from git

$ 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

Client/Server

After successful build, the client and server executable should befound under examples directory. They talk HTTP/3.

Client

$ examples/client [OPTIONS] <HOST> <PORT> [<URI>...]

The notable options are:

  • -d, --data=<PATH>: Read data from <PATH> and send it to apeer.

Server

$ examples/server [OPTIONS] <ADDR> <PORT> <PRIVATE_KEY_FILE> <CERTIFICATE_FILE>

The notable options are:

  • -V, --validate-addr: Enforce stateless address validation.

H09client/H09server

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).

Resumption and 0-RTT

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.

Token (Not something included in Retry packet)

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.

Crypto helper library

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:

  • libngtcp2_crypto_openssl: Use OpenSSL as TLS backend
  • libngtcp2_crypto_gnutls: Use GnuTLS as TLS backend
  • libngtcp2_crypto_boringssl: Use BoringSSL as TLS backend

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:

  • client: OpenSSL client
  • server: OpenSSL server
  • gtlsclient: GnuTLS client
  • gtlsserver: GnuTLS server
  • bsslclient: BoringSSL client
  • bsslserver: BoringSSL server

QUIC protocol extensions

The library implements the following QUIC protocol extensions:

Configuring Wireshark for QUIC

Wireshark can be configured toanalyze QUIC traffic using the following steps:

  1. Set SSLKEYLOGFILE environment variable:

    $ export SSLKEYLOGFILE=quic_keylog_file
  2. 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.

  3. 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.

  4. 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.

  5. 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

License

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

相关阅读

相关文章

相关问答

相关文档