cloudflare / quiche

🥧 Savoury implementation of the QUIC transport protocol and HTTP/3
https://docs.quic.tech/quiche/
BSD 2-Clause "Simplified" License
9.1k stars 684 forks source link

WebTransport support #1114

Open notedit opened 2 years ago

notedit commented 2 years ago

Hi, Chrome M97 will support WebTransport( https://chromestatus.com/roadmap ), Does quiche support WebTransport or will support WebTransport?

kalradivyanshu commented 2 years ago

Chrome has a webserver sample that uses python3 and aioquic to support WebTransport (https://github.com/GoogleChrome/samples/tree/gh-pages/webtransport). Would be great if quiche could support webtransport, or if someone could guide me on how to use quiche to build a WebTransport server.

LPardue commented 2 years ago

Hey.

Here's been a few iterations of the WebTransport protocol, I expect that to keep happening while the details are all figured out in the IETF. So the question is, what version are you targeting?

I'd guess its the version of WebTransport over HTTP/3 that's based on https://datatracker.ietf.org/doc/html/draft-ietf-masque-h3-datagram-05, which changes the QUIC DATAGRAM format from what we have implemented today in quiche. And that format is likely to change again in the near future due to IETF work. The good news is that as a workaround, you can add context ID handling in application space without needing any changes in quiche.

The rest of WebTransport is also mostly the responsibility of applications using quiche. I have an old branch that implemented an echo service using QuicTransport (now long deprecated) on client and server in about additional 450 lines. I suspect similar changes would be needed to add WebTransport over HTTP/3, although I think it would be simpler than my branch because you don't have to define an entirely new ALPN handler (just reuse HTTP/3).

The main challenge you'll have to implementing WebTransport though is handling the Capsule protocol, which requires variable-length integer handling. quiche's internal code for handling this, octets, is not currently public. For experimentation you could force that in fork, or just reimplement it.

notedit commented 2 years ago

@LPardue Thanks,I will check your QuicTransport branch. I did not know the Chrome's WebTransport version yet, Maybe the version with the M97.

alishir commented 2 years ago

@LPardue Thanks for the detailed explanation. According to the last paragraph in your above answer, you said that octets is a private crate, but there is octets.rs in the quiche source tree. Does the octets.rs in the source tree differ from the octets package in your answer?

LPardue commented 2 years ago

Octets is now available as a crate in https://crates.io/crates/octets

alishir commented 2 years ago

Thanks a lot.

danielblignaut commented 1 year ago

+1 . Can anybody share an example of this if they've managed to implement it.

btwiuse commented 1 year ago

+1 . Can anybody share an example of this if they've managed to implement it.

xflagstudio/requiem is using a forked quiche with webtransport support:

https://github.com/lyokato/quiche/commits/0.12.0-webtransport-support

danielblignaut commented 1 year ago

@btwiuse I've seen that but it seems incomplete? I get compile time errors in the Rust code

D1plo1d commented 1 year ago

@danielblignaut I'm running their example without compile errors (although I haven't figured out how to connect a client yet). In order to get a successful compile I ran:

git clone https://github.com/lyokato/quiche.git
cd quiche/quiche
git checkout 0.12.0-webtransport-support
git submodule init
git submodule update
cargo run --example http3-server

~~For reference this is the example I'm running: https://github.com/lyokato/quiche/blob/0.12.0-webtransport-support/quiche/examples/http3-server.rs~~

Edit: examples/http3-server does not support Web Transport. See my comment bellow for a working solution.

D1plo1d commented 1 year ago

After a bit of trial and error I've gotten a Web Transport connection from Quiche to Chrome to send and receive data: https://github.com/D1plo1d/quiche/blob/webtransport-example/quiche/examples/webtransport-server.rs

The pull request to merge this into the webtransport branch can be found here: https://github.com/lyokato/quiche/pull/1

With regards to my setup, I'm using Chrome version 106.0.5249.119 (a recent release)

PS. For anyone coming across this later examples/http3-server I mentioned earlier does not support WebTransport. Use my examples/webtransport-server example to connect WebTransport sessions.

ayasuda-may commented 1 year ago

PS. For anyone coming across this later examples/http3-server I mentioned earlier does not support WebTransport. Use my examples/webtransport-server example to connect WebTransport sessions.

Those of us have similar needs, this branch is actively maintained, adding extra supports such as ffi based on the latest draft. The goal is to compile a final version to PR the original when the requirement is met.

Thanks but the working branch seems to be outdated (0.12.0). Please kindly help us to test, or rather PR this branch if it seems fitting @D1plo1d

D1plo1d commented 1 year ago

@mayniacs I've not been able to get a WebTransport connection to Chrome working with your branch so far - I am by no means an expert on Quic though. Would it be possible for you to add an example that demonstrates how to accept WebTransport connections?

n8o commented 1 year ago

I took the WebTransport implementation from lyokato and example from @D1plo1d merged them together and rebased it on top of master in cloudflare/quiche. I originally wasn't going to update it to master. I needed c/c++ support so i added ffi support. But it turns out that sockaddr in rust changed recently and i either needed to port the updated code from master to the older version or rebase it on master. so i went ahead and rebased it.

I didn't look at ayasuda-may/quiche implementation because of the above comments about the example not working. also the ffi stuff was incomplete imo.

This is my first time writing rust code so I haven't created a PR yet. Any help or advice would be appreciated.

List of changes:

You can view the changes here: https://github.com/n8o/quiche

redoriental commented 1 year ago

https

I used your branch, but it seems to be unable to trigger connection closure and flow closure

n8o commented 4 months ago

Can you create an example I can test against?

brentmjohnson commented 1 month ago

@n8o just tried your implementation and all tests defined in webtransport-server-public passed on edge v126 - excited to start experimenting! thanks to all others that have contributed as well.