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

Binary packed network addresses #11

Open
jbenet opened this issue Jun 2, 2014 · 3 comments
Open

Binary packed network addresses #11

jbenet opened this issue Jun 2, 2014 · 3 comments

Comments

@jbenet
Copy link
Owner

jbenet commented Jun 2, 2014

Consider url network addresses like:

tcp4://127.0.0.1:1234
udp4://10.20.30.40:5060
ws://1.2.3.4:5678
tcp6://[1fff:0:a88:85a3::ac1f]:8001

How best to binary pack them? Is there a standard for this? These should be storable in 7 bytes for IPv4 (not 20), and 19 bytes for ipv6 (not 35).

If not, perhaps:

<1 byte proto><4 or 16 byte ip><2 byte port>

Or, if we want encapsulation generality:

(<1 byte proto><n byte addr>)+
<1 byte ipv4 code><4 byte ipv4 addr><1 byte udp code><2 byte udp port>
<1 byte ipv6 code><16 byte ipv6 addr><1 byte tcp code><2 byte tcp port>

Which is nice, because it stacks well.

Back-translating with a better hierarchical approach (let's not get too crazy now...) gives us:

(/<addr str code>/<addr str rep>)+
/ip4/<ipv4 str addr>/udp/<udp int port>
/ip6/<ipv6 str addr>/tcp/<tcp int port>

Rather than:

udp4://<ipv4 addr>:<udp port>
tcp6://[<ipv6 addr>]:<tcp port>
@jbenet
Copy link
Owner Author

jbenet commented Jun 2, 2014

Bittorrent just concats ip + port: https://github.com/bencevans/node-compact2string
It doesn't handle protocol at all, try both tcp + udp.

@jbenet
Copy link
Owner Author

jbenet commented Jun 9, 2014

Fleshed out the node api: https://github.com/jbenet/node-multiaddr

@jbenet
Copy link
Owner Author

jbenet commented Jun 11, 2014

Implemented + published on npm.

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

1 participant