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

multistream-select specification isn't very clear #24

Open
dhuseby opened this issue Aug 19, 2023 · 2 comments
Open

multistream-select specification isn't very clear #24

dhuseby opened this issue Aug 19, 2023 · 2 comments

Comments

@dhuseby
Copy link

dhuseby commented Aug 19, 2023

Reading the spec I noticed that the code blocks in the beginning show a pseudo-wire protocol representation by just showing the contents of each message without explicitly showing the varint message length and the newline suffix. For instance this example is like that:

```
> /multistream/1.0.0
> /ipfs/kad/1.0.0
```

Only later, in an easy-to-miss note do we point out the critical details that every message has a varint length and newline suffix:

**Note 1:** Every multistream message is a "length-prefixed-message", which means that every message is preprended by a varint that describes the size of the message.

Farther down in the spec, the examples begin to show the varint length explicitly:

```
> <varint-ls-length>ls\n
< <varint-ls-response-length><varint-protocol-length><protocol>\n
< <varint-protocol-length><protocol>\n
# ...more protocols
< \n
```

Suggestions for improvement:

  1. Highlight the basic message wire format first and have an example showing the varint, message body, newline suffix.
  2. Make all of the examples consistent in explicitly showing the varint lengths and newline suffixes. The way it is now is ambiguous. Does each protocol line constitute a message and thus has a varint length and newline suffix or is it only the overall message that does?
  3. Add a little terminology/vocab note at the top explaining "initiator" and "responder" and explicitly stating that any message that starts with ">" is a message from the initiator to the responder and any message that starts with "<" is a message from the responder to the initiator.
  4. Remove the newline suffixes. If you have varint length prefixes the newline suffixes are redundant framing.
@dhuseby
Copy link
Author

dhuseby commented Aug 19, 2023

I would make a PR right now to fix the problems but the spec, as it is, can be interpreted different ways and I don't want to dump raw messages to figure out the behavior in the wild. Once I confirm the actual wire protocol, I can submit a PR to clean this up.

@marten-seemann
Copy link

When using the TCP transport, the first multistream exchange happens in the clear, so it should be easy to inspect using Wireshark.

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

2 participants