Skip to content
Explore the learning library ☟
◎ Google Translate
SanchitGurukulTechnology · Education · Innovation Take a quiz

How to Build a QUIC and HTTP/3 Lab on Ubuntu with Python and aioquic


QUIC and HTTP/3 are now established Internet protocols used by modern browsers, content-delivery platforms, cloud services, and application-delivery systems.

QUIC is defined in RFC 9000 and runs over UDP.

It incorporates:

  • Secure connection establishment using TLS 1.3
  • Multiple independent streams
  • Loss recovery
  • Congestion control
  • Connection migration support
  • Connection identifiers

HTTP/3 runs HTTP semantics over QUIC instead of TCP.

One of QUIC’s important advantages is that packet loss affecting one stream does not necessarily block progress on unrelated streams.

This avoids the cross-stream transport-layer head-of-line blocking associated with HTTP/2 over a single TCP connection.

In this lab, we will build a practical HTTP/3 environment on Ubuntu using Python and aioquic.

You will learn how to:

  • Create an isolated Python environment
  • Install aioquic
  • Generate a local TLS certificate
  • Run an HTTP/3 server
  • Test it with an HTTP/3 client
  • Inspect QUIC traffic in Wireshark
  • Record TLS secrets
  • Generate QLOG traces
  • Troubleshoot common QUIC problems
Python aioquic HTTP3 Lab Architecture

Understand the Lab Before Building It

QUIC, TLS and HTTP/3

A simplified protocol relationship is:

HTTP3 Protocol Stack

QUIC should not be described simply as TCP replaced by UDP.

QUIC provides transport functions that TCP traditionally provides, including:

  • Reliable stream delivery
  • Loss recovery
  • Congestion control
  • Flow control

but implements them in a different protocol architecture over UDP.

What Is aioquic?

aioquic is a Python implementation of:

  • QUIC
  • TLS 1.3 integration
  • HTTP/3

The project also supports features such as:

  • IPv4 and IPv6
  • Connection migration
  • TLS secret logging
  • QLOG
  • HTTP/3 server push
  • WebSocket bootstrapping
  • QUIC datagrams

At the time of this technical review, the current aioquic release is 1.3.0 and requires Python 3.10 or newer.


Build the Ubuntu HTTP/3 Lab

Lab Directory

We will use:

~/h3lab

with this structure:

Output / Result
h3lab/
├── certs/
├── logs/
├── www/
└── venv/

Step 1 — Check Python

Check the installed Python version:

Command
python3 --version

Use Python 3.10 or newer for current aioquic releases.

Step 2 — Install Required Ubuntu Packages

Update the package information:

Command
sudo apt update

Install Python and supporting packages:

Command
sudo apt install python3 python3-venv python3-pip libssl-dev python3-dev openssl

The OpenSSL development headers are particularly useful if aioquic or one of its dependencies needs to be built locally.

Step 3 — Create the Lab Directories

Create the project structure:

Command
mkdir -p ~/h3lab/certs ~/h3lab/logs ~/h3lab/www
cd ~/h3lab

Step 4 — Create a Python Virtual Environment

Create the virtual environment:

Command
python3 -m venv ~/h3lab/venv

Activate it:

Command
source ~/h3lab/venv/bin/activate

Your command prompt will normally show the active environment.

For example:

Output / Result
(venv) user@ubuntu:~/h3lab$

Upgrade pip:

Command
python -m pip install --upgrade pip

Install aioquic:

Command
python -m pip install aioquic

Verify the installation:

Command
python -m pip show aioquic

Create a TLS Certificate and Run HTTP/3

HTTP/3 requires secure QUIC operation.

For a local lab, we can use a self-signed certificate.

Step 1 — Create a Local Certificate

Generate a private key and certificate:

Command
openssl req -x509 -newkey rsa:2048 -nodes -days 30 -keyout ~/h3lab/certs/key.pem -out ~/h3lab/certs/cert.pem -subj "/CN=localhost" -addext "subjectAltName=DNS:localhost,IP:127.0.0.1"

Verify the certificate:

Command
openssl x509 -in ~/h3lab/certs/cert.pem -text -noout

Look for:

Output / Result
X509v3 Subject Alternative Name:
    DNS:localhost, IP Address:127.0.0.1

Step 2 — Download the Official aioquic Examples

Instead of maintaining a large custom HTTP/3 implementation that may become incompatible with future aioquic releases, use the project’s current official examples as the base lab.

Clone the repository:

Command
cd ~/h3lab
git clone https://github.com/aiortc/aioquic.git

Move into the project:

Command
cd ~/h3lab/aioquic

aioquic currently provides example programs including:

  • examples/http3_server.py
  • examples/http3_client.py

These examples directly demonstrate the project’s supported QUIC and HTTP/3 APIs.

Step 3 — Start the HTTP/3 Server

Run the official HTTP/3 server:

Command
python examples/http3_server.py --certificate ~/h3lab/certs/cert.pem --private-key ~/h3lab/certs/key.pem

The server normally listens on UDP port 4433 unless another port is configured.

Keep this terminal open.

Step 4 — Confirm UDP Is Listening

Open another terminal and check UDP listeners:

Command
ss -ulnp

Look for the Python process listening on the HTTP/3 test port.


Test the HTTP/3 Server

Activate the same virtual environment in another terminal:

Command
source ~/h3lab/venv/bin/activate
cd ~/h3lab/aioquic

Basic HTTP/3 Request

Use the official client:

Command
python examples/http3_client.py --insecure https://localhost:4433/

The --insecure option is appropriate here only because this is a controlled lab using a self-signed certificate.

For a trusted certificate, certificate validation should remain enabled.

Include Response Headers

Check the options supported by the installed client:

Command
python examples/http3_client.py --help

The official client provides options for functions such as:

  • Request output
  • Certificate handling
  • QLOG
  • TLS secrets
  • Session tickets
  • 0-RTT testing

Test a POST Request

The official client supports sending request data.

Check:

Command
python examples/http3_client.py --help

Then use the data option supported by your installed release to test the server’s echo endpoint.

The official aioquic demo application includes an HTTP POST echo example.

aioquic HTTP3 Request Flow

Observe QUIC with Wireshark and QLOG

One of the main advantages of building a lab is the ability to observe the protocol.

Capture QUIC Traffic

Start Wireshark and capture on the interface carrying the HTTP/3 traffic.

For localhost testing, use the loopback interface.

A useful display filter is:

ConfigurationTEXT
udp.port == 4433

You should see QUIC traffic between the client and server.

Useful QUIC Events to Observe

Look for:

  • Initial packets
  • Handshake packets
  • 1-RTT packets
  • Connection IDs
  • ACK frames
  • STREAM frames
  • Loss and retransmission behavior

TLS Secrets

aioquic supports TLS secret logging.

The current official HTTP/3 client includes a secrets-log option.

Check the exact syntax:

Command
python examples/http3_client.py --help

Configure the client to write TLS secrets to:

~/h3lab/logs/secrets.log

Then configure Wireshark to use that file under:

Edit → Preferences → Protocols → TLS

Set the TLS key-log filename to the generated secrets file.

Wireshark can then use the captured TLS secrets to decrypt supported QUIC traffic.

QLOG

aioquic also supports QUIC event logging in QLOG format.

The official example client provides QUIC logging support.

QLOG can help analyze:

  • Handshake timing
  • Packet transmission
  • ACK processing
  • Packet loss
  • Recovery behavior
  • Streams
  • Congestion-control behavior

QLOG files can be inspected using compatible visualization tools such as qvis.


Understand 0-RTT, Streams and QUIC Behavior

QUIC Does Not Guarantee 0-RTT on Every Connection

The phrase “QUIC provides a 0-RTT handshake” can be misleading.

An initial QUIC connection normally requires cryptographic connection establishment.

0-RTT application data can be used in supported session-resumption scenarios when:

  • The client has previously connected
  • Appropriate session state exists
  • The server accepts early data

0-RTT also has important replay-security considerations.

It should therefore be used only for operations that are safe if replayed.

QUIC Stream Multiplexing

QUIC supports multiple streams within one connection.

Packet loss associated with one stream does not necessarily prevent unrelated streams from making progress.

This differs from HTTP/2 over TCP, where loss at the TCP transport level can temporarily delay all HTTP/2 streams carried by that connection.

Connection Migration

QUIC uses connection IDs that can allow a connection to survive certain network-address changes.

For example, a client may be able to move between network paths without creating a completely new application connection.

However, migration support and policy depend on the implementation and deployment.


Secure, Tune and Troubleshoot the Lab

Firewall

If the client runs on another machine, ensure the lab’s UDP port is permitted through:

  • Ubuntu firewall
  • Cloud security group
  • Network firewall
  • Router ACL

For this lab, the important transport is:

UDP 4433

Do not assume that allowing TCP 4433 also allows UDP 4433.

Check the Listener

Verify UDP listeners:

Command
ss -ulnp

Test Basic IP Connectivity

For a remote server, first confirm that the client can reach the server network.

Then troubleshoot UDP separately.

Certificate Errors

Certificate failures may be caused by:

  • Untrusted self-signed certificate
  • Hostname mismatch
  • Missing SAN
  • Expired certificate
  • Incorrect system time

For lab testing, --insecure can bypass verification.

For real deployments, correct the certificate instead.

HTTP/3 Negotiation Failure

Both sides need compatible HTTP/3 ALPN values.

The aioquic HTTP/3 examples configure the appropriate HTTP/3 ALPN identifiers internally.

If you create a custom implementation, use the HTTP/3 ALPN constants provided by aioquic rather than inventing an ALPN string.

Import Errors

Verify the active environment:

Command
which python

Check aioquic:

Command
python -m pip show aioquic

If the environment is not active:

Command
source ~/h3lab/venv/bin/activate

Capture Shows UDP but HTTP/3 Still Fails

If UDP packets reach the server but HTTP/3 does not complete, investigate:

  1. QUIC Initial exchange
  2. TLS handshake
  3. Certificate validation
  4. ALPN negotiation
  5. QUIC transport parameters
  6. HTTP/3 SETTINGS
  7. Application behavior
Python HTTP3 Lab Troubleshooting Flow

Do Not Tune UDP Buffers Too Early

Linux UDP buffer tuning can be useful under high packet rates or large bandwidth-delay products.

For a simple lab, default operating-system values are usually sufficient.

Measure first before changing kernel networking parameters.


Extend the Lab

Once the basic environment works, the same lab can be expanded.

Test Packet Loss and Delay

Linux traffic-control tools can be used in a controlled lab to introduce:

  • Latency
  • Packet loss
  • Reordering
  • Jitter

This allows you to observe QUIC recovery behavior.

Test Session Resumption and 0-RTT

The official aioquic client includes session-ticket and zero-RTT functionality.

Use these capabilities to compare:

  • Initial connection
  • Resumed connection
  • Early data

Remember that early data has replay considerations.

Test QUIC Version 2

aioquic includes support for QUIC protocol-version negotiation capabilities.

Use the current client help to identify the version-selection options available in your release.

Experiment with QUIC Datagrams

QUIC DATAGRAM support is useful when an application requires unreliable messages within a QUIC connection.

This differs from normal reliable QUIC streams.

Build a Custom Python Application

After understanding the official examples, you can start building custom functionality such as:

  • JSON APIs
  • Authentication
  • File transfer
  • Metrics
  • WebSockets over HTTP/3
  • WebTransport experiments

Starting from the official example structure is safer than copying an old custom implementation because aioquic APIs can evolve.


Key Takeaways and Summary

Key Takeaways

  1. QUIC runs over UDP and provides transport functions such as streams, loss recovery and congestion control.
  2. QUIC integrates TLS 1.3 into connection establishment.
  3. HTTP/3 runs HTTP semantics over QUIC.
  4. QUIC avoids transport-level head-of-line blocking between independent streams.
  5. 0-RTT is an optional session-resumption capability, not something every new connection automatically uses.
  6. aioquic provides a Python implementation of QUIC and HTTP/3.
  7. Current aioquic releases require Python 3.10 or newer.
  8. A Python virtual environment keeps the lab isolated.
  9. HTTP/3 testing requires UDP connectivity.
  10. Wireshark TLS secrets and QLOG provide complementary troubleshooting information.
  11. Self-signed certificates are suitable for controlled labs but not production identity validation.
  12. The official aioquic examples are a good foundation for custom HTTP/3 development.

Summary

In this lab, we built an Ubuntu environment for learning QUIC and HTTP/3 with Python and aioquic.

The workflow was:

  1. Prepare Ubuntu and Python.
  2. Create an isolated virtual environment.
  3. Install aioquic.
  4. Generate a local TLS certificate.
  5. Run the official HTTP/3 server.
  6. Test it using the aioquic HTTP/3 client.
  7. Capture QUIC traffic.
  8. Use TLS key logging and QLOG for deeper analysis.
  9. Troubleshoot UDP, TLS, QUIC and HTTP/3 separately.
  10. Prepare the environment for more advanced experiments.

The most important lesson is that HTTP/3 troubleshooting should be performed in layers.

A failed web request does not automatically mean the HTTP/3 application is broken.

The problem may instead be:

  • UDP reachability
  • QUIC negotiation
  • TLS validation
  • ALPN
  • HTTP/3 setup
  • Application logic

A controlled aioquic lab makes each of those layers easier to observe and understand.


SanchitGurukul Static Resources

Official External References

Your feedback matters

Was this post helpful?

0 reactions

SanchitGurukul — Technology • Education • Innovation

Discussion

0 approved comments

No approved comments yet. You can start the discussion below.

Leave a Comment

No login is required. Name and email are used for moderation/security. Your email is never displayed publicly. All comments require administrator approval.

This field is not used to determine whether a comment is safe.

Plain text only. File uploads, scripts, executable code, abuse and spam are not accepted.


Discover more from SanchitGurukul

Subscribe to get the latest posts sent to your email.

Keep exploring

Related guides

Namaste! I’m SG Saarthi 👋Need help learning or finding something?