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

Use underlying UDP transport as net.PacketConn #1

Open
paralin opened this issue Jan 17, 2018 · 6 comments
Open

Use underlying UDP transport as net.PacketConn #1

paralin opened this issue Jan 17, 2018 · 6 comments

Comments

@paralin
Copy link
Owner

paralin commented Jan 17, 2018

The multiaddr to engage KCP currently will look like:

/ip4/127.0.0.1/udp/5000/kcp/p2p/QmPeerHash

This would suggest that UDP should open a new PacketConn to port 5000 on that IP, and then pass that UDP net.PacketConn to the KCP module for handling.

Can we implement, or is there already implemented, a common go-libp2p-udp library, on top of which we can layer something like go-libp2p-kcp, and then after that, go-libp2p-smux via libp2p?

cc @whyrusleeping

@whyrusleeping
Copy link

@Stebalien would really like this. He wants to have transports be constructed iteratively, so you would start with a ip transport, instantiate it, and make a udp transport on top of that, then use the kcp one.

However, we can just do what the utp lib did, and keep track of the udp connections being created inside the transport object for kcp: https://github.com/libp2p/go-utp-transport/blob/master/utp.go#L31

@paralin
Copy link
Owner Author

paralin commented Jan 17, 2018

Alright - so, let's consider that a mid-term goal and in the short term track things locally inside this package.

With that in mind I'm going to create a go-libp2p-udp package, build the connection tracking and re-usage in there, and then basically link against it in this package as a short-term hack until we have something more dynamic.

@Stebalien
Copy link

@paralin that sounds like the best approach. Eventually, I'd like to create a registry (i.e., global map) of known packet transport types and another for known stream transports so we can just use those.

Note: I'm currently planning on changing the transport interface to the one defined in: https://github.com/libp2p/go-libp2p-transport/tree/feat/refactor. Transports will fully featured and may need to use libraries like https://github.com/libp2p/go-libp2p-stream-transport to "upgrade" their connections (e.g., add security, multiplex etc). For example, see my new branch in the TCP transport: https://github.com/libp2p/go-tcp-transport/blob/feat/refactor/tcp.go

@paralin
Copy link
Owner Author

paralin commented Feb 18, 2018

@Stebalien I'm planning to come back to this soon. Has anything changed since 22 days ago? The iterative transport construction idea seems like the right approach to me, is there anywhere in particular you need implementation work that I can help out with to get us there?

@jvsteiner
Copy link

I'd love to use this - if I can help, let me know

@Stebalien
Copy link

@paralin, @jvsteiner I'm in the process of getting the changes reviewed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants
@Stebalien @paralin @jvsteiner @whyrusleeping and others