unlabelled – TOR How does the intermediate node know which chain a packet belongs to?

If we have the string X: A-> B-> C and Y: D-> B-> C

When B receives a packet of A, decrypts the content, sees that the next hop is C, opens a connection to C (binds internally to the open connection with A that it has) and sends the rest of the packet to C (which is encrypted with the key of C, so I could not read it, anyway).

When it comes to a response from C to A, the connection was already opened by C, so B knows that a certain connection (you can probably group several internal connections into a single TCP connection, but here it's irrelevant) corresponds to this one , since that is how B created them.