Spanning Tree Protocol – How Are Ports Selected to Be Designated or Non-Designated?

network-protocolsspanning tree

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

enter image description here

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?

Best Answer

Essentially, a port is designated when it is a root port on the other side (for an STP bridge) or an edge port (end node, no STP bridge).

802.1Q clause 13.4 says

A Port Role (13.12) of Root Port is assigned to the one port on each Bridge that provides that lowest cost path to the Root Bridge, and a Port Role of Designated Port to the one Bridge Port that provides the lowest cost path from the attached LAN to the Root Bridge.

[edit] While all ports nowadays use full-duplex mode (half-duplex mode only exists up to 100 Mbit/s), you are asking about shared-media links. Well, that's where the point-to-point status of a port comes into play. Full-duplex links are considered point-to-point (see 802.1Q clause 13.4) and my simplified statement root port or edge node on the other side applies.

Shared-media links use the more universal rule from the IEEE 802.1Q quote above: if any STP bridge on that collision domain chooses the port in question as its root path, the local port becomes designated. Note that other STP bridges on the same segment would either choose the same bridge for providing their root path or use another, lower-cost port towards the bridge.