> For the complete documentation index, see [llms.txt](https://davidjosearaujo.gitbook.io/online-courses/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://davidjosearaujo.gitbook.io/online-courses/ccna-200-301/spanning-tree-protocol/stp-port-role-selection.md).

# STP Port Role Selection

1. The switch with the lowest bridge ID is elected as the root bridge. All ports on the root bridge are **designated ports** (forwarding state). Root bridge selection:
   1. Lowest bridge ID.
2. Each remaining switch will select ONE of its interfaces to be its **root port**. The interface with the lowest *root cost* will be the root port. Root bridge selection:
   1. Lowest root cost.
   2. Lowest neighbor bridge ID.
   3. Lowest neighbor port ID.
3. Each remaining collision domain will select **one** interface to be a **designated port** (forwarding state). The other port in the collision will be **non-designated** (bocking). Designated port selection:
   1. The interface on the switch with the lowest root cost.
   2. The interface on the switch with the lowest bridge ID.

| Speed    | STP Cost |
| -------- | -------- |
| 10 Mbps  | 100      |
| 100 Mbps | 19       |
| 1 Gbps   | 4        |
| 10 Gbps  | 2        |

<figure><img src="https://1474932522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAgItg4KAZpnXjAFPWRf8%2Fuploads%2FyEAGYiRpzdiQf3ukkcoq%2F2023-01-28_17-21.png?alt=media&amp;token=b66a58bc-8612-4775-b1a7-d7f51b1f3801" alt=""><figcaption></figcaption></figure>

### SW3's logic

* I was advertised a cost of 0 on G0/0. My interface cost = 4. Total cost via G0/0 = 4.
* I was advertised a cost of 4 on G0/1. My interface cost = 4. Total cost via G0/1 = 8.

The ports connected to another switch's root port **must** be designated. Because the root port is the switch's path to the root bridge, another switch must not block it.

## Port ID

<figure><img src="https://1474932522-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAgItg4KAZpnXjAFPWRf8%2Fuploads%2FtLYAULOmWbzGs5oAPANH%2F2023-01-28_17-21.png?alt=media&amp;token=906af13f-9d7a-4d04-a5b1-be1e8d55d4b3" alt=""><figcaption></figcaption></figure>

STP Port ID = port priority (default 128) + port number.
