"Tor works like a chain of proxies, where each proxy only knows about the next hop and the previous hop."
I presume that a TOR node may be part of more than one circuit though, how does it know which packets belong to which chain, does each chain have an "ID" of sorts? Surely that would compromise security.
If we have chain X: A->B->C and Y: D->B->C
and B receives a packet from C, how does it know which entry node to send to?