protocol-quic 0.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- checksums.yaml.gz.sig +0 -0
- data/ext/ngtcp2/AUTHORS +44 -0
- data/ext/ngtcp2/CMakeLists.txt +431 -0
- data/ext/ngtcp2/CMakeOptions.txt +17 -0
- data/ext/ngtcp2/COPYING +22 -0
- data/ext/ngtcp2/ChangeLog +0 -0
- data/ext/ngtcp2/Makefile.am +60 -0
- data/ext/ngtcp2/NEWS +0 -0
- data/ext/ngtcp2/README +1 -0
- data/ext/ngtcp2/README.rst +258 -0
- data/ext/ngtcp2/ci/build_boringssl.sh +10 -0
- data/ext/ngtcp2/ci/build_nghttp3.sh +9 -0
- data/ext/ngtcp2/ci/build_openssl1.sh +8 -0
- data/ext/ngtcp2/ci/build_openssl1_cross.sh +9 -0
- data/ext/ngtcp2/ci/build_openssl3.sh +8 -0
- data/ext/ngtcp2/ci/build_picotls.sh +26 -0
- data/ext/ngtcp2/ci/build_wolfssl.sh +9 -0
- data/ext/ngtcp2/ci/gen-certificate.sh +8 -0
- data/ext/ngtcp2/cmake/ExtractValidFlags.cmake +31 -0
- data/ext/ngtcp2/cmake/FindCUnit.cmake +40 -0
- data/ext/ngtcp2/cmake/FindJemalloc.cmake +40 -0
- data/ext/ngtcp2/cmake/FindLibev.cmake +38 -0
- data/ext/ngtcp2/cmake/FindLibnghttp3.cmake +41 -0
- data/ext/ngtcp2/cmake/Findwolfssl.cmake +41 -0
- data/ext/ngtcp2/cmake/Version.cmake +11 -0
- data/ext/ngtcp2/cmakeconfig.h.in +36 -0
- data/ext/ngtcp2/configure.ac +755 -0
- data/ext/ngtcp2/crypto/CMakeLists.txt +56 -0
- data/ext/ngtcp2/crypto/Makefile.am +49 -0
- data/ext/ngtcp2/crypto/boringssl/CMakeLists.txt +64 -0
- data/ext/ngtcp2/crypto/boringssl/Makefile.am +39 -0
- data/ext/ngtcp2/crypto/boringssl/boringssl.c +630 -0
- data/ext/ngtcp2/crypto/boringssl/libngtcp2_crypto_boringssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/gnutls/CMakeLists.txt +86 -0
- data/ext/ngtcp2/crypto/gnutls/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/gnutls/gnutls.c +644 -0
- data/ext/ngtcp2/crypto/gnutls/libngtcp2_crypto_gnutls.pc.in +33 -0
- data/ext/ngtcp2/crypto/includes/CMakeLists.txt +56 -0
- data/ext/ngtcp2/crypto/includes/Makefile.am +45 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto.h +893 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_boringssl.h +104 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_gnutls.h +107 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_openssl.h +132 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_picotls.h +246 -0
- data/ext/ngtcp2/crypto/includes/ngtcp2/ngtcp2_crypto_wolfssl.h +106 -0
- data/ext/ngtcp2/crypto/openssl/CMakeLists.txt +86 -0
- data/ext/ngtcp2/crypto/openssl/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/openssl/libngtcp2_crypto_openssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/openssl/openssl.c +807 -0
- data/ext/ngtcp2/crypto/picotls/CMakeLists.txt +65 -0
- data/ext/ngtcp2/crypto/picotls/Makefile.am +39 -0
- data/ext/ngtcp2/crypto/picotls/libngtcp2_crypto_picotls.pc.in +33 -0
- data/ext/ngtcp2/crypto/picotls/picotls.c +707 -0
- data/ext/ngtcp2/crypto/shared.c +1431 -0
- data/ext/ngtcp2/crypto/shared.h +350 -0
- data/ext/ngtcp2/crypto/wolfssl/CMakeLists.txt +84 -0
- data/ext/ngtcp2/crypto/wolfssl/Makefile.am +43 -0
- data/ext/ngtcp2/crypto/wolfssl/libngtcp2_crypto_wolfssl.pc.in +33 -0
- data/ext/ngtcp2/crypto/wolfssl/wolfssl.c +534 -0
- data/ext/ngtcp2/doc/Makefile.am +65 -0
- data/ext/ngtcp2/doc/make.bat +35 -0
- data/ext/ngtcp2/doc/mkapiref.py +356 -0
- data/ext/ngtcp2/doc/source/conf.py.in +94 -0
- data/ext/ngtcp2/doc/source/index.rst +22 -0
- data/ext/ngtcp2/doc/source/programmers-guide.rst +476 -0
- data/ext/ngtcp2/docker/Dockerfile +39 -0
- data/ext/ngtcp2/examples/CMakeLists.txt +361 -0
- data/ext/ngtcp2/examples/Makefile.am +228 -0
- data/ext/ngtcp2/examples/client.cc +3049 -0
- data/ext/ngtcp2/examples/client.h +192 -0
- data/ext/ngtcp2/examples/client_base.cc +202 -0
- data/ext/ngtcp2/examples/client_base.h +213 -0
- data/ext/ngtcp2/examples/debug.cc +298 -0
- data/ext/ngtcp2/examples/debug.h +124 -0
- data/ext/ngtcp2/examples/examplestest.cc +84 -0
- data/ext/ngtcp2/examples/gtlssimpleclient.c +720 -0
- data/ext/ngtcp2/examples/h09client.cc +2601 -0
- data/ext/ngtcp2/examples/h09client.h +196 -0
- data/ext/ngtcp2/examples/h09server.cc +3024 -0
- data/ext/ngtcp2/examples/h09server.h +237 -0
- data/ext/ngtcp2/examples/http.cc +138 -0
- data/ext/ngtcp2/examples/http.h +44 -0
- data/ext/ngtcp2/examples/network.h +80 -0
- data/ext/ngtcp2/examples/server.cc +3731 -0
- data/ext/ngtcp2/examples/server.h +256 -0
- data/ext/ngtcp2/examples/server_base.cc +58 -0
- data/ext/ngtcp2/examples/server_base.h +195 -0
- data/ext/ngtcp2/examples/shared.cc +385 -0
- data/ext/ngtcp2/examples/shared.h +96 -0
- data/ext/ngtcp2/examples/simpleclient.c +683 -0
- data/ext/ngtcp2/examples/template.h +71 -0
- data/ext/ngtcp2/examples/tests/README.rst +60 -0
- data/ext/ngtcp2/examples/tests/__init__.py +0 -0
- data/ext/ngtcp2/examples/tests/config.ini.in +32 -0
- data/ext/ngtcp2/examples/tests/conftest.py +28 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/__init__.py +6 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/certs.py +476 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/client.py +187 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/env.py +191 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/log.py +101 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/server.py +137 -0
- data/ext/ngtcp2/examples/tests/ngtcp2test/tls.py +983 -0
- data/ext/ngtcp2/examples/tests/test_01_handshake.py +30 -0
- data/ext/ngtcp2/examples/tests/test_02_resume.py +46 -0
- data/ext/ngtcp2/examples/tests/test_03_earlydata.py +56 -0
- data/ext/ngtcp2/examples/tests/test_04_clientcert.py +57 -0
- data/ext/ngtcp2/examples/tests/test_05_ciphers.py +46 -0
- data/ext/ngtcp2/examples/tls_client_context.h +52 -0
- data/ext/ngtcp2/examples/tls_client_context_boringssl.cc +126 -0
- data/ext/ngtcp2/examples/tls_client_context_boringssl.h +49 -0
- data/ext/ngtcp2/examples/tls_client_context_gnutls.cc +74 -0
- data/ext/ngtcp2/examples/tls_client_context_gnutls.h +50 -0
- data/ext/ngtcp2/examples/tls_client_context_openssl.cc +137 -0
- data/ext/ngtcp2/examples/tls_client_context_openssl.h +49 -0
- data/ext/ngtcp2/examples/tls_client_context_picotls.cc +158 -0
- data/ext/ngtcp2/examples/tls_client_context_picotls.h +53 -0
- data/ext/ngtcp2/examples/tls_client_context_wolfssl.cc +177 -0
- data/ext/ngtcp2/examples/tls_client_context_wolfssl.h +51 -0
- data/ext/ngtcp2/examples/tls_client_session.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_boringssl.cc +110 -0
- data/ext/ngtcp2/examples/tls_client_session_boringssl.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_gnutls.cc +190 -0
- data/ext/ngtcp2/examples/tls_client_session_gnutls.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_openssl.cc +113 -0
- data/ext/ngtcp2/examples/tls_client_session_openssl.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_picotls.cc +147 -0
- data/ext/ngtcp2/examples/tls_client_session_picotls.h +52 -0
- data/ext/ngtcp2/examples/tls_client_session_wolfssl.cc +160 -0
- data/ext/ngtcp2/examples/tls_client_session_wolfssl.h +52 -0
- data/ext/ngtcp2/examples/tls_server_context.h +52 -0
- data/ext/ngtcp2/examples/tls_server_context_boringssl.cc +257 -0
- data/ext/ngtcp2/examples/tls_server_context_boringssl.h +54 -0
- data/ext/ngtcp2/examples/tls_server_context_gnutls.cc +99 -0
- data/ext/ngtcp2/examples/tls_server_context_gnutls.h +59 -0
- data/ext/ngtcp2/examples/tls_server_context_openssl.cc +338 -0
- data/ext/ngtcp2/examples/tls_server_context_openssl.h +54 -0
- data/ext/ngtcp2/examples/tls_server_context_picotls.cc +321 -0
- data/ext/ngtcp2/examples/tls_server_context_picotls.h +58 -0
- data/ext/ngtcp2/examples/tls_server_context_wolfssl.cc +284 -0
- data/ext/ngtcp2/examples/tls_server_context_wolfssl.h +55 -0
- data/ext/ngtcp2/examples/tls_server_session.h +52 -0
- data/ext/ngtcp2/examples/tls_server_session_boringssl.cc +84 -0
- data/ext/ngtcp2/examples/tls_server_session_boringssl.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_gnutls.cc +155 -0
- data/ext/ngtcp2/examples/tls_server_session_gnutls.h +46 -0
- data/ext/ngtcp2/examples/tls_server_session_openssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_server_session_openssl.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_picotls.cc +70 -0
- data/ext/ngtcp2/examples/tls_server_session_picotls.h +47 -0
- data/ext/ngtcp2/examples/tls_server_session_wolfssl.cc +55 -0
- data/ext/ngtcp2/examples/tls_server_session_wolfssl.h +47 -0
- data/ext/ngtcp2/examples/tls_session_base_gnutls.cc +87 -0
- data/ext/ngtcp2/examples/tls_session_base_gnutls.h +51 -0
- data/ext/ngtcp2/examples/tls_session_base_openssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_session_base_openssl.h +52 -0
- data/ext/ngtcp2/examples/tls_session_base_picotls.cc +56 -0
- data/ext/ngtcp2/examples/tls_session_base_picotls.h +54 -0
- data/ext/ngtcp2/examples/tls_session_base_wolfssl.cc +54 -0
- data/ext/ngtcp2/examples/tls_session_base_wolfssl.h +54 -0
- data/ext/ngtcp2/examples/tls_shared_picotls.cc +59 -0
- data/ext/ngtcp2/examples/tls_shared_picotls.h +36 -0
- data/ext/ngtcp2/examples/util.cc +646 -0
- data/ext/ngtcp2/examples/util.h +361 -0
- data/ext/ngtcp2/examples/util_gnutls.cc +136 -0
- data/ext/ngtcp2/examples/util_openssl.cc +131 -0
- data/ext/ngtcp2/examples/util_test.cc +237 -0
- data/ext/ngtcp2/examples/util_test.h +45 -0
- data/ext/ngtcp2/examples/util_wolfssl.cc +130 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/ack +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/ack_ecn +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/connection_close +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/crypto +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/data_blocked +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/datagram_len +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_data +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_stream_data +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/max_streams +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/new_connection_id +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/new_token +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/path_challenge +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/path_response +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/reset_stream +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/retire_connection_id +1 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stop_sending +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_data_blocked +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/stream_len +0 -0
- data/ext/ngtcp2/fuzz/corpus/decode_frame/streams_blocked +0 -0
- data/ext/ngtcp2/fuzz/corpus/ksl/random +0 -0
- data/ext/ngtcp2/fuzz/decode_frame.cc +25 -0
- data/ext/ngtcp2/fuzz/ksl.cc +77 -0
- data/ext/ngtcp2/interop/Dockerfile +39 -0
- data/ext/ngtcp2/interop/run_endpoint.sh +93 -0
- data/ext/ngtcp2/lib/CMakeLists.txt +110 -0
- data/ext/ngtcp2/lib/Makefile.am +122 -0
- data/ext/ngtcp2/lib/includes/CMakeLists.txt +4 -0
- data/ext/ngtcp2/lib/includes/Makefile.am +25 -0
- data/ext/ngtcp2/lib/includes/ngtcp2/ngtcp2.h +5843 -0
- data/ext/ngtcp2/lib/includes/ngtcp2/version.h.in +51 -0
- data/ext/ngtcp2/lib/libngtcp2.pc.in +33 -0
- data/ext/ngtcp2/lib/ngtcp2_acktr.c +335 -0
- data/ext/ngtcp2/lib/ngtcp2_acktr.h +221 -0
- data/ext/ngtcp2/lib/ngtcp2_addr.c +117 -0
- data/ext/ngtcp2/lib/ngtcp2_addr.h +69 -0
- data/ext/ngtcp2/lib/ngtcp2_balloc.c +90 -0
- data/ext/ngtcp2/lib/ngtcp2_balloc.h +91 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr.c +693 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr.h +157 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr2.c +1490 -0
- data/ext/ngtcp2/lib/ngtcp2_bbr2.h +149 -0
- data/ext/ngtcp2/lib/ngtcp2_buf.c +56 -0
- data/ext/ngtcp2/lib/ngtcp2_buf.h +108 -0
- data/ext/ngtcp2/lib/ngtcp2_cc.c +616 -0
- data/ext/ngtcp2/lib/ngtcp2_cc.h +422 -0
- data/ext/ngtcp2/lib/ngtcp2_cid.c +147 -0
- data/ext/ngtcp2/lib/ngtcp2_cid.h +175 -0
- data/ext/ngtcp2/lib/ngtcp2_conn.c +13731 -0
- data/ext/ngtcp2/lib/ngtcp2_conn.h +1119 -0
- data/ext/ngtcp2/lib/ngtcp2_conn_stat.h +131 -0
- data/ext/ngtcp2/lib/ngtcp2_conv.c +291 -0
- data/ext/ngtcp2/lib/ngtcp2_conv.h +208 -0
- data/ext/ngtcp2/lib/ngtcp2_crypto.c +895 -0
- data/ext/ngtcp2/lib/ngtcp2_crypto.h +148 -0
- data/ext/ngtcp2/lib/ngtcp2_err.c +154 -0
- data/ext/ngtcp2/lib/ngtcp2_err.h +34 -0
- data/ext/ngtcp2/lib/ngtcp2_gaptr.c +167 -0
- data/ext/ngtcp2/lib/ngtcp2_gaptr.h +98 -0
- data/ext/ngtcp2/lib/ngtcp2_idtr.c +79 -0
- data/ext/ngtcp2/lib/ngtcp2_idtr.h +89 -0
- data/ext/ngtcp2/lib/ngtcp2_ksl.c +819 -0
- data/ext/ngtcp2/lib/ngtcp2_ksl.h +345 -0
- data/ext/ngtcp2/lib/ngtcp2_log.c +822 -0
- data/ext/ngtcp2/lib/ngtcp2_log.h +123 -0
- data/ext/ngtcp2/lib/ngtcp2_macro.h +58 -0
- data/ext/ngtcp2/lib/ngtcp2_map.c +336 -0
- data/ext/ngtcp2/lib/ngtcp2_map.h +136 -0
- data/ext/ngtcp2/lib/ngtcp2_mem.c +113 -0
- data/ext/ngtcp2/lib/ngtcp2_mem.h +72 -0
- data/ext/ngtcp2/lib/ngtcp2_net.h +136 -0
- data/ext/ngtcp2/lib/ngtcp2_objalloc.c +40 -0
- data/ext/ngtcp2/lib/ngtcp2_objalloc.h +140 -0
- data/ext/ngtcp2/lib/ngtcp2_opl.c +46 -0
- data/ext/ngtcp2/lib/ngtcp2_opl.h +65 -0
- data/ext/ngtcp2/lib/ngtcp2_path.c +77 -0
- data/ext/ngtcp2/lib/ngtcp2_path.h +49 -0
- data/ext/ngtcp2/lib/ngtcp2_pkt.c +2527 -0
- data/ext/ngtcp2/lib/ngtcp2_pkt.h +1235 -0
- data/ext/ngtcp2/lib/ngtcp2_pmtud.c +160 -0
- data/ext/ngtcp2/lib/ngtcp2_pmtud.h +123 -0
- data/ext/ngtcp2/lib/ngtcp2_ppe.c +230 -0
- data/ext/ngtcp2/lib/ngtcp2_ppe.h +153 -0
- data/ext/ngtcp2/lib/ngtcp2_pq.c +164 -0
- data/ext/ngtcp2/lib/ngtcp2_pq.h +126 -0
- data/ext/ngtcp2/lib/ngtcp2_pv.c +172 -0
- data/ext/ngtcp2/lib/ngtcp2_pv.h +194 -0
- data/ext/ngtcp2/lib/ngtcp2_qlog.c +1219 -0
- data/ext/ngtcp2/lib/ngtcp2_qlog.h +161 -0
- data/ext/ngtcp2/lib/ngtcp2_range.c +61 -0
- data/ext/ngtcp2/lib/ngtcp2_range.h +80 -0
- data/ext/ngtcp2/lib/ngtcp2_rcvry.h +40 -0
- data/ext/ngtcp2/lib/ngtcp2_ringbuf.c +121 -0
- data/ext/ngtcp2/lib/ngtcp2_ringbuf.h +132 -0
- data/ext/ngtcp2/lib/ngtcp2_rob.c +319 -0
- data/ext/ngtcp2/lib/ngtcp2_rob.h +197 -0
- data/ext/ngtcp2/lib/ngtcp2_rst.c +138 -0
- data/ext/ngtcp2/lib/ngtcp2_rst.h +86 -0
- data/ext/ngtcp2/lib/ngtcp2_rtb.c +1676 -0
- data/ext/ngtcp2/lib/ngtcp2_rtb.h +468 -0
- data/ext/ngtcp2/lib/ngtcp2_str.c +233 -0
- data/ext/ngtcp2/lib/ngtcp2_str.h +94 -0
- data/ext/ngtcp2/lib/ngtcp2_strm.c +698 -0
- data/ext/ngtcp2/lib/ngtcp2_strm.h +310 -0
- data/ext/ngtcp2/lib/ngtcp2_unreachable.c +71 -0
- data/ext/ngtcp2/lib/ngtcp2_unreachable.h +46 -0
- data/ext/ngtcp2/lib/ngtcp2_vec.c +243 -0
- data/ext/ngtcp2/lib/ngtcp2_vec.h +120 -0
- data/ext/ngtcp2/lib/ngtcp2_version.c +39 -0
- data/ext/ngtcp2/lib/ngtcp2_window_filter.c +99 -0
- data/ext/ngtcp2/lib/ngtcp2_window_filter.h +65 -0
- data/ext/ngtcp2/m4/ax_check_compile_flag.m4 +74 -0
- data/ext/ngtcp2/m4/ax_cxx_compile_stdcxx.m4 +1009 -0
- data/ext/ngtcp2/tests/CMakeLists.txt +68 -0
- data/ext/ngtcp2/tests/Makefile.am +94 -0
- data/ext/ngtcp2/tests/main.c +358 -0
- data/ext/ngtcp2/tests/ngtcp2_acktr_test.c +367 -0
- data/ext/ngtcp2/tests/ngtcp2_acktr_test.h +37 -0
- data/ext/ngtcp2/tests/ngtcp2_conn_test.c +9821 -0
- data/ext/ngtcp2/tests/ngtcp2_conn_test.h +104 -0
- data/ext/ngtcp2/tests/ngtcp2_conv_test.c +430 -0
- data/ext/ngtcp2/tests/ngtcp2_conv_test.h +46 -0
- data/ext/ngtcp2/tests/ngtcp2_crypto_test.c +667 -0
- data/ext/ngtcp2/tests/ngtcp2_crypto_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_gaptr_test.c +127 -0
- data/ext/ngtcp2/tests/ngtcp2_gaptr_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_idtr_test.c +79 -0
- data/ext/ngtcp2/tests/ngtcp2_idtr_test.h +34 -0
- data/ext/ngtcp2/tests/ngtcp2_ksl_test.c +502 -0
- data/ext/ngtcp2/tests/ngtcp2_ksl_test.h +39 -0
- data/ext/ngtcp2/tests/ngtcp2_map_test.c +206 -0
- data/ext/ngtcp2/tests/ngtcp2_map_test.h +38 -0
- data/ext/ngtcp2/tests/ngtcp2_pkt_test.c +1645 -0
- data/ext/ngtcp2/tests/ngtcp2_pkt_test.h +68 -0
- data/ext/ngtcp2/tests/ngtcp2_pmtud_test.c +153 -0
- data/ext/ngtcp2/tests/ngtcp2_pmtud_test.h +34 -0
- data/ext/ngtcp2/tests/ngtcp2_pv_test.c +129 -0
- data/ext/ngtcp2/tests/ngtcp2_pv_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_range_test.c +105 -0
- data/ext/ngtcp2/tests/ngtcp2_range_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.c +91 -0
- data/ext/ngtcp2/tests/ngtcp2_ringbuf_test.h +35 -0
- data/ext/ngtcp2/tests/ngtcp2_rob_test.c +552 -0
- data/ext/ngtcp2/tests/ngtcp2_rob_test.h +37 -0
- data/ext/ngtcp2/tests/ngtcp2_rtb_test.c +470 -0
- data/ext/ngtcp2/tests/ngtcp2_rtb_test.h +38 -0
- data/ext/ngtcp2/tests/ngtcp2_str_test.c +96 -0
- data/ext/ngtcp2/tests/ngtcp2_str_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_strm_test.c +575 -0
- data/ext/ngtcp2/tests/ngtcp2_strm_test.h +36 -0
- data/ext/ngtcp2/tests/ngtcp2_test_helper.c +404 -0
- data/ext/ngtcp2/tests/ngtcp2_test_helper.h +191 -0
- data/ext/ngtcp2/tests/ngtcp2_vec_test.c +426 -0
- data/ext/ngtcp2/tests/ngtcp2_vec_test.h +36 -0
- data/ext/ngtcp2/third-party/CMakeLists.txt +34 -0
- data/ext/ngtcp2/third-party/Makefile.am +31 -0
- data/ext/ngtcp2/third-party/http-parser/AUTHORS +68 -0
- data/ext/ngtcp2/third-party/http-parser/LICENSE-MIT +23 -0
- data/ext/ngtcp2/third-party/http-parser/Makefile +157 -0
- data/ext/ngtcp2/third-party/http-parser/README.md +246 -0
- data/ext/ngtcp2/third-party/http-parser/bench.c +111 -0
- data/ext/ngtcp2/third-party/http-parser/contrib/parsertrace.c +160 -0
- data/ext/ngtcp2/third-party/http-parser/contrib/url_parser.c +47 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.c +2419 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.gyp +111 -0
- data/ext/ngtcp2/third-party/http-parser/http_parser.h +431 -0
- data/ext/ngtcp2/third-party/http-parser/test.c +4411 -0
- data/lib/protocol/quic/version.rb +10 -0
- data/lib/protocol/quic.rb +9 -0
- data/license.md +21 -0
- data.tar.gz.sig +1 -0
- metadata +424 -0
- metadata.gz.sig +1 -0
@@ -0,0 +1,616 @@
|
|
1
|
+
/*
|
2
|
+
* ngtcp2
|
3
|
+
*
|
4
|
+
* Copyright (c) 2018 ngtcp2 contributors
|
5
|
+
*
|
6
|
+
* Permission is hereby granted, free of charge, to any person obtaining
|
7
|
+
* a copy of this software and associated documentation files (the
|
8
|
+
* "Software"), to deal in the Software without restriction, including
|
9
|
+
* without limitation the rights to use, copy, modify, merge, publish,
|
10
|
+
* distribute, sublicense, and/or sell copies of the Software, and to
|
11
|
+
* permit persons to whom the Software is furnished to do so, subject to
|
12
|
+
* the following conditions:
|
13
|
+
*
|
14
|
+
* The above copyright notice and this permission notice shall be
|
15
|
+
* included in all copies or substantial portions of the Software.
|
16
|
+
*
|
17
|
+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
18
|
+
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
19
|
+
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
20
|
+
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
21
|
+
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
22
|
+
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
23
|
+
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
24
|
+
*/
|
25
|
+
#include "ngtcp2_cc.h"
|
26
|
+
|
27
|
+
#include <assert.h>
|
28
|
+
|
29
|
+
#if defined(_MSC_VER)
|
30
|
+
# include <intrin.h>
|
31
|
+
#endif
|
32
|
+
|
33
|
+
#include "ngtcp2_log.h"
|
34
|
+
#include "ngtcp2_macro.h"
|
35
|
+
#include "ngtcp2_mem.h"
|
36
|
+
#include "ngtcp2_rcvry.h"
|
37
|
+
#include "ngtcp2_conn_stat.h"
|
38
|
+
|
39
|
+
uint64_t ngtcp2_cc_compute_initcwnd(size_t max_udp_payload_size) {
|
40
|
+
uint64_t n = 2 * max_udp_payload_size;
|
41
|
+
n = ngtcp2_max(n, 14720);
|
42
|
+
return ngtcp2_min(10 * max_udp_payload_size, n);
|
43
|
+
}
|
44
|
+
|
45
|
+
ngtcp2_cc_pkt *ngtcp2_cc_pkt_init(ngtcp2_cc_pkt *pkt, int64_t pkt_num,
|
46
|
+
size_t pktlen, ngtcp2_pktns_id pktns_id,
|
47
|
+
ngtcp2_tstamp sent_ts, uint64_t lost,
|
48
|
+
uint64_t tx_in_flight, int is_app_limited) {
|
49
|
+
pkt->pkt_num = pkt_num;
|
50
|
+
pkt->pktlen = pktlen;
|
51
|
+
pkt->pktns_id = pktns_id;
|
52
|
+
pkt->sent_ts = sent_ts;
|
53
|
+
pkt->lost = lost;
|
54
|
+
pkt->tx_in_flight = tx_in_flight;
|
55
|
+
pkt->is_app_limited = is_app_limited;
|
56
|
+
|
57
|
+
return pkt;
|
58
|
+
}
|
59
|
+
|
60
|
+
static void reno_cc_reset(ngtcp2_reno_cc *cc) {
|
61
|
+
cc->max_delivery_rate_sec = 0;
|
62
|
+
cc->target_cwnd = 0;
|
63
|
+
cc->pending_add = 0;
|
64
|
+
}
|
65
|
+
|
66
|
+
void ngtcp2_reno_cc_init(ngtcp2_reno_cc *cc, ngtcp2_log *log) {
|
67
|
+
cc->ccb.log = log;
|
68
|
+
reno_cc_reset(cc);
|
69
|
+
}
|
70
|
+
|
71
|
+
void ngtcp2_reno_cc_free(ngtcp2_reno_cc *cc) { (void)cc; }
|
72
|
+
|
73
|
+
int ngtcp2_cc_reno_cc_init(ngtcp2_cc *cc, ngtcp2_log *log,
|
74
|
+
const ngtcp2_mem *mem) {
|
75
|
+
ngtcp2_reno_cc *reno_cc;
|
76
|
+
|
77
|
+
reno_cc = ngtcp2_mem_calloc(mem, 1, sizeof(ngtcp2_reno_cc));
|
78
|
+
if (reno_cc == NULL) {
|
79
|
+
return NGTCP2_ERR_NOMEM;
|
80
|
+
}
|
81
|
+
|
82
|
+
ngtcp2_reno_cc_init(reno_cc, log);
|
83
|
+
|
84
|
+
cc->ccb = &reno_cc->ccb;
|
85
|
+
cc->on_pkt_acked = ngtcp2_cc_reno_cc_on_pkt_acked;
|
86
|
+
cc->congestion_event = ngtcp2_cc_reno_cc_congestion_event;
|
87
|
+
cc->on_persistent_congestion = ngtcp2_cc_reno_cc_on_persistent_congestion;
|
88
|
+
cc->on_ack_recv = ngtcp2_cc_reno_cc_on_ack_recv;
|
89
|
+
cc->reset = ngtcp2_cc_reno_cc_reset;
|
90
|
+
|
91
|
+
return 0;
|
92
|
+
}
|
93
|
+
|
94
|
+
void ngtcp2_cc_reno_cc_free(ngtcp2_cc *cc, const ngtcp2_mem *mem) {
|
95
|
+
ngtcp2_reno_cc *reno_cc = ngtcp2_struct_of(cc->ccb, ngtcp2_reno_cc, ccb);
|
96
|
+
|
97
|
+
ngtcp2_reno_cc_free(reno_cc);
|
98
|
+
ngtcp2_mem_free(mem, reno_cc);
|
99
|
+
}
|
100
|
+
|
101
|
+
static int in_congestion_recovery(const ngtcp2_conn_stat *cstat,
|
102
|
+
ngtcp2_tstamp sent_time) {
|
103
|
+
return cstat->congestion_recovery_start_ts != UINT64_MAX &&
|
104
|
+
sent_time <= cstat->congestion_recovery_start_ts;
|
105
|
+
}
|
106
|
+
|
107
|
+
void ngtcp2_cc_reno_cc_on_pkt_acked(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
108
|
+
const ngtcp2_cc_pkt *pkt,
|
109
|
+
ngtcp2_tstamp ts) {
|
110
|
+
ngtcp2_reno_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_reno_cc, ccb);
|
111
|
+
uint64_t m;
|
112
|
+
(void)ts;
|
113
|
+
|
114
|
+
if (in_congestion_recovery(cstat, pkt->sent_ts)) {
|
115
|
+
return;
|
116
|
+
}
|
117
|
+
|
118
|
+
if (cc->target_cwnd && cc->target_cwnd < cstat->cwnd) {
|
119
|
+
return;
|
120
|
+
}
|
121
|
+
|
122
|
+
if (cstat->cwnd < cstat->ssthresh) {
|
123
|
+
cstat->cwnd += pkt->pktlen;
|
124
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
125
|
+
"pkn=%" PRId64 " acked, slow start cwnd=%" PRIu64,
|
126
|
+
pkt->pkt_num, cstat->cwnd);
|
127
|
+
return;
|
128
|
+
}
|
129
|
+
|
130
|
+
m = cstat->max_tx_udp_payload_size * pkt->pktlen + cc->pending_add;
|
131
|
+
cc->pending_add = m % cstat->cwnd;
|
132
|
+
|
133
|
+
cstat->cwnd += m / cstat->cwnd;
|
134
|
+
}
|
135
|
+
|
136
|
+
void ngtcp2_cc_reno_cc_congestion_event(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
137
|
+
ngtcp2_tstamp sent_ts,
|
138
|
+
ngtcp2_tstamp ts) {
|
139
|
+
ngtcp2_reno_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_reno_cc, ccb);
|
140
|
+
uint64_t min_cwnd;
|
141
|
+
|
142
|
+
if (in_congestion_recovery(cstat, sent_ts)) {
|
143
|
+
return;
|
144
|
+
}
|
145
|
+
|
146
|
+
cstat->congestion_recovery_start_ts = ts;
|
147
|
+
cstat->cwnd >>= NGTCP2_LOSS_REDUCTION_FACTOR_BITS;
|
148
|
+
min_cwnd = 2 * cstat->max_tx_udp_payload_size;
|
149
|
+
cstat->cwnd = ngtcp2_max(cstat->cwnd, min_cwnd);
|
150
|
+
cstat->ssthresh = cstat->cwnd;
|
151
|
+
|
152
|
+
cc->pending_add = 0;
|
153
|
+
|
154
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
155
|
+
"reduce cwnd because of packet loss cwnd=%" PRIu64,
|
156
|
+
cstat->cwnd);
|
157
|
+
}
|
158
|
+
|
159
|
+
void ngtcp2_cc_reno_cc_on_persistent_congestion(ngtcp2_cc *ccx,
|
160
|
+
ngtcp2_conn_stat *cstat,
|
161
|
+
ngtcp2_tstamp ts) {
|
162
|
+
(void)ccx;
|
163
|
+
(void)ts;
|
164
|
+
|
165
|
+
cstat->cwnd = 2 * cstat->max_tx_udp_payload_size;
|
166
|
+
cstat->congestion_recovery_start_ts = UINT64_MAX;
|
167
|
+
}
|
168
|
+
|
169
|
+
void ngtcp2_cc_reno_cc_on_ack_recv(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
170
|
+
const ngtcp2_cc_ack *ack, ngtcp2_tstamp ts) {
|
171
|
+
ngtcp2_reno_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_reno_cc, ccb);
|
172
|
+
uint64_t target_cwnd, initcwnd;
|
173
|
+
(void)ack;
|
174
|
+
(void)ts;
|
175
|
+
|
176
|
+
/* TODO Use sliding window for min rtt measurement */
|
177
|
+
/* TODO Use sliding window */
|
178
|
+
cc->max_delivery_rate_sec =
|
179
|
+
ngtcp2_max(cc->max_delivery_rate_sec, cstat->delivery_rate_sec);
|
180
|
+
|
181
|
+
if (cstat->min_rtt != UINT64_MAX && cc->max_delivery_rate_sec) {
|
182
|
+
target_cwnd = cc->max_delivery_rate_sec * cstat->min_rtt / NGTCP2_SECONDS;
|
183
|
+
initcwnd = ngtcp2_cc_compute_initcwnd(cstat->max_tx_udp_payload_size);
|
184
|
+
cc->target_cwnd = ngtcp2_max(initcwnd, target_cwnd) * 289 / 100;
|
185
|
+
|
186
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
187
|
+
"target_cwnd=%" PRIu64 " max_delivery_rate_sec=%" PRIu64
|
188
|
+
" min_rtt=%" PRIu64,
|
189
|
+
cc->target_cwnd, cc->max_delivery_rate_sec, cstat->min_rtt);
|
190
|
+
}
|
191
|
+
}
|
192
|
+
|
193
|
+
void ngtcp2_cc_reno_cc_reset(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
194
|
+
ngtcp2_tstamp ts) {
|
195
|
+
ngtcp2_reno_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_reno_cc, ccb);
|
196
|
+
(void)cstat;
|
197
|
+
(void)ts;
|
198
|
+
|
199
|
+
reno_cc_reset(cc);
|
200
|
+
}
|
201
|
+
|
202
|
+
static void cubic_cc_reset(ngtcp2_cubic_cc *cc) {
|
203
|
+
cc->max_delivery_rate_sec = 0;
|
204
|
+
cc->target_cwnd = 0;
|
205
|
+
cc->w_last_max = 0;
|
206
|
+
cc->w_tcp = 0;
|
207
|
+
cc->origin_point = 0;
|
208
|
+
cc->epoch_start = UINT64_MAX;
|
209
|
+
cc->k = 0;
|
210
|
+
|
211
|
+
cc->prior.cwnd = 0;
|
212
|
+
cc->prior.ssthresh = 0;
|
213
|
+
cc->prior.w_last_max = 0;
|
214
|
+
cc->prior.w_tcp = 0;
|
215
|
+
cc->prior.origin_point = 0;
|
216
|
+
cc->prior.epoch_start = UINT64_MAX;
|
217
|
+
cc->prior.k = 0;
|
218
|
+
|
219
|
+
cc->rtt_sample_count = 0;
|
220
|
+
cc->current_round_min_rtt = UINT64_MAX;
|
221
|
+
cc->last_round_min_rtt = UINT64_MAX;
|
222
|
+
cc->window_end = -1;
|
223
|
+
}
|
224
|
+
|
225
|
+
void ngtcp2_cubic_cc_init(ngtcp2_cubic_cc *cc, ngtcp2_log *log) {
|
226
|
+
cc->ccb.log = log;
|
227
|
+
cubic_cc_reset(cc);
|
228
|
+
}
|
229
|
+
|
230
|
+
void ngtcp2_cubic_cc_free(ngtcp2_cubic_cc *cc) { (void)cc; }
|
231
|
+
|
232
|
+
int ngtcp2_cc_cubic_cc_init(ngtcp2_cc *cc, ngtcp2_log *log,
|
233
|
+
const ngtcp2_mem *mem) {
|
234
|
+
ngtcp2_cubic_cc *cubic_cc;
|
235
|
+
|
236
|
+
cubic_cc = ngtcp2_mem_calloc(mem, 1, sizeof(ngtcp2_cubic_cc));
|
237
|
+
if (cubic_cc == NULL) {
|
238
|
+
return NGTCP2_ERR_NOMEM;
|
239
|
+
}
|
240
|
+
|
241
|
+
ngtcp2_cubic_cc_init(cubic_cc, log);
|
242
|
+
|
243
|
+
cc->ccb = &cubic_cc->ccb;
|
244
|
+
cc->on_pkt_acked = ngtcp2_cc_cubic_cc_on_pkt_acked;
|
245
|
+
cc->congestion_event = ngtcp2_cc_cubic_cc_congestion_event;
|
246
|
+
cc->on_spurious_congestion = ngtcp2_cc_cubic_cc_on_spurious_congestion;
|
247
|
+
cc->on_persistent_congestion = ngtcp2_cc_cubic_cc_on_persistent_congestion;
|
248
|
+
cc->on_ack_recv = ngtcp2_cc_cubic_cc_on_ack_recv;
|
249
|
+
cc->on_pkt_sent = ngtcp2_cc_cubic_cc_on_pkt_sent;
|
250
|
+
cc->new_rtt_sample = ngtcp2_cc_cubic_cc_new_rtt_sample;
|
251
|
+
cc->reset = ngtcp2_cc_cubic_cc_reset;
|
252
|
+
cc->event = ngtcp2_cc_cubic_cc_event;
|
253
|
+
|
254
|
+
return 0;
|
255
|
+
}
|
256
|
+
|
257
|
+
void ngtcp2_cc_cubic_cc_free(ngtcp2_cc *cc, const ngtcp2_mem *mem) {
|
258
|
+
ngtcp2_cubic_cc *cubic_cc = ngtcp2_struct_of(cc->ccb, ngtcp2_cubic_cc, ccb);
|
259
|
+
|
260
|
+
ngtcp2_cubic_cc_free(cubic_cc);
|
261
|
+
ngtcp2_mem_free(mem, cubic_cc);
|
262
|
+
}
|
263
|
+
|
264
|
+
static uint64_t ngtcp2_cbrt(uint64_t n) {
|
265
|
+
int d;
|
266
|
+
uint64_t a;
|
267
|
+
|
268
|
+
if (n == 0) {
|
269
|
+
return 0;
|
270
|
+
}
|
271
|
+
|
272
|
+
#if defined(_MSC_VER)
|
273
|
+
# if defined(_M_X64)
|
274
|
+
d = (int)__lzcnt64(n);
|
275
|
+
# elif defined(_M_ARM64)
|
276
|
+
{
|
277
|
+
unsigned long index;
|
278
|
+
d = sizeof(uint64_t) * CHAR_BIT;
|
279
|
+
if (_BitScanReverse64(&index, n)) {
|
280
|
+
d = d - 1 - index;
|
281
|
+
}
|
282
|
+
}
|
283
|
+
# else
|
284
|
+
if ((n >> 32) != 0) {
|
285
|
+
d = __lzcnt((unsigned int)(n >> 32));
|
286
|
+
} else {
|
287
|
+
d = 32 + __lzcnt((unsigned int)n);
|
288
|
+
}
|
289
|
+
# endif
|
290
|
+
#else
|
291
|
+
d = __builtin_clzll(n);
|
292
|
+
#endif
|
293
|
+
a = 1ULL << ((64 - d) / 3 + 1);
|
294
|
+
|
295
|
+
for (; a * a * a > n;) {
|
296
|
+
a = (2 * a + n / a / a) / 3;
|
297
|
+
}
|
298
|
+
return a;
|
299
|
+
}
|
300
|
+
|
301
|
+
/* HyStart++ constants */
|
302
|
+
#define NGTCP2_HS_MIN_SSTHRESH 16
|
303
|
+
#define NGTCP2_HS_N_RTT_SAMPLE 8
|
304
|
+
#define NGTCP2_HS_MIN_ETA (4 * NGTCP2_MILLISECONDS)
|
305
|
+
#define NGTCP2_HS_MAX_ETA (16 * NGTCP2_MILLISECONDS)
|
306
|
+
|
307
|
+
void ngtcp2_cc_cubic_cc_on_pkt_acked(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
308
|
+
const ngtcp2_cc_pkt *pkt,
|
309
|
+
ngtcp2_tstamp ts) {
|
310
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
311
|
+
ngtcp2_duration t, eta;
|
312
|
+
uint64_t target, cwnd_thres;
|
313
|
+
uint64_t tx, kx, time_delta, delta;
|
314
|
+
uint64_t add, tcp_add;
|
315
|
+
uint64_t m;
|
316
|
+
|
317
|
+
if (pkt->pktns_id == NGTCP2_PKTNS_ID_APPLICATION && cc->window_end != -1 &&
|
318
|
+
cc->window_end <= pkt->pkt_num) {
|
319
|
+
cc->window_end = -1;
|
320
|
+
}
|
321
|
+
|
322
|
+
if (in_congestion_recovery(cstat, pkt->sent_ts)) {
|
323
|
+
return;
|
324
|
+
}
|
325
|
+
|
326
|
+
if (cc->target_cwnd && cc->target_cwnd < cstat->cwnd) {
|
327
|
+
return;
|
328
|
+
}
|
329
|
+
|
330
|
+
if (cstat->cwnd < cstat->ssthresh) {
|
331
|
+
/* slow-start */
|
332
|
+
cstat->cwnd += pkt->pktlen;
|
333
|
+
|
334
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
335
|
+
"pkn=%" PRId64 " acked, slow start cwnd=%" PRIu64,
|
336
|
+
pkt->pkt_num, cstat->cwnd);
|
337
|
+
|
338
|
+
if (cc->last_round_min_rtt != UINT64_MAX &&
|
339
|
+
cc->current_round_min_rtt != UINT64_MAX &&
|
340
|
+
cstat->cwnd >=
|
341
|
+
NGTCP2_HS_MIN_SSTHRESH * cstat->max_tx_udp_payload_size &&
|
342
|
+
cc->rtt_sample_count >= NGTCP2_HS_N_RTT_SAMPLE) {
|
343
|
+
eta = cc->last_round_min_rtt / 8;
|
344
|
+
|
345
|
+
if (eta < NGTCP2_HS_MIN_ETA) {
|
346
|
+
eta = NGTCP2_HS_MIN_ETA;
|
347
|
+
} else if (eta > NGTCP2_HS_MAX_ETA) {
|
348
|
+
eta = NGTCP2_HS_MAX_ETA;
|
349
|
+
}
|
350
|
+
|
351
|
+
if (cc->current_round_min_rtt >= cc->last_round_min_rtt + eta) {
|
352
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
353
|
+
"HyStart++ exit slow start");
|
354
|
+
|
355
|
+
cc->w_last_max = cstat->cwnd;
|
356
|
+
cstat->ssthresh = cstat->cwnd;
|
357
|
+
}
|
358
|
+
}
|
359
|
+
|
360
|
+
return;
|
361
|
+
}
|
362
|
+
|
363
|
+
/* congestion avoidance */
|
364
|
+
|
365
|
+
if (cc->epoch_start == UINT64_MAX) {
|
366
|
+
cc->epoch_start = ts;
|
367
|
+
if (cstat->cwnd < cc->w_last_max) {
|
368
|
+
cc->k = ngtcp2_cbrt((cc->w_last_max - cstat->cwnd) * 10 / 4 /
|
369
|
+
cstat->max_tx_udp_payload_size);
|
370
|
+
cc->origin_point = cc->w_last_max;
|
371
|
+
} else {
|
372
|
+
cc->k = 0;
|
373
|
+
cc->origin_point = cstat->cwnd;
|
374
|
+
}
|
375
|
+
|
376
|
+
cc->w_tcp = cstat->cwnd;
|
377
|
+
|
378
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
379
|
+
"cubic-ca epoch_start=%" PRIu64 " k=%" PRIu64
|
380
|
+
" origin_point=%" PRIu64,
|
381
|
+
cc->epoch_start, cc->k, cc->origin_point);
|
382
|
+
|
383
|
+
cc->pending_add = 0;
|
384
|
+
cc->pending_w_add = 0;
|
385
|
+
}
|
386
|
+
|
387
|
+
t = ts - cc->epoch_start;
|
388
|
+
|
389
|
+
tx = (t << 10) / NGTCP2_SECONDS;
|
390
|
+
kx = (cc->k << 10);
|
391
|
+
|
392
|
+
if (tx > kx) {
|
393
|
+
time_delta = tx - kx;
|
394
|
+
} else {
|
395
|
+
time_delta = kx - tx;
|
396
|
+
}
|
397
|
+
|
398
|
+
delta = cstat->max_tx_udp_payload_size *
|
399
|
+
((((time_delta * time_delta) >> 10) * time_delta) >> 10) * 4 / 10;
|
400
|
+
delta >>= 10;
|
401
|
+
|
402
|
+
if (tx > kx) {
|
403
|
+
target = cc->origin_point + delta;
|
404
|
+
} else {
|
405
|
+
target = cc->origin_point - delta;
|
406
|
+
}
|
407
|
+
|
408
|
+
cwnd_thres =
|
409
|
+
(target * (((t + cstat->smoothed_rtt) << 10) / NGTCP2_SECONDS)) >> 10;
|
410
|
+
if (cwnd_thres < cstat->cwnd) {
|
411
|
+
target = cstat->cwnd;
|
412
|
+
} else if (2 * cwnd_thres > 3 * cstat->cwnd) {
|
413
|
+
target = cstat->cwnd * 3 / 2;
|
414
|
+
} else {
|
415
|
+
target = cwnd_thres;
|
416
|
+
}
|
417
|
+
|
418
|
+
if (target > cstat->cwnd) {
|
419
|
+
m = cc->pending_add +
|
420
|
+
cstat->max_tx_udp_payload_size * (target - cstat->cwnd);
|
421
|
+
add = m / cstat->cwnd;
|
422
|
+
cc->pending_add = m % cstat->cwnd;
|
423
|
+
} else {
|
424
|
+
m = cc->pending_add + cstat->max_tx_udp_payload_size;
|
425
|
+
add = m / (100 * cstat->cwnd);
|
426
|
+
cc->pending_add = m % (100 * cstat->cwnd);
|
427
|
+
}
|
428
|
+
|
429
|
+
m = cc->pending_w_add + cstat->max_tx_udp_payload_size * pkt->pktlen;
|
430
|
+
|
431
|
+
cc->w_tcp += m / cstat->cwnd;
|
432
|
+
cc->pending_w_add = m % cstat->cwnd;
|
433
|
+
|
434
|
+
if (cc->w_tcp > cstat->cwnd) {
|
435
|
+
tcp_add = cstat->max_tx_udp_payload_size * (cc->w_tcp - cstat->cwnd) /
|
436
|
+
cstat->cwnd;
|
437
|
+
if (tcp_add > add) {
|
438
|
+
add = tcp_add;
|
439
|
+
}
|
440
|
+
}
|
441
|
+
|
442
|
+
cstat->cwnd += add;
|
443
|
+
|
444
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
445
|
+
"pkn=%" PRId64 " acked, cubic-ca cwnd=%" PRIu64 " t=%" PRIu64
|
446
|
+
" k=%" PRIi64 " time_delta=%" PRIu64 " delta=%" PRIu64
|
447
|
+
" target=%" PRIu64 " w_tcp=%" PRIu64,
|
448
|
+
pkt->pkt_num, cstat->cwnd, t, cc->k, time_delta >> 4, delta,
|
449
|
+
target, cc->w_tcp);
|
450
|
+
}
|
451
|
+
|
452
|
+
void ngtcp2_cc_cubic_cc_congestion_event(ngtcp2_cc *ccx,
|
453
|
+
ngtcp2_conn_stat *cstat,
|
454
|
+
ngtcp2_tstamp sent_ts,
|
455
|
+
ngtcp2_tstamp ts) {
|
456
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
457
|
+
uint64_t min_cwnd;
|
458
|
+
|
459
|
+
if (in_congestion_recovery(cstat, sent_ts)) {
|
460
|
+
return;
|
461
|
+
}
|
462
|
+
|
463
|
+
if (cc->prior.cwnd < cstat->cwnd) {
|
464
|
+
cc->prior.cwnd = cstat->cwnd;
|
465
|
+
cc->prior.ssthresh = cstat->ssthresh;
|
466
|
+
cc->prior.w_last_max = cc->w_last_max;
|
467
|
+
cc->prior.w_tcp = cc->w_tcp;
|
468
|
+
cc->prior.origin_point = cc->origin_point;
|
469
|
+
cc->prior.epoch_start = cc->epoch_start;
|
470
|
+
cc->prior.k = cc->k;
|
471
|
+
}
|
472
|
+
|
473
|
+
cstat->congestion_recovery_start_ts = ts;
|
474
|
+
|
475
|
+
cc->epoch_start = UINT64_MAX;
|
476
|
+
if (cstat->cwnd < cc->w_last_max) {
|
477
|
+
cc->w_last_max = cstat->cwnd * 17 / 10 / 2;
|
478
|
+
} else {
|
479
|
+
cc->w_last_max = cstat->cwnd;
|
480
|
+
}
|
481
|
+
|
482
|
+
min_cwnd = 2 * cstat->max_tx_udp_payload_size;
|
483
|
+
cstat->ssthresh = cstat->cwnd * 7 / 10;
|
484
|
+
cstat->ssthresh = ngtcp2_max(cstat->ssthresh, min_cwnd);
|
485
|
+
cstat->cwnd = cstat->ssthresh;
|
486
|
+
|
487
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
488
|
+
"reduce cwnd because of packet loss cwnd=%" PRIu64,
|
489
|
+
cstat->cwnd);
|
490
|
+
}
|
491
|
+
|
492
|
+
void ngtcp2_cc_cubic_cc_on_spurious_congestion(ngtcp2_cc *ccx,
|
493
|
+
ngtcp2_conn_stat *cstat,
|
494
|
+
ngtcp2_tstamp ts) {
|
495
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
496
|
+
(void)ts;
|
497
|
+
|
498
|
+
if (cstat->cwnd >= cc->prior.cwnd) {
|
499
|
+
return;
|
500
|
+
}
|
501
|
+
|
502
|
+
cstat->congestion_recovery_start_ts = UINT64_MAX;
|
503
|
+
|
504
|
+
cstat->cwnd = cc->prior.cwnd;
|
505
|
+
cstat->ssthresh = cc->prior.ssthresh;
|
506
|
+
cc->w_last_max = cc->prior.w_last_max;
|
507
|
+
cc->w_tcp = cc->prior.w_tcp;
|
508
|
+
cc->origin_point = cc->prior.origin_point;
|
509
|
+
cc->epoch_start = cc->prior.epoch_start;
|
510
|
+
cc->k = cc->prior.k;
|
511
|
+
|
512
|
+
cc->prior.cwnd = 0;
|
513
|
+
cc->prior.ssthresh = 0;
|
514
|
+
cc->prior.w_last_max = 0;
|
515
|
+
cc->prior.w_tcp = 0;
|
516
|
+
cc->prior.origin_point = 0;
|
517
|
+
cc->prior.epoch_start = UINT64_MAX;
|
518
|
+
cc->prior.k = 0;
|
519
|
+
|
520
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
521
|
+
"spurious congestion is detected and congestion state is "
|
522
|
+
"restored cwnd=%" PRIu64,
|
523
|
+
cstat->cwnd);
|
524
|
+
}
|
525
|
+
|
526
|
+
void ngtcp2_cc_cubic_cc_on_persistent_congestion(ngtcp2_cc *ccx,
|
527
|
+
ngtcp2_conn_stat *cstat,
|
528
|
+
ngtcp2_tstamp ts) {
|
529
|
+
(void)ccx;
|
530
|
+
(void)ts;
|
531
|
+
|
532
|
+
cstat->cwnd = 2 * cstat->max_tx_udp_payload_size;
|
533
|
+
cstat->congestion_recovery_start_ts = UINT64_MAX;
|
534
|
+
}
|
535
|
+
|
536
|
+
void ngtcp2_cc_cubic_cc_on_ack_recv(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
537
|
+
const ngtcp2_cc_ack *ack,
|
538
|
+
ngtcp2_tstamp ts) {
|
539
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
540
|
+
uint64_t target_cwnd, initcwnd;
|
541
|
+
(void)ack;
|
542
|
+
(void)ts;
|
543
|
+
|
544
|
+
/* TODO Use sliding window for min rtt measurement */
|
545
|
+
/* TODO Use sliding window */
|
546
|
+
cc->max_delivery_rate_sec =
|
547
|
+
ngtcp2_max(cc->max_delivery_rate_sec, cstat->delivery_rate_sec);
|
548
|
+
|
549
|
+
if (cstat->min_rtt != UINT64_MAX && cc->max_delivery_rate_sec) {
|
550
|
+
target_cwnd = cc->max_delivery_rate_sec * cstat->min_rtt / NGTCP2_SECONDS;
|
551
|
+
initcwnd = ngtcp2_cc_compute_initcwnd(cstat->max_tx_udp_payload_size);
|
552
|
+
cc->target_cwnd = ngtcp2_max(initcwnd, target_cwnd) * 289 / 100;
|
553
|
+
|
554
|
+
ngtcp2_log_info(cc->ccb.log, NGTCP2_LOG_EVENT_RCV,
|
555
|
+
"target_cwnd=%" PRIu64 " max_delivery_rate_sec=%" PRIu64
|
556
|
+
" min_rtt=%" PRIu64,
|
557
|
+
cc->target_cwnd, cc->max_delivery_rate_sec, cstat->min_rtt);
|
558
|
+
}
|
559
|
+
}
|
560
|
+
|
561
|
+
void ngtcp2_cc_cubic_cc_on_pkt_sent(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
562
|
+
const ngtcp2_cc_pkt *pkt) {
|
563
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
564
|
+
(void)cstat;
|
565
|
+
|
566
|
+
if (pkt->pktns_id != NGTCP2_PKTNS_ID_APPLICATION || cc->window_end != -1) {
|
567
|
+
return;
|
568
|
+
}
|
569
|
+
|
570
|
+
cc->window_end = pkt->pkt_num;
|
571
|
+
cc->last_round_min_rtt = cc->current_round_min_rtt;
|
572
|
+
cc->current_round_min_rtt = UINT64_MAX;
|
573
|
+
cc->rtt_sample_count = 0;
|
574
|
+
}
|
575
|
+
|
576
|
+
void ngtcp2_cc_cubic_cc_new_rtt_sample(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
577
|
+
ngtcp2_tstamp ts) {
|
578
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
579
|
+
(void)ts;
|
580
|
+
|
581
|
+
if (cc->window_end == -1) {
|
582
|
+
return;
|
583
|
+
}
|
584
|
+
|
585
|
+
cc->current_round_min_rtt =
|
586
|
+
ngtcp2_min(cc->current_round_min_rtt, cstat->latest_rtt);
|
587
|
+
++cc->rtt_sample_count;
|
588
|
+
}
|
589
|
+
|
590
|
+
void ngtcp2_cc_cubic_cc_reset(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
591
|
+
ngtcp2_tstamp ts) {
|
592
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
593
|
+
(void)cstat;
|
594
|
+
(void)ts;
|
595
|
+
|
596
|
+
cubic_cc_reset(cc);
|
597
|
+
}
|
598
|
+
|
599
|
+
void ngtcp2_cc_cubic_cc_event(ngtcp2_cc *ccx, ngtcp2_conn_stat *cstat,
|
600
|
+
ngtcp2_cc_event_type event, ngtcp2_tstamp ts) {
|
601
|
+
ngtcp2_cubic_cc *cc = ngtcp2_struct_of(ccx->ccb, ngtcp2_cubic_cc, ccb);
|
602
|
+
ngtcp2_tstamp last_ts;
|
603
|
+
|
604
|
+
if (event != NGTCP2_CC_EVENT_TYPE_TX_START || cc->epoch_start == UINT64_MAX) {
|
605
|
+
return;
|
606
|
+
}
|
607
|
+
|
608
|
+
last_ts = cstat->last_tx_pkt_ts[NGTCP2_PKTNS_ID_APPLICATION];
|
609
|
+
if (last_ts == UINT64_MAX || last_ts <= cc->epoch_start) {
|
610
|
+
return;
|
611
|
+
}
|
612
|
+
|
613
|
+
assert(ts >= last_ts);
|
614
|
+
|
615
|
+
cc->epoch_start += ts - last_ts;
|
616
|
+
}
|