Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUIC Dgram Support #35

Open
CMCDragonkai opened this issue Jul 13, 2023 · 1 comment
Open

QUIC Dgram Support #35

CMCDragonkai opened this issue Jul 13, 2023 · 1 comment
Labels
development Standard development r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices

Comments

@CMCDragonkai
Copy link
Member

CMCDragonkai commented Jul 13, 2023

Specification

The quiche library supports dgrams. This means the dgrams run on top of an existing QUIC connection. In contrast to streams, the dgrams end up being stateless. It's useful if we are virtualising a connection on top of QUIC to avoid double-congestion control.

Suppose we want to do decentralised relaying for PK agents. Then in order to relay another QUIC connection (and their associated streams), we would pass through the underlying UDP dgrams and inject as dgrams on an existing QUIC connection.

At the moment, I'm unsure how to exactly go about this. Suppose agents A, B and C where B is relaying the connection between A and C.

One way is for B to simply propagate the dgrams it receives from A and just proxy it to C. In that sense, there's no actual need for QUIC dgram support. B is just a network proxy like we used to do in PK's network domain.

Alternatively, B is connected to A and C over a QUIC connection. However the QUIC connection acts like a "lower layer". Then when A connects to C, it creates another QUIC connection, but this is done on top of the lower layer QUIC connection. In order to expose this, the lower QUIC connection must use the QUIC dgrams to pass through.

In that sense, it's possible for this library to expose the dgram support, and "recursively" use QUIC on top of QUIC.

Right now QUICServer and QUICClient both require QUICSocket. The QUICSocket hardcodes the usage of node's dgram module using UDP. If QUICSocket can be made more generic, it would be possible to supply it with a QUICVirtualSocket, where the underlying strategy could be to use the UDP dgrams, or an existing QUICConnection's dgram system.

One major important difference is that QUICConnection's dgrams would have no use for things like the address. The QUICConnection's dgrams is already connected, and it's not possible to send it elsewhere. That would mean, that is up to the bottom layer quic connection to receive the entire encapsulated UDP dgram and then process it appropriately.

This is how we could create an "overlay" network with QUIC.

However would this really be needed to do decentralised relaying for Polykey, or can just standard transparent networking proxying of the UDP dgram packets be suitable for decentralised relaying?

Note that Tailscale often needs to use relays, but in their case, their relays are done over TCP. So they are encapsulating wireguard (UDP packets) as TCP. I think it ends up looking like HTTP too, which allows them to bypass some corporate firewalls. If this QUIC library was built so that it can re-use any underlying "virtual socket", that would make it easier to run this QUIC library on top of whatever underlying socket system (whether another QUIC connection, or tailscale like DERP thing).

Additional context

Tasks

  1. ...
  2. ...
  3. ...
@CMCDragonkai CMCDragonkai added the development Standard development label Jul 13, 2023
@CMCDragonkai CMCDragonkai added the r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices label Aug 13, 2024
@ilkkapoutanen-61n
Copy link

Hi! I find myself in need of QUIC datagram support in Node.js, but also in the unenviable position of being quite unfamiliar with the details of QUIC, and not much better at Rust. Anyway, after poking around in the js-quic source, it seems that the napi mod already wraps the dgram_send* and dgram_recv* functions for a connection. Would it be possible to "just" expose these through the TS QUICConnection API in order to have basic dgram support?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Standard development r&d:polykey:core activity 4 End to End Networking behind Consumer NAT Devices
Development

No branches or pull requests

2 participants