quiche icon indicating copy to clipboard operation
quiche copied to clipboard

WebTransport support

Open notedit opened this issue 2 years ago • 17 comments

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

notedit avatar Dec 11 '21 08:12 notedit

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.

kalradivyanshu avatar Dec 11 '21 23:12 kalradivyanshu

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.

LPardue avatar Dec 14 '21 00:12 LPardue

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

notedit avatar Dec 15 '21 11:12 notedit

@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?

alishir avatar Mar 29 '22 03:03 alishir

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

LPardue avatar Apr 08 '22 11:04 LPardue

Thanks a lot.

alishir avatar Apr 08 '22 13:04 alishir

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

danielblignaut avatar Jul 08 '22 14:07 danielblignaut

+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

btwiuse avatar Oct 06 '22 03:10 btwiuse

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

danielblignaut avatar Oct 06 '22 11:10 danielblignaut

@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 avatar Nov 08 '22 18:11 D1plo1d

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.

D1plo1d avatar Nov 09 '22 16:11 D1plo1d

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

ayasuda-may avatar Nov 21 '22 07:11 ayasuda-may

@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?

D1plo1d avatar Nov 26 '22 19:11 D1plo1d

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:

  • Added WT support based from lyokato
  • Added WT example from D1plo1d
  • Added WT ffi
  • Fixed Unit Tests
  • Tested only WT example and passed.

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

n8o avatar Mar 17 '23 14:03 n8o

https

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

redoriental avatar May 26 '23 07:05 redoriental

Can you create an example I can test against?

n8o avatar Feb 11 '24 18:02 n8o