Network protocol structure

Hi there, I’m working on an alternative green-field implementation of lib2p for internal project ( Specific requrirements, nothing fits). And I’d like to know more about how the network protocol works.

I’m interested how to stream muxing & encryption play together.

  1. Is the stream encryption in a special place ( each muxed stream always running on top of encrypted stream). OR

  2. Raw connection (TCP) is muxed, one of the streams on top of it is the noise protocol, and on top of noise protocol is another muxer switching between individual app streams ?

Basically , I need to know whats the composition structure of all the muxers and different protocols, and what’s the negotiation tactic. I’ve been able to find a lot of materials for user defined streams, but not a lot for this part of the code.

If the base connection doesn’t provide builtin encryption & authentication, it’s encrypted & authenticated using Noise or TLS. The multiplexer is then run on top of the encrypted stream.

Basically, encryption is always the first “upgrade”. The entire process can be found in:

Thank you, I found some docs got the information I needed