-
-
Notifications
You must be signed in to change notification settings - Fork 412
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
Sharing the UdpSocket with another protocol #1374
Comments
Option (3): we do nothing and you fork the quinn crate, building on top of quinn-proto and quinn-udp directly.
Honestly I feel like this is niche enough that it's not obvious that we want to support a specific API for it, and quinn-proto already exists to offer this kind of low-level control. |
Might be that I explained myself poorly: forking the quinn crate and doing all the work was always meant to be done by us. I mainly created this issue to see if there is an interest for such an API in quinn and if so how would you prefer it to be done (there was a little hope we'd get a hint or two along the way, but not expected). The obvious benefit for us - if this was merged - is that we wouldn't need to continually merge with quinn on each new release, but we can live with that. The benefit for you would be the added API, more on that below.
We thought about this, but we would end up duplicating all the high level (non trivial and already tested) code, modifying only a tiny fraction. I think that is a is hard sell for anyone already using tokio.
Maybe. I started looking at quinn and quiche only recently, from what I've read so far I gathered quinn is the more preferred candidate for P2P projects. Knowing your external address is a notoriously difficult thing unless there is an infrastructure in place dedicated for it, but that's something P2P projects try to avoid having. I tried to avoid this to be brief in my previous post, but there are other advantages for such API, another big one is that prior to establishing a connection, one could use such API to create holes in NATs. Thus I think in the context of P2P applications such API is not as niche as it may appear at first glance. I'm happy to discuss this further, but I also don't want to be pushy. As I expressed, I think we know how to approach this whether it's in a fork or not. |
Have you already looked at the abstractions introduced in #1364? |
I haven't looked into it prior to you pointing it out, thank you for that. If I understand it correctly, we'd write a wrapper over (e.g.) the tokio runtime, then create our own socket wrapper for which we'd implement the |
Just an update on this if someone is interested: we were able to use the code in the abstract runtime PR #1364 and it works pretty well in that peers that were previously not able to connect to each other due to being behind a NAT now can do so. @Ralith one small change we had to do was to make the If there is anything we can improve that would increase the chance of this change being merged into your code feel free to let us know and we'll try our best. |
Whoops, we should definitely be reexporting all of those traits, since allowing downstream reimplementations is a big part of the point.
This seems well motivated to me. I'd be happy to accept a PR to the WIP branch, or I can just reimplement it myself once I get some time. |
I've now folded the proposed changes into the outstanding PR, I went for an additional |
Fixed by #1364. |
We are planning on using quinn in a peer-to-peer app where peers find each other using the BitTorrent Distributed Hash Table (DHT).
It is essential for us that the transport protocol and the DHT protocol work on the same UdpSocket. The primary advantage being that peers don't need to know their external port numbers, but instead can tell nodes in the DHT that they'll be accepting QUIC connections on the same IP:PORT address as one used for the DHT communication (
implied_port
in the DHT spec.). We have used this same technique with success in one of our other peer-to-peer projects, although there the transport protocol was uTP.Looking at the code, we came up with two possible modifications that we could do to the quinn's high level wrapper and would be interested in hearing whether any of those (or some we haven't though of yet) would be of interest to the quinn project.
The first approach would be to create a trait with the
poll_send
,poll_recv
andlocal_addr
functions and pass a generic type with this trait to thequinn::Endpoint
's constructor functions. The idea is that we could create our own "proxy" wrapper overquinn::UdpSocket
that we could pass toquinn::Endpoint::new
and thus have access to the rawstd::net::UdpSocket
. Thenquinn::EndpointInner::socket
would probably need to be wrapped in aBox
.The second approach would be to modify the
quinn::Endpoint
to provide API for sending and receiving datagrams. I imagine there could be a functionquinn::Endpoint::create_side_channel
that could create aSideChannel
object havingquinn::EndpointRef
as one of its members. TheSideChannel
object would providerecv_from
andsend_to
functions similar to the ones intokio::net::UdpSocket
. If I'm reading thequinn
s code correctly, I could "tap" toquinn::EndpointInner::drive_recv
(here in particular) to get datagrams not processed by quinn. To send a datagram I could probably just insert data intoquinn::EndpointInner::outgoing
and callwake
on thedriver
.Pros and Cons
The ratio of pros/cons is probably non indicative as some of them may be trivial and only listed for completeness.
For the proxy wrapper approach:
quinn::EndpointInner::socket
will need to be wrapped in aBox
.quinn::Connection
and itself. I have a feeling this may interfere with quinn's congestion timers.Or perhaps there is another approach? I noticed there is
quinn::Connection::send_datagram
but we need API for sending and receiving datagrams even if there is no connection established yet.The text was updated successfully, but these errors were encountered: