mirror of
https://github.com/n0-computer/noq.git
synced 2026-09-20 18:23:41 +00:00
345 lines
18 KiB
HTML
345 lines
18 KiB
HTML
<!DOCTYPE HTML>
|
||
<html lang="en" class="sidebar-visible no-js light">
|
||
<head>
|
||
<!-- Book generated using mdBook -->
|
||
<meta charset="UTF-8">
|
||
<title>Quinn</title>
|
||
|
||
<meta name="robots" content="noindex" />
|
||
|
||
|
||
|
||
|
||
<!-- Custom HTML head -->
|
||
|
||
|
||
|
||
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
|
||
<meta name="description" content="">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||
<meta name="theme-color" content="#ffffff" />
|
||
|
||
|
||
<link rel="icon" href="favicon.svg">
|
||
|
||
|
||
<link rel="shortcut icon" href="favicon.png">
|
||
|
||
<link rel="stylesheet" href="css/variables.css">
|
||
<link rel="stylesheet" href="css/general.css">
|
||
<link rel="stylesheet" href="css/chrome.css">
|
||
|
||
<link rel="stylesheet" href="css/print.css" media="print">
|
||
|
||
|
||
<!-- Fonts -->
|
||
<link rel="stylesheet" href="FontAwesome/css/font-awesome.css">
|
||
|
||
<link rel="stylesheet" href="fonts/fonts.css">
|
||
|
||
|
||
<!-- Highlight.js Stylesheets -->
|
||
<link rel="stylesheet" href="highlight.css">
|
||
<link rel="stylesheet" href="tomorrow-night.css">
|
||
<link rel="stylesheet" href="ayu-highlight.css">
|
||
|
||
<!-- Custom theme stylesheets -->
|
||
|
||
|
||
|
||
</head>
|
||
<body>
|
||
<!-- Provide site root to javascript -->
|
||
<script type="text/javascript">
|
||
var path_to_root = "";
|
||
var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "navy" : "light";
|
||
</script>
|
||
|
||
<!-- Work around some values being stored in localStorage wrapped in quotes -->
|
||
<script type="text/javascript">
|
||
try {
|
||
var theme = localStorage.getItem('mdbook-theme');
|
||
var sidebar = localStorage.getItem('mdbook-sidebar');
|
||
|
||
if (theme.startsWith('"') && theme.endsWith('"')) {
|
||
localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
|
||
}
|
||
|
||
if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
|
||
localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
|
||
}
|
||
} catch (e) { }
|
||
</script>
|
||
|
||
<!-- Set the theme before any content is loaded, prevents flash -->
|
||
<script type="text/javascript">
|
||
var theme;
|
||
try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
|
||
if (theme === null || theme === undefined) { theme = default_theme; }
|
||
var html = document.querySelector('html');
|
||
html.classList.remove('no-js')
|
||
html.classList.remove('light')
|
||
html.classList.add(theme);
|
||
html.classList.add('js');
|
||
</script>
|
||
|
||
<!-- Hide / unhide sidebar before it is displayed -->
|
||
<script type="text/javascript">
|
||
var html = document.querySelector('html');
|
||
var sidebar = 'hidden';
|
||
if (document.body.clientWidth >= 1080) {
|
||
try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
|
||
sidebar = sidebar || 'visible';
|
||
}
|
||
html.classList.remove('sidebar-visible');
|
||
html.classList.add("sidebar-" + sidebar);
|
||
</script>
|
||
|
||
<nav id="sidebar" class="sidebar" aria-label="Table of contents">
|
||
<div class="sidebar-scrollbox">
|
||
<ol class="chapter"><li class="chapter-item expanded "><a href="quinn.html"><strong aria-hidden="true">1.</strong> Quinn introduction</a></li><li class="chapter-item expanded "><a href="quic.html"><strong aria-hidden="true">2.</strong> The QUIC protocol</a></li></ol>
|
||
</div>
|
||
<div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
|
||
</nav>
|
||
|
||
<div id="page-wrapper" class="page-wrapper">
|
||
|
||
<div class="page">
|
||
|
||
<div id="menu-bar-hover-placeholder"></div>
|
||
<div id="menu-bar" class="menu-bar sticky bordered">
|
||
<div class="left-buttons">
|
||
<button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
|
||
<i class="fa fa-bars"></i>
|
||
</button>
|
||
<button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
|
||
<i class="fa fa-paint-brush"></i>
|
||
</button>
|
||
<ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
|
||
<li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
|
||
<li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
|
||
</ul>
|
||
|
||
<button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
|
||
<i class="fa fa-search"></i>
|
||
</button>
|
||
|
||
</div>
|
||
|
||
<h1 class="menu-title">Quinn</h1>
|
||
|
||
<div class="right-buttons">
|
||
|
||
<a href="print.html" title="Print this book" aria-label="Print this book">
|
||
<i id="print-button" class="fa fa-print"></i>
|
||
</a>
|
||
|
||
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<div id="search-wrapper" class="hidden">
|
||
<form id="searchbar-outer" class="searchbar-outer">
|
||
<input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
|
||
</form>
|
||
<div id="searchresults-outer" class="searchresults-outer hidden">
|
||
<div id="searchresults-header" class="searchresults-header"></div>
|
||
<ul id="searchresults">
|
||
</ul>
|
||
</div>
|
||
</div>
|
||
|
||
|
||
<!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
|
||
<script type="text/javascript">
|
||
document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
|
||
document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
|
||
Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
|
||
link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
|
||
});
|
||
</script>
|
||
|
||
<div id="content" class="content">
|
||
<main>
|
||
<h1 align="center"><img width="500" src="./docs/thumbnail.svg" /></h1>
|
||
<p><a href="https://docs.rs/quinn/"><img src="https://docs.rs/quinn/badge.svg" alt="Documentation" /></a>
|
||
<a href="https://crates.io/crates/quinn"><img src="https://img.shields.io/crates/v/quinn.svg" alt="Crates.io" /></a>
|
||
<a href="https://github.com/djc/quinn/actions?query=workflow%3ACI"><img src="https://github.com/djc/quinn/workflows/CI/badge.svg" alt="Build status" /></a>
|
||
<a href="https://codecov.io/gh/djc/quinn"><img src="https://codecov.io/gh/djc/quinn/branch/main/graph/badge.svg" alt="codecov" /></a>
|
||
<a href="https://matrix.to/#/#djc_quinn:gitter.im"><img src="https://img.shields.io/badge/chat-%23djc_quinn:gitter.im-%2346BC99?logo=matrix" alt="Chat" /></a>
|
||
<a href="https://gitter.im/djc/quinn"><img src="https://badges.gitter.im/gitterHQ/gitter.svg" alt="Chat" /></a>
|
||
<a href="LICENSE-MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License: MIT" /></a>
|
||
<a href="LICENSE-APACHE"><img src="https://img.shields.io/badge/License-Apache%202.0-blue.svg" alt="License: Apache 2.0" /></a></p>
|
||
<h1><a class="header" href="#pure-rust-quic-protocol-implementation" id="pure-rust-quic-protocol-implementation">Pure-rust QUIC protocol implementation</a></h1>
|
||
<p>Quinn is a pure-rust, future-based implementation of the <a href="https://quicwg.github.io/">QUIC</a> transport protocol undergoing standardization by the IETF.
|
||
This library is at <a href="https://datatracker.ietf.org/doc/draft-ietf-quic-transport/32/">draft 32</a>.</p>
|
||
<h2><a class="header" href="#features" id="features">Features</a></h2>
|
||
<ul>
|
||
<li>Simultaneous client/server operation.</li>
|
||
<li>Ordered and unordered stream reads for improved performance.</li>
|
||
<li>Works on stable Rust, tested on Linux, macOS and Windows.</li>
|
||
<li>Pluggable cryptography, with a standard implementation backed by
|
||
<a href="https://github.com/ctz/rustls">rustls</a> and <a href="https://github.com/briansmith/ring"><em>ring</em></a>.</li>
|
||
<li>Application-layer datagrams for small, unreliable messages.</li>
|
||
<li>Future-based async API.</li>
|
||
<li>Experimental HTTP over QUIC.</li>
|
||
</ul>
|
||
<h2><a class="header" href="#overview" id="overview">Overview</a></h2>
|
||
<ul>
|
||
<li><strong>quinn:</strong> High-level async API based on tokio, see for usage. This will be used by most developers. (Basic benchmarks are included.)</li>
|
||
<li><strong>quinn-proto:</strong> Deterministic state machine of the protocol which performs <a href="https://sans-io.readthedocs.io/how-to-sans-io.html"><strong>no</strong> I/O</a> internally and is suitable for use with custom event loops (and potentially a C or C++ API).</li>
|
||
<li><strong>quinn-h3:</strong> Contains an implementation of HTTP-3 and QPACK. It is split internally in a deterministic state machine and a tokio-based high-level async API.</li>
|
||
<li><strong>bench:</strong> Benchmarks without any framework.</li>
|
||
<li><strong>interop:</strong> Tooling that helps to run interoperability tests.</li>
|
||
<li><strong>fuzz:</strong> Fuzz tests.</li>
|
||
</ul>
|
||
<h1><a class="header" href="#getting-started" id="getting-started">Getting Started</a></h1>
|
||
<p><strong>Examples</strong></p>
|
||
<pre><code class="language-sh">$ cargo run --example server ./
|
||
$ cargo run --example client https://localhost:4433/Cargo.toml
|
||
</code></pre>
|
||
<p>This launches an HTTP 0.9 server on the loopback address serving the current
|
||
working directory, with the client fetching <code>./Cargo.toml</code>. By default, the
|
||
server generates a self-signed certificate and stores it to disk, where the
|
||
client will automatically find and trust it.</p>
|
||
<p><strong>Links</strong></p>
|
||
<ul>
|
||
<li>Talk at <a href="https://paris.rustfest.eu/sessions/a-quic-future-in-rust">RustFest Paris (May 2018) presentation</a>; <a href="https://dirkjan.ochtman.nl/files/quic-future-in-rust.pdf">slides</a>; <a href="https://www.youtube.com/watch?v=EHgyY5DNdvI">YouTube</a></li>
|
||
<li>Usage <a href="https://github.com/djc/quinn/tree/main/quinn/examples">examples</a></li>
|
||
<li>Guide <a href="https://github.com/djc/quinn/issues/865">book</a></li>
|
||
</ul>
|
||
<h2><a class="header" href="#usage-notes" id="usage-notes">Usage Notes</a></h2>
|
||
<details>
|
||
<summary>
|
||
Click to show the notes
|
||
</summary>
|
||
<h3><a class="header" href="#buffers" id="buffers">Buffers</a></h3>
|
||
<p>A Quinn endpoint corresponds to a single UDP socket, no matter how many
|
||
connections are in use. Handling high aggregate data rates on a single endpoint
|
||
can require a larger UDP buffer than is configured by default in most
|
||
environments. If you observe erratic latency and/or throughput over a stable
|
||
network link, consider increasing the buffer sizes used. For example, you could
|
||
adjust the <code>SO_SNDBUF</code> and <code>SO_RCVBUF</code> options of the UDP socket to be used
|
||
before passing it in to Quinn. Note that some platforms (e.g. Linux) require
|
||
elevated privileges or modified system configuration for a process to increase
|
||
its UDP buffer sizes.</p>
|
||
<h3><a class="header" href="#certificates" id="certificates">Certificates</a></h3>
|
||
<p>By default, Quinn clients validate the cryptographic identity of servers they
|
||
connect to. This prevents an active, on-path attacker from intercepting
|
||
messages, but requires trusting some certificate authority. For many purposes,
|
||
this can be accomplished by using certificates from <a href="https://letsencrypt.org/">Let's Encrypt</a>
|
||
for servers, and relying on the default configuration for clients.</p>
|
||
<p>For some cases, including peer-to-peer, trust-on-first-use, deliberately
|
||
insecure applications, or any case where servers are not identified by domain
|
||
name, this isn't practical. Arbitrary certificate validation logic can be
|
||
implemented by enabling the <code>dangerous_configuration</code> feature of <code>rustls</code> and
|
||
constructing a Quinn <code>ClientConfig</code> with an overridden certificate verifier by
|
||
hand.</p>
|
||
<p>When operating your own certificate authority doesn't make sense, <a href="https://crates.io/crates/rcgen">rcgen</a>
|
||
can be used to generate self-signed certificates on demand. To support
|
||
trust-on-first-use, servers that automatically generate self-signed certificates
|
||
should write their generated certificate to persistent storage and reuse it on
|
||
future runs.</p>
|
||
</details>
|
||
<p></p>
|
||
<h2><a class="header" href="#contribution" id="contribution">Contribution</a></h2>
|
||
<p>All feedback welcome. Feel free to file bugs, requests for documentation and
|
||
any other feedback to the <a href="https://github.com/djc/quinn/issues">issue tracker</a>.</p>
|
||
<p>The quinn-proto test suite uses simulated IO for reproducibility and to avoid
|
||
long sleeps in certain timing-sensitive tests. If the <code>SSLKEYLOGFILE</code>
|
||
environment variable is set, the tests will emit UDP packets for inspection
|
||
using external protocol analyzers like Wireshark, and NSS-compatible key logs
|
||
for the client side of each connection will be written to the path specified in
|
||
the variable.</p>
|
||
<h2><a class="header" href="#authors" id="authors">Authors</a></h2>
|
||
<ul>
|
||
<li><strong>Dirkjan Ochtman</strong> - <em>Project owner & founder</em></li>
|
||
<li><strong>Benjamin Saunders</strong> - <em>Project owner & founder</em></li>
|
||
<li><strong>Jean-Christophe Begue</strong> - <em>Project collaborator, author of the HTTP/3 Implementation</em></li>
|
||
</ul>
|
||
<h1><a class="header" href="#the-quic-protocol" id="the-quic-protocol">The QUIC protocol</a></h1>
|
||
<p><a href="https://en.wikipedia.org/wiki/QUIC">QUIC</a> is a general-purpose network protocol built on top of UDP.
|
||
The protocol is still under development and standardized by the <a href="https://www.ietf.org/">IETF</a>.
|
||
Quinn strives to implement the latest <a href="https://datatracker.ietf.org/doc/draft-ietf-quic-transport/">draft</a> but may lag a bit behind. Although QUIC is still in a draft phase,
|
||
the protocol is used for all connections from Chrome web browsers to the Google servers. </p>
|
||
<p>QUIC solves a number of transport-layer and application-layer problems experienced by modern web applications.
|
||
It is very similar to TCP+TLS+HTTP2, but implemented on top of UDP.
|
||
Having QUIC as a self-contained protocol allows innovations which aren’t
|
||
possible with existing protocols as they are hampered by legacy clients and middleboxes.</p>
|
||
<p>Key advantages of QUIC over TCP+TLS+HTTP2 include:</p>
|
||
<ul>
|
||
<li>Improved connection establishment speed (0-rtt).</li>
|
||
<li>Improved congestion control by moving congestion control algorithms into the user space at both endpoints.</li>
|
||
<li>Improved bandwidth estimation in each direction to avoid congestion. </li>
|
||
<li>Improved multiplexing without head-of-line blocking.</li>
|
||
<li>Contains forward error correction (FEC). </li>
|
||
</ul>
|
||
<p>While QUIC's intentions are originally web-oriented, it offers interesting opportunities in other areas like game networking.
|
||
One thing is for sure, QUIC has many great potentials and will serve us in the future with HTTP/3. </p>
|
||
<p>In the upcoming chapter we will be discussing various aspects of QUIC also in relation to Quinn. </p>
|
||
|
||
</main>
|
||
|
||
<nav class="nav-wrapper" aria-label="Page navigation">
|
||
<!-- Mobile navigation buttons -->
|
||
|
||
|
||
|
||
|
||
<div style="clear: both"></div>
|
||
</nav>
|
||
</div>
|
||
</div>
|
||
|
||
<nav class="nav-wide-wrapper" aria-label="Page navigation">
|
||
|
||
|
||
|
||
</nav>
|
||
|
||
</div>
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
window.playground_copyable = true;
|
||
</script>
|
||
|
||
|
||
|
||
|
||
|
||
<script src="elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
|
||
<script src="mark.min.js" type="text/javascript" charset="utf-8"></script>
|
||
<script src="searcher.js" type="text/javascript" charset="utf-8"></script>
|
||
|
||
|
||
<script src="clipboard.min.js" type="text/javascript" charset="utf-8"></script>
|
||
<script src="highlight.js" type="text/javascript" charset="utf-8"></script>
|
||
<script src="book.js" type="text/javascript" charset="utf-8"></script>
|
||
|
||
<!-- Custom JS scripts -->
|
||
|
||
|
||
|
||
|
||
<script type="text/javascript">
|
||
window.addEventListener('load', function() {
|
||
window.setTimeout(window.print, 100);
|
||
});
|
||
</script>
|
||
|
||
|
||
|
||
</body>
|
||
</html>
|