Convert Figma logo to code with AI

litespeedtech logolsquic

LiteSpeed QUIC and HTTP/3 Library

1,532
332
1,532
73

Top Related Projects

4,046

Cross-platform, C implementation of the IETF QUIC protocol, exposed to C, C++, C# and Rust.

1,673

QUIC and HTTP/3 implementation in Python

1,150

ngtcp2 project is an effort to implement IETF QUIC protocol

10,041

A QUIC implementation in pure Go

Quick Overview

LiteSpeed QUIC (LSQUIC) is an open-source implementation of the QUIC transport protocol and HTTP/3. It is developed by LiteSpeed Technologies and provides a high-performance, user-space library for building QUIC-enabled applications and servers.

Pros

  • High-performance implementation optimized for speed and efficiency
  • Supports both client and server-side QUIC functionality
  • Regularly updated to comply with the latest QUIC and HTTP/3 specifications
  • Extensive documentation and examples for easy integration

Cons

  • Primarily focused on C/C++ development, which may limit accessibility for developers using other languages
  • Requires a deeper understanding of low-level networking concepts
  • May have a steeper learning curve compared to higher-level networking libraries

Code Examples

  1. Initializing a QUIC engine:
struct lsquic_engine_settings settings;
lsquic_engine_init_settings(&settings, LSENG_SERVER);
struct lsquic_engine *engine = lsquic_engine_new(LSENG_SERVER, &settings);
  1. Creating a QUIC connection:
lsquic_conn_t *conn = lsquic_engine_connect(engine, LSQVER_I001,
                                            local_addr, peer_addr,
                                            (void *) peer_ctx, NULL, NULL, 0,
                                            NULL, 0, NULL, 0);
  1. Sending data on a QUIC stream:
lsquic_stream_t *stream = lsquic_conn_get_stream(conn, stream_id);
lsquic_stream_write(stream, data, data_len);
lsquic_stream_flush(stream);

Getting Started

To get started with LSQUIC:

  1. Clone the repository:

    git clone https://github.com/litespeedtech/lsquic.git
    
  2. Build the library:

    cd lsquic
    cmake .
    make
    
  3. Include the LSQUIC headers in your project:

    #include <lsquic.h>
    
  4. Link against the LSQUIC library when compiling your application:

    gcc -o your_app your_app.c -llsquic
    

For more detailed instructions and examples, refer to the documentation in the repository.

Competitor Comparisons

4,046

Cross-platform, C implementation of the IETF QUIC protocol, exposed to C, C++, C# and Rust.

Pros of msquic

  • More active development with frequent updates and contributions
  • Extensive documentation and examples for easier implementation
  • Cross-platform support for Windows, Linux, and macOS

Cons of msquic

  • Larger codebase, potentially more complex to understand and maintain
  • Primarily focused on Windows ecosystem, which may not be ideal for all use cases
  • Steeper learning curve for developers not familiar with Microsoft technologies

Code Comparison

msquic:

QUIC_STATUS
QUIC_API
MsQuicOpenVersion(
    _In_ uint32_t Version,
    _Out_ _Pre_defensive_ const QUIC_API_TABLE** QuicApi
    )

lsquic:

int
lsquic_engine_init (const struct lsquic_engine_settings *,
                    unsigned flags);

The code snippets show different initialization approaches. msquic uses a version-based API initialization, while lsquic uses a simpler engine initialization with settings and flags.

Both libraries provide QUIC protocol implementation, but msquic offers broader platform support and more extensive documentation. lsquic may be simpler to integrate for certain projects, especially those not tied to the Microsoft ecosystem. The choice between them depends on specific project requirements and target platforms.

1,673

QUIC and HTTP/3 implementation in Python

Pros of aioquic

  • Written in pure Python, making it more accessible and easier to integrate with Python projects
  • Supports both client and server implementations of QUIC and HTTP/3
  • Designed to work seamlessly with asyncio, providing non-blocking I/O operations

Cons of aioquic

  • May have lower performance compared to lsquic, which is written in C
  • Less mature and potentially less battle-tested than lsquic
  • Limited platform support compared to lsquic's broader compatibility

Code Comparison

aioquic example:

async def run_client(configuration: QuicConfiguration):
    async with connect("localhost", 4433, configuration=configuration) as client:
        await client.ping()

lsquic example:

static int
http_client_on_write(struct lsquic_stream *stream, lsquic_stream_ctx_t *st_h)
{
    struct http_client_ctx *const ctx = (void *) st_h;
    return send_headers(stream, ctx);
}

Both libraries provide APIs for QUIC functionality, but aioquic offers a more Pythonic interface with async/await syntax, while lsquic uses a C-style callback approach. The aioquic example demonstrates a simple client connection, while the lsquic example shows a write callback function for an HTTP client.

1,150

ngtcp2 project is an effort to implement IETF QUIC protocol

Pros of ngtcp2

  • More actively maintained with frequent updates
  • Broader focus on QUIC protocol implementation, not just limited to HTTP/3
  • Extensive test suite and documentation

Cons of ngtcp2

  • Steeper learning curve due to its lower-level implementation
  • May require more integration work for specific use cases
  • Less optimized for production environments out of the box

Code Comparison

ngtcp2:

ngtcp2_conn *conn;
ngtcp2_conn_client_new(&conn, dcid, &params, &callbacks, NULL);
ngtcp2_conn_handshake(conn, buf, &pktlen, NULL, 0, timestamp);

lsquic:

lsquic_engine_t *engine;
lsquic_engine_new(LSENG_SERVER, &engine_api);
lsquic_engine_connect(engine, version, local_sa, peer_sa, NULL, ssl_ctx, NULL, 0, NULL, 0, NULL, 0);

Summary

ngtcp2 offers a more comprehensive QUIC implementation with active development and extensive testing. It's suitable for projects requiring fine-grained control over the QUIC protocol. However, it may require more effort to integrate and optimize for specific use cases.

lsquic, developed by LiteSpeed Technologies, is more focused on HTTP/3 and optimized for production environments. It provides an easier integration path but may be less flexible for non-HTTP/3 QUIC applications.

Choose ngtcp2 for broader QUIC protocol support and active development, or lsquic for a more production-ready HTTP/3 implementation with easier integration.

10,041

A QUIC implementation in pure Go

Pros of quic-go

  • Written in Go, offering better cross-platform compatibility and easier integration with Go-based projects
  • More active community and frequent updates, potentially leading to faster bug fixes and feature additions
  • Extensive documentation and examples, making it easier for developers to get started and implement QUIC

Cons of quic-go

  • May have slightly lower performance compared to lsquic, which is written in C
  • Less mature and battle-tested in production environments compared to lsquic
  • Potentially higher memory usage due to Go's garbage collection

Code Comparison

lsquic (C):

lsquic_conn_t *conn = lsquic_engine_connect(engine, version, &local_sa, &peer_sa,
                                            (void *) peer_ctx, ssl_ctx,
                                            NULL, 0, NULL, 0, NULL, 0);

quic-go (Go):

session, err := quic.DialAddr(addr, tlsConf, config)
if err != nil {
    return nil, err
}

The code snippets demonstrate the difference in connection establishment between the two libraries. lsquic requires more parameters and configuration, while quic-go offers a more straightforward API. This reflects the general design philosophy of each library, with quic-go prioritizing ease of use and lsquic focusing on fine-grained control and performance.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Linux and MacOS build status Windows build status FreeBSD build status Documentation Status

LiteSpeed QUIC (LSQUIC) Library README

Description

LiteSpeed QUIC (LSQUIC) Library is an open-source implementation of QUIC and HTTP/3 functionality for servers and clients. Most of the code in this distribution is used in our own products: LiteSpeed Web Server, LiteSpeed ADC, and OpenLiteSpeed.

Currently supported QUIC versions are v1, v2, Internet-Draft versions 29, and 27; and the older "Google" QUIC versions Q043, Q046, an Q050.

Standard Compliance

LiteSpeed QUIC is mostly compliant to the follow RFCs:

  • RFC 9000 QUIC: A UDP-Based Multiplexed and Secure Transport
  • RFC 9001 Using TLS to Secure QUIC
  • RFC 9002 QUIC Loss Detection and Congestion Control
  • RFC 9114 HTTP/3
  • RFC 9204 QPACK: Field Compression for HTTP/3

QUIC protocol extensions

The following QUIC protocol extensions are implemented:

Documentation

Documentation is available at https://lsquic.readthedocs.io/en/latest/.

In addition, see example programs for API usage and EXAMPLES.txt for some compilation and run-time options.

Requirements

To build LSQUIC, you need CMake, zlib, and BoringSSL. The example program uses libevent to provide the event loop.

Building BoringSSL

BoringSSL is not packaged; you have to build it yourself. The process is straightforward. You will need go installed.

  1. Clone BoringSSL by issuing the following command:
git clone https://boringssl.googlesource.com/boringssl
cd boringssl

You may need to install pre-requisites like zlib and libevent.

  1. Use specific BoringSSL version
git checkout 9fc1c33e9c21439ce5f87855a6591a9324e569fd

Or, just try the latest master branch.

  1. Compile the library
cmake . &&  make

Remember where BoringSSL sources are:

BORINGSSL=$PWD

If you want to turn on optimizations, do

cmake -DCMAKE_BUILD_TYPE=Release . && make

If you want to build as a library, (necessary to build lsquic itself as as shared library) do:

cmake -DBUILD_SHARED_LIBS=1 . && make

Building LSQUIC Library

LSQUIC's http_client, http_server, and the tests link BoringSSL libraries statically. Following previous section, you can build LSQUIC as follows:

  1. Get the source code
git clone https://github.com/litespeedtech/lsquic.git
cd lsquic
git submodule update --init
  1. Compile the library

Statically:

# $BORINGSSL is the top-level BoringSSL directory from the previous step
cmake -DBORINGSSL_DIR=$BORINGSSL .
make

As a dynamic library:

cmake -DLSQUIC_SHARED_LIB=1 -DBORINGSSL_DIR=$BORINGSSL .
make
  1. Run tests
make test

Building with Docker

The library and the example client and server can be built with Docker.

Initialize Git submodules:

cd lsquic
git submodule update --init

Build the Docker image:

docker build -t lsquic .

Then you can use the examples from the command line. For example:

sudo docker run -it --rm lsquic http_client -s www.google.com  -p / -o version=h3
sudo docker run -p 12345:12345/udp -v /path/to/certs:/mnt/certs -it --rm lsquic http_server -c www.example.com,/mnt/certs/chain,/mnt/certs/key

Platforms

The library has been tested on the following platforms:

  • Linux
    • i386
    • x86_64
    • ARM (Raspberry Pi 3)
  • FreeBSD
    • i386
  • MacOS
    • x86_64
  • iOS
    • ARM
  • Android
    • ARM
  • Windows
    • x86_64

Get Involved

Do not hesitate to report bugs back to us. Even better, send us fixes and improvements!

Have fun,

LiteSpeed QUIC Team.

Copyright (c) 2017 - 2021 LiteSpeed Technologies Inc