How does STP calculate the lowest port ID

spanning tree

I was reading about how STP determines which port to block. I was looking at this url https://ciscoiseasy.blogspot.co.uk/2010/10/lesson-20-spanning-tree-protocol.html explicitly this section

The following algorithm is used to determine the root port or designated port (in order):

  1. Prefer the lowest Root Path Cost.
  2. In case of the same Root Path Cost, prefer the lowest Bridge ID of the designated switch (the neighbor that sends BPDUs).
  3. In case of receiving BPDUs on multiple ports from the same designated switch (BPDU sender), prefer the lowest Port ID (known also as port priority) of the sender. That parameter has a default value 128 and is configurable.
  4. In case of all above are did not resolve the problem, prefer the lowest Port ID of the BPDU sender.

The first 3 parts I understand fine. It's the last one that I wanted some clarification on.

The website goes on to show and example where the BPDU frame is being sent from a switch (SW3) on interfaces Fa0/3 and Fa0/4 to another switch (SW4). SW4 chooses it's port Fa0/1 because that port is connected to Fa0/3 and 3 is lower than 4.

Example

My question is:

Is that really as simple as it sounds? A simple calculation on which port number is lower or is there more to it? What would happen if I had Po1 and Fa0/1 and all other factors were the same?

Best Answer

If you do show spanning-tree, the port ID is the Nbr element in the Prio.Nbr column. For this example Gi0/0 is port 1, Gi0/1 is port 2, Po1 is port 65. You will find that all the interfaces of a type are grouped and the port IDs are ordered within that group.

VLAN0001
  Spanning tree enabled protocol ieee
  Root ID    Priority    32769
             Address     0000.ab15.f500
             This bridge is the root
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec

  Bridge ID  Priority    32769  (priority 32768 sys-id-ext 1)
             Address     0000.ab15.f500
             Hello Time   2 sec  Max Age 20 sec  Forward Delay 15 sec
             Aging Time  15  sec

Interface           Role Sts Cost      Prio.Nbr Type
------------------- ---- --- --------- -------- --------------------------------
Gi0/0               Desg FWD 4         128.1    Shr 
Gi0/1               Desg FWD 4         128.2    Shr 
Gi0/2               Desg FWD 4         128.3    Shr 
Gi0/3               Desg FWD 4         128.4    Shr 
Gi1/0               Desg FWD 4         128.5    Shr 
Gi1/1               Desg FWD 4         128.6    Shr 
Gi1/2               Desg FWD 4         128.7    Shr 
Po1                 Desg LIS 4         128.65   Shr