Skip to content
This repository has been archived by the owner on Feb 12, 2024. It is now read-only.

mplex stream numbers #1601

Closed
richardschneider opened this issue Sep 29, 2018 · 4 comments
Closed

mplex stream numbers #1601

richardschneider opened this issue Sep 29, 2018 · 4 comments

Comments

@richardschneider
Copy link
Contributor

According to https://github.com/libp2p/mplex#opening-a-new-stream

To open a new stream, first allocate a new unique stream ID; the session initiator allocates odd IDs and the session receiver allocates even IDs.

But it seems that js-ipfs is using even IDs when opening a new stream.

Here's the debug output when sending the Bitswap want list. Note that js-ipfs was told to connect to QmTp1fwYnJxc5rUEVM2xowcDiyR61J7yvmBRUQzT4g8MHs , so it is the initiator.

  libp2p:switch:dial dialing QmTp1fwYnJxc5rUEVM2xowcDiyR61J7yvmBRUQzT4g8MHs +12ms
  mplex:main:44875 createStream: 2 2 { halfOpen: true, initiator: true } +54s
  mplex:channel:2 open, halfOpen: true +0ms
  mplex:main:44875 _addChannel 2 +3ms
  mplex:channel:2 open: 2 +2ms
  mplex:main:44875 _send 16 0 +3ms
  mss:dialer     (10sse5) dialer handle conn +0ms
  mss:dialer     (10sse5) writing multicodec: /multistream/1.0.0 +4ms
  mplex:channel:2 write:  20 +20ms
  mplex:main:44875 _send 18 20 +18ms
  ipfs:mfs:lock read operation callback invoked +50ms
  ipfs:mfs:lock Finished read operation +1ms
  mplex:main:44875 _write 22 +8ms
  mplex:main:44875 _push 20 +1ms
  mss:dialer     (10sse5) received ack: /multistream/1.0.0 +15ms
  mss:dialer     (10sse5) handshake success +0ms
  mss:dialer     (10sse5) dialer select /ipfs/bitswap/1.1.0 +1ms
  mss:dialer     (10sse5) writing multicodec: /ipfs/bitswap/1.1.0 +7ms
  mplex:channel:2 write:  21 +20ms
  mplex:main:44875 _send 18 21 +10ms
  mplex:main:44875 _write 23 +17ms
  mplex:main:44875 _push 21 +1ms
  mss:dialer     (10sse5) received ack: /ipfs/bitswap/1.1.0 +19ms
  mplex:channel:2 write:  51 +20ms
  mplex:main:44875 _send 18 51 +2ms
  mplex:main:44875 _send 20 0 +3ms
@richardschneider
Copy link
Contributor Author

@diasdavid I seem to remember this issue be mentioned months ago, but I can't find any reference to it.

@daviddias
Copy link
Member

it might be due to incomplete work, see https://github.com/libp2p/js-libp2p-mplex/pulls //cc @jacobheun @vasco-santos

@jacobheun
Copy link
Contributor

jacobheun commented Oct 1, 2018

It looks like the initiator base id is just flipped. https://github.com/libp2p/js-libp2p-mplex/blob/v0.8.0/src/internals/index.js#L83. The base id is set to 0 instead of 1 and then the stream id is incremented by 2, which is why we're seeing 2 2 in the logs mplex:main:44875 createStream: 2 2 for the first stream.

Edit: After reviewing the flags, they are correct between both versions, the id on the js side looks to be the only issue.

@jacobheun
Copy link
Contributor

There was an intended change to the mplex spec that never got merged, libp2p/mplex#3. It was just merged in a little while ago.

The js implementation does match the intended spec.

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

No branches or pull requests

3 participants