Skip to content

Commit

Permalink
Quiche feature
Browse files Browse the repository at this point in the history
  • Loading branch information
politrons committed Oct 24, 2024
1 parent bebd204 commit 019b92e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 1 deletion.
42 changes: 42 additions & 0 deletions quiche-feature/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# QUIC Client-Server

This project demonstrates a simple QUIC client-server communication using the [quiche](https://github.com/cloudflare/quiche) library in Rust. The client sends multiple requests to the server over QUIC, and the server responds with acknowledgments for each stream.

## Features

- Utilizes the QUIC protocol for fast and secure UDP communication.
- Client sends up to 999 requests in parallel on bidirectional streams.
- Server handles multiple concurrent connections and responds to each request.
- Demonstrates stream-based data transfer with flow control using the `quiche` library.

## Requirements

- **Rust**: Latest stable version recommended.
- **`quiche` library**: To install and use the quiche library, refer to its [official documentation](https://github.com/cloudflare/quiche).
- **TLS Certificate**: You need a valid TLS certificate (`cert.crt`) and a private key (`cert.key`) for the server.

### Dependencies

To include `quiche` in your Rust project, add it to your `Cargo.toml`:

```toml
[dependencies]
quiche = "0.22.0"
```

## Run

Run server
```
cargo run --bin server
```
Run client
```
cargo run --bin client
```

## Benchmarks

![My image](img/output-2.png)
![My image](img/output-3.png)
![My image](img/output.png)
Binary file added quiche-feature/img/output-2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quiche-feature/img/output-3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added quiche-feature/img/output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion quiche-feature/src/bin/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {

// Maximum datagram size
const MAX_DATAGRAM_SIZE: usize = 5000;
const PACKAGE_SIZE: usize = 50;

// Create UDP socket bound to an ephemeral port
let socket = UdpSocket::bind("0.0.0.0:0")?;
Expand Down Expand Up @@ -102,7 +103,7 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
next_stream_id += 4; // Increment by 4 for bidirectional streams

// 50 KB of data to send
let data = vec![b'a'; 50 * 1024];
let data = vec![b'a'; PACKAGE_SIZE * 1024];

// Keep track of how much data has been sent on this stream
streams_data.insert(stream_id, (data.clone(), 0));
Expand Down

0 comments on commit 019b92e

Please sign in to comment.