How the STP works
The purpose of the Spanning-Tree is to obtain a LAN architecture WITHOUT BOUCLE.
The first protocol for Spanning-Tree is the SPanning-Tree Protocol (Spanning-Tree Protocol).
To turn a mesh architecture into a loopless architecture, STP will have to disable certain links.
To do this, it has the possibility to put the ports of a switch in one of these two states (state) stable:
– normal port operation
– the port emits nothing except STP frames
– the port receives all but only deals with STP frames
To make this type of decision, all switches will have to agree on the logical architecture to adopt.
Our switches will exchange STP information via BPDU frames, so that he all agrees, they will first have to elect a leader!!
The Chief will be called the root-bridge!
Our switches exchange information about STP via BPDU frames.
BPDU (Bridge Protocol Data Units).
There are two types of BPDU frames:
1 – BPDU configuration:
Lets your neighbours know about the health of STP topology.
2 – Topology Change Notification BPDU (TCN BPDU):
Announces a change in STP topology.
By default, a Switchs sends a BPDU frame every 2 seconds to all its ports.
Election of roles
1- Bridge Priority
– on 2 bytes
– perhaps modified by the administrator
– between 0 and 65,535
– has a step of 4096 (4096, 8192, 12228, … , 28672, 32,768, 36864, … , 57344 or 61440)
– default: 32,768
2- MAC Address
– on 6 bytes
– corresponds to the MAC address of our switch
Thanks to the BPDU frames, our switches will look for the active equipment with the lowest Bridge Priority value. If everyone has the same bridge priority value. They're going to look for which at the weakest MAC Address.
By default, the switch with the weakest Mac address is going to be the root bridge!
So it will be the oldest switch in your network that will be the head of your level 2 topology! It is essential to put your network core as a root bridge (#chef) by playing on your bridge priority.
As soon as the "root bridge" is elected, all links will be put either forwarding or blocking, following the following logic:
All ports of the "root bridge" (#chef) switch will be obligatory in the forwarding state
The wearing of each "non root bridge" (#lesautresswitchs) which has the smallest administrative cost to go to the "root bridge" is in the forwarding state
The other links will be inactive. On an inactive link, there will always be one port in the forwarding state and another in the blocking state.
If an active link falls, it will be replaced by an inactive link following the logic above.
We've seen that the ports of our switches can take 2 states:
The STP protocol will also define a role for each port, there are 3 roles:
– root port
– designated port
– port blocking
To define which port of our switch will become the root-port –
- Lowest administrative cost
- The lowest bridge ID value
- The lowest port number
The administrative cost:
We have seen above that each switchs "non-root bridge" will put the port which has the lowest administrative cost to discuss with the root-bridge in the "forwarding" state. This port will have the role of "root port."
How does it calculate the administrative cost? Taking into account the following table:
– 10 Mbps – 100
– 100 Mbps – 19
– 1 Gbps – 4
– 10 Gbps – 2
The root bridge sends a BPDU frame to all these ports with a "root path cost" value equal to 0.
The switches receiving this BPDU frame put this "path cost" value on the physical reception interface.
The latter return to their other interfaces a BPDU frame with a "root path cost" equal to 0 – the value of the output interface.
The Switch 1 only has FastEthernet interfaces. It receives on the FastEthernet 0/1 interface a BPDU message with a "root path cost" equal to 0. It will therefore send a BPDU frame to these other FastEthernet ports with a "root path cost" value equal to 19 (0-19).
The physical interface of each "non-root switch" with the lowest "root path cost" value will have the role of "root-port".
To illustrate this, we will rely on the same architecture seen above.
The only point that will differ on both architectures is the cost of the links.
Now, let's put our root-port architectures on:
The C and D switches found a shorter path by passing towards B and E respectively.
The value of Bridge ID
Let's imagine this scenario:
One of our switches receives on two of its ports a BPDU frame with the same administrative cost. So which link will he choose to put in Forwarding mode?
In our BPDU frame, we've seen above that each switch incorporates its Bridge ID.
Since the administrative cost is equal for these two BPDU frames, our switch will look at the bridge ID value of these two frames and will decide to put in forwarding mode the interface that received the BDPU with the weakest Bridge ID.
In our case, all of our Bridge IDs have a default value.
The Switch B has a lower mac address than the C switch.
The D switch will therefore go through the Switch B in order to reach the root bridge
The port number
Our Switch D receives two BPDU frames on two different ports:
Administrative costs are equal
Bridges IDs are equal (as they come from the same switch).
Our switch will therefore have to fall one link to be forwarding and the other in blocking.
The lowest port number will be put into active.
A port that has the role of "designatedport" is in the forwarding state.
All root bridge ports (#chef) have the role of "designated port".
Only the links between "root port" and "designated port" will be active.
The other routes will have a "designated port" port and a "blocking port" port. In order to determine which of the two ports will have the role of "designated port", we will define which of the two switches has:
- The link with the lowest cost to reach the root bridge (root path cost)
In the event of a tie
- The Lowest Priority (Bridge ID: default 32,768)
In the event of a tie
- The weakest MAC address
The other ports will be in blocking state:
State of STP ports
Our STP ports can take several states. There are different types of states:
– disabled (with shutdown control)
– blocking (the protocol has made the decision to block this port to avoid a loop, it always receives and processes the BPDU frames it receives)
– forwarding (the port is active)
– listening (the port can send and receive BPDU frames) – 15s
– learning (idem that the "listening" state, except that it will at the same time fill its ARP table) – 15s
In the event of a breakdown
In order to keep our architecture up to date and ready to switch in the event of a breakdown, the "root bridge" sends a "Hello BPDU" frame to all its ports and every 2 seconds.
This frame contains:
– the root Bridge ID
– the Bridge ID (in this case, it will be identical to the root Bridge ID)
– the cost to reach the root bridge (in this case it will be zero)
Each non Root Bridge (#paschef) replaces the Bridge ID and the cost of reaching the root bridge (#chef) with its own and transmits this frame to all its "designated port" ports.
If a switch no longer receives a Hello BPDU frame for 20 seconds (10 x 2sec), it will start trying to change the STP topology. This time interval is called the "MaxAge."
When STP topology starts to change and it requires a previously blocking port to switch to forwarding mode. It will pass in the listening (listening) and learning (learning) stages.
(f) In the official guide of the CCNA 200-125 , we can find this table:
It tells us that blocking, forwarding and disable states (shutdown, off) are stable states and that listening and learning states are transient states. Each of its transient states lasts 15 seconds.
It will take 50 seconds (20-15-15) to our STP topology to compensate for a network outage.
This time is far too important. The RSTP (Rapid STP) protocol was born.
Next Article: 02 – RSTP Protocol