This is a rough outline of how the existing GO version connects to the swarm. This was engineered by parsing log files. So some details may be missing
or inaccurate.
Conneting to the swarm:
0) Network connection
1) Negotiate Multistream
2) Negotiate secio
3) Negotiate Multistream over secio
4) Negotiate yamux over multistrem over secio. They should reply with the yamux protocol id. Then there are about 6 streams. It appears that odd number
streams are opened by the "client" and even numbered streams by the "server".
It does not seem that these streams are synchronized with one another, although each stream must complete its transmission before another can be sent
(i.e. yamux header + all data must be sent before another stream can use the connection)
The miscellaneous bytes sent still have to be sorted as to why and when they should be sent.
Stream 1: Us sending the ID protocol and ID message
Send a Window Update
They will send one back
Send multistream protocol id (18 bytes) plus \n (1 byte)
Receive yamux header with 2 bytes (167, 4) (not sure why just yet, but it looks like the id protocol sends the size, then the bytes, and yamux wraps them both)