I have read a lot about STP now. Perhaps not enough yet, but it starts to get difficult to get details.
I have understood the mechanism how all bridges select their root port. After having exchanged enough BPDUs containing information about potential root bridges, the information about the real root bridge will have seeped through the network providing each bridge with path cost information to the root bridge. Each bridge will then set their root port to the one with the least path cost.
But that alone does nothing to prevent a loop.
Of all its other ports the bridge has to set some to designated and some to non-designated role. The latter ones will stay blocked while the designated ones will eventually be switched to forwarding mode.
I do not understand, how the differentiation is done between designated and non-designated ports. In my opinion there must be some information about the different direction.
Let's say bridge A is rather far from the root bridge and bridge B is a peer to A. At some point bridge A has to tell bridge B: "hey, my root port now points to you, so you have to make the opposing port of yours a designated one."
But I did not find any reference and as far as I can see there's no information in a BPDU regarding this issue. However there must be a mechanism, but I can't see it yet.
Edit
To make it more concise: On a network segment there can be many ports of many bridges attached. Per bridge attached to this segment there may be 0 or 1 port a root port. And as soon as one single root port is attached to this segment exactly one port of another bridge has to be turned into a designated port. I understood that very well, however I felt I had to write it more clearly.
My question is still: How is determined which port on that segment will be turned into a designated port? What part of the STP algorithm is making this decision and how?
Edit
I added a sample picture to make the problem once more visible.
Let's say there's a segment where the two switches A and G in the upper half have each a minimal path cost on their ports pointing up. Hence their interfaces to the segment under inspection can only be designated or non-designated. We have one or more other switches below which have a port on the network they chose as root port.
I have understood that the switches below including B send BPDUs which make clear, that there is at least one root port attached to the segment. This makes clear that exactly one designated port is needed to satisfy the root ports of B and the others with connectivity. However, as BPDUs are multicast, there is no such thing as a "link partner".
How do A and G know which one has to make its port designated or non-designated?