### Install Kani Verifier Source: https://github.com/aws/s2n-quic/blob/main/docs/dev-guide/kani.md Installs the Kani verifier and sets up the necessary environment for proof harnesses. ```sh cargo install kani-verifier cargo-kani setup ``` -------------------------------- ### Start perf Server Source: https://github.com/aws/s2n-quic/blob/main/quic/s2n-quic-qns/README.md Starts the perf server on a specified port. This server is used for testing QUIC implementation throughput and efficiency. ```bash ./target/release/s2n-quic-qns perf server --port 4433 ``` -------------------------------- ### Install Rust Components and Nightly Toolchain Source: https://github.com/aws/s2n-quic/blob/main/docs/dev-guide/setup.md Installs essential Rust components for testing and analysis, and the nightly toolchain for development. Ensure rustup is installed first. ```sh rustup component add rustfmt clippy rust-analysis rustup toolchain install nightly ``` -------------------------------- ### IPv6 Option Layout Example 2 Source: https://github.com/aws/s2n-quic/blob/main/specs/www.rfc-editor.org/rfc/rfc2460.txt Demonstrates the layout of an option with three data fields (4, 2, and 1 octets) and its alignment requirement. This ensures the 4-octet field starts at a multiple-of-4 offset. ```text +-+-+-+-+-+-+-+-+ | Option Type=Y | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |Opt Data Len=7 | 1-octet field | 2-octet field | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | 4-octet field | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- ``` ```text +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Hdr Ext Len=1 | Pad1 Option=0 | Option Type=Y | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- |Opt Data Len=7 | 1-octet field | 2-octet field | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | 4-octet field | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | PadN Option=1 |Opt Data Len=2 | 0 | 0 | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- ``` -------------------------------- ### Install dcQUIC Wireshark Plugin Source: https://github.com/aws/s2n-quic/blob/main/dc/wireshark/README.md Use this command to install the dcQUIC Wireshark plugin for the current machine. Ensure you have the necessary Rust build tools. ```bash cargo xtask install ``` -------------------------------- ### Start hq-interop Server Source: https://github.com/aws/s2n-quic/blob/main/quic/s2n-quic-qns/README.md Starts the hq-interop server on a specified port. This server is used for testing with the quic-interop-runner. ```bash ./target/release/s2n-quic-qns interop server --port 4433 ``` -------------------------------- ### Header Protection Calculation Example (Hex) Source: https://github.com/aws/s2n-quic/blob/main/specs/www.rfc-editor.org/rfc/rfc9001.txt This example demonstrates the calculation of the header protection sample and mask, starting from the third protected byte, and the resulting protected header. ```hex sample = 2cd0991cd25b0aac406a5816b6394100 mask = 2ec0d8356a header = cf000000010008f067a5502a4262b5004075c0d9 ``` -------------------------------- ### Run Unreliable Datagram Sender Example Source: https://github.com/aws/s2n-quic/blob/main/examples/unreliable-datagram/README.md Execute this command in your shell to start the QUIC server that sends an unreliable datagram. ```sh cargo run --bin datagram_sender ``` -------------------------------- ### Async QUIC Client Hello Callback Source: https://github.com/aws/s2n-quic/blob/main/docs/examples/async-client-hello-callback.md Implement the client side of the async hello callback example. This code establishes a QUIC connection and handles the handshake and data exchange using callbacks. ```rust use std::env; use std::error::Error; use std::net::SocketAddr; use std::sync::{Arc, Mutex}; use s2n_quic::client::{Client, Connect}; #[tokio::main] async fn main() -> Result<(), Box> { let addr: SocketAddr = env::args().nth(1).unwrap().parse()?; let host = env::args().nth(2).unwrap(); let mut client = Client::builder() .unwrap() .with_tls(Default::default()) .unwrap() .with_io(Default::default()) .unwrap() .start() .unwrap(); let connect = Connect { local_addr: addr, server_name: host.clone(), }; let connection_id = client.connect(connect).await?; let mut stream = client.open_stream(connection_id).await?; stream.send_data("hello\n".into()).await?; let mut data = vec![0u8; 1024]; let recv_bytes = stream.receive_data(&mut data).await?; println!("Received: {}\n", std::str::from_utf8(&data[..recv_bytes]).unwrap()); Ok(()) } ``` -------------------------------- ### Async QUIC Server Hello Callback Source: https://github.com/aws/s2n-quic/blob/main/docs/examples/async-client-hello-callback.md Implement the server side of the async hello callback example. This code listens for incoming QUIC connections and handles client requests, sending back a 'hello' response. ```rust use std::error::Error; use s2n_quic::server::{Server, io::IoEvent}; #[tokio::main] async fn main() -> Result<(), Box> { let mut server = Server::builder() .unwrap() .with_tls(Default::default()) .unwrap() .with_io(Default::default()) .unwrap() .start() .unwrap(); while let Some(io_event) = server.next_io_event().await? { match io_event { IoEvent::NewConnection (mut connection) => { tokio::spawn(async move { while let Some(stream_result) = connection.next_stream().await? { match stream_result { Ok(mut stream) => { let mut data = vec![0u8; 1024]; let recv_bytes = stream.receive_data(&mut data).await?; stream.send_data(data[..recv_bytes].into()).await?; } Err(e) => eprintln!("stream error: {:?}", e), } } Ok::<(), Box>(()) }); } _ => (), } } Ok(()) } ``` -------------------------------- ### Run Unreliable Datagram Receiver Example Source: https://github.com/aws/s2n-quic/blob/main/examples/unreliable-datagram/README.md Execute this command in a separate shell to start the client that receives the unreliable datagram sent by the server. ```sh cargo run --bin datagram_receiver ``` -------------------------------- ### Configure and Initialize tracing-subscriber Source: https://github.com/aws/s2n-quic/blob/main/docs/user-guide/debugging-tracelog.md Initialize a global `tracing-subscriber` in your application before starting the s2n-quic server or client. This setup uses the RUST_LOG environment variable to control logging verbosity. ```rust let format = tracing_subscriber::fmt::format() .with_level(false) // don't include levels in formatted output .with_timer(tracing_subscriber::fmt::time::uptime()) .with_ansi(false) .compact(); // Use a less verbose output format. tracing_subscriber::fmt() .with_env_filter(tracing_subscriber::EnvFilter::from_default_env()) .event_format(format) .init(); ``` -------------------------------- ### Run PQ QUIC Server Source: https://github.com/aws/s2n-quic/blob/main/examples/post-quantum/README.md Start a QUIC server with post-quantum TLS enabled. Ensure the PQ TLS flags are active before running this command. ```sh cargo run --bin pq_server ``` -------------------------------- ### IPv6 Option Layout Example 1 Source: https://github.com/aws/s2n-quic/blob/main/specs/www.rfc-editor.org/rfc/rfc2460.txt Illustrates the layout of an option with two data fields (8 and 4 octets) and its alignment requirement. This format ensures the 8-octet field starts at a multiple-of-8 offset. ```text +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Option Type=X |Opt Data Len=12| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | 4-octet field | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | | + 8-octet field + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- ``` ```text +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ | Next Header | Hdr Ext Len=1 | Option Type=X |Opt Data Len=12| +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | 4-octet field | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- | | + 8-octet field + | | +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- ``` -------------------------------- ### Entering Startup State Source: https://github.com/aws/s2n-quic/blob/main/specs/tools.ietf.org/id/draft-cardwell-iccrg-bbr-congestion-control-02.txt Initializes BBR's state to 'Startup' and sets the pacing and congestion window gains for rapid rate probing. ```pseudocode BBREnterStartup(): BBR.state = Startup BBR.pacing_gain = BBRStartupPacingGain BBR.cwnd_gain = BBRStartupCwndGain ``` -------------------------------- ### Run Kani Proofs Source: https://github.com/aws/s2n-quic/blob/main/docs/dev-guide/kani.md Executes all Kani proof harnesses within the s2n-quic-core crate. Ensure you are in the correct directory. ```sh cd quic/s2n-quic-core cargo kani --tests ``` -------------------------------- ### BBR Start ProbeBW UP Phase Source: https://github.com/aws/s2n-quic/blob/main/specs/tools.ietf.org/id/draft-cardwell-iccrg-bbr-congestion-control-02.txt Sets ack phase to STARTING, starts a round, sets the cycle timer, and transitions to ProbeBW_UP state, raising the inflight_hi slope. ```C BBRStartProbeBW_UP(): BBR.ack_phase = ACKS_PROBE_STARTING BBRStartRound() BBR.cycle_stamp = Now() /* start wall clock */ BBR.state = ProbeBW_UP BBRRaiseInflightHiSlope() ``` -------------------------------- ### Checking Startup Completion Source: https://github.com/aws/s2n-quic/blob/main/specs/tools.ietf.org/id/draft-cardwell-iccrg-bbr-congestion-control-02.txt Determines if the Startup phase is complete based on bandwidth plateau or high loss, potentially transitioning to the Drain state. ```pseudocode BBRCheckStartupDone(): BBRCheckStartupFullBandwidth() BBRCheckStartupHighLoss() if (BBR.state == Startup and BBR.filled_pipe) BBREnterDrain() ``` -------------------------------- ### BBR Start ProbeBW DOWN Phase Source: https://github.com/aws/s2n-quic/blob/main/specs/tools.ietf.org/id/draft-cardwell-iccrg-bbr-congestion-control-02.txt Resets congestion signals, sets probe_up_cnt to infinity, picks probe wait time, starts the cycle timer, sets ack phase, and starts a round. ```C BBRStartProbeBW_DOWN(): BBRResetCongestionSignals() BBR.probe_up_cnt = Infinity /* not growing inflight_hi */ BBRPickProbeWait() BBR.cycle_stamp = Now() /* start wall clock */ BBR.ack_phase = ACKS_PROBE_STOPPING BBRStartRound() BBR.state = ProbeBW_DOWN ``` -------------------------------- ### Run PQ QUIC Client Source: https://github.com/aws/s2n-quic/blob/main/examples/post-quantum/README.md Connect to a QUIC server using post-quantum TLS from the client side. This command assumes the server is already running and PQ TLS is enabled. ```sh cargo run --bin pq_client ```