Libp2p stream multiplexing

https://docs.libp2p.io/concepts/stream-multiplexing/

What is Multiplexing (Muxing)

Why do we need multiplexing?

If we communicate frequently with a peer, we’d like to avoid establishing new transport connections. This is because creating new transport connections might involve Network Address Translation (NAT) traversals, which are expensive.

Multiplexing allows us to have concurrent streams which use the same transport connection.

Which layer should we do multiplexing though?

Multiplexing is done at the application layer for greater portability.

Can it scale?

Yes, we can swap out multiplexing protocols according to our needs.

For instance yamux allows us to scale to thousands of multiplexed streams over a single connection.