So let’s start with a simple topology to illustrate how Spanning Tree works.
Why would you require Spanning Tree in a switch network?
So in this topology we have host A connected to switch 1
switch 1 in turn is connected to switch 2 and switch 2 has host B connected to it.
So very simple topology.
Now if your link went down between switch 1 and switch 2
host A wouldn’t be able to communicate with host B and vice versa.
So you probably gonna want to implement some kind of redundancy
between those switches by adding an additional link.
So that’s great because you now have network redundancy
in case one of the links goes down
however, that introduces problems in a switch environment.
It’s generally recommended in networks today
that you implement some type of redundancy.
So in this example, you have 2 links between your 2 switches
but that will introduce additional problems which we'll now discuss.
Let’s assume for the moment
that the switches have just booted up
and their MAC address tables or cam tables are empty
and to help explain this issue
let's add MAC address tables to the topology
so that you can see how the MAC address tables are updated
when traffic is sent from 1 host to another.
So let’s assume that in this topology
the switches have just come up
in other words, they've been rebooted or powered up
and the MAC address tables or cam tables are empty on the 2 switches.
now when A sends a frame to B the destination address on the frame will be B
and the source address will be A
so A is sending a frame to B and when it arrives at switch 1
switch 1 will read the source MAC address of the frame
and the switch will see that the source address is A.
the switch will update its MAC address table to state that A can be found on port 1.
MAC address B, however, is not in the MAC address table.
So the switch will flood the frame out of all ports
except on the port in which it will arrive.
So in this example, the frame will go out port 2 as well as port 3.
It does that because it doesn’t know where MAC address B is.
Now, this is obviously a very simple topology.
In this example, the frame is only being sent out of 2 ports of the switch.
however, if the switch had many ports, let’s say 96 ports
an incoming frame on 1 port could be replicated out of over 90 ports on that switch.
That increases the amount of traffic sent in your network quite dramatically.
So in this topology what does switch 2 do with the frame received in port 1.
The source address once again is A and the destination address is B
what will the switch do with the frame?
Well firstly its gonna update its MAC address table
to state that A can be found on port 1
and then it's gonna flood the frame out of all ports.
So they’ll flood out of port 2 as well as port 3.
so in this example, host B will receive the frame from host A
however, the switch also receive the frame on port 3
and this is where it gets a bit confusing
where is A from the switches point of view, is it on port 1 or is it on port 3?
So in this example, its gonna update its MAC address table
to state that A is on port 3
because their frame in our example arrived on port 3 but later then on port 1
so its gonna update the MAC address table entry
to state that A is now available on port 3.
The switch will also flood the frame out of all ports
so it’s gonna flood it out of port 1 and out of port 2.
so host B has now received the frame twice
once from the original frames that arrived on port 1 sent to host B
and secondly for the frame that arrived on port 3.
So this can get confusing for any devices
because they're receiving the same frame multiple times.
The MAC address table is also changing
the first frame that arrived on port 1
allowed this switch to update it's MAC address table
to state that A can be found on port 1, however, the frame that arrived on port 3
now indicates to the switch that A can be found on port 3
so the switch needs to update its MAC address table
to state that A can be now found on port 3.
So this introduces instability in the MAC address table.
so we have end devices receiving frames multiple times
and we have MAC address instability
because the switch thought that A was available on port 1
but now sees that it's available on port 3
but it get worst, when the frame arrived on port 1
the switch updated its MAC address table to state that A can be found on port 1
but it also flooded the frame out of both port 2 and port 3 in this topology.
The frame was received by host B
but in an addition, the frame was sent back to switch 1.
So switch 1 has received the frame that it sent to switch 2
and switch 1 now updates its MAC address table to state that A is available on port 3.
Now when switch 1 receives the frame it not only updates its MAC address table
but it also floods the frame out of all ports except to the port which it arrived.
so the frame arrived on port 3 it's flooded out of port 1 and out of port 2
so this gets confusing for host A
because it's receiving the frame that it originally sent.
but not only is A receiving the frame that it sent
switch 1 is also sending the same frame back to switch 2
and what a switch 2 gonna do with the frame?
it's gonna flood it, so it's gonna send a copy to host B
host B has now received the same frame 3 times
but it will also send the frame back to switch 1
as well as updating its MAC address table to now state that A is on port 1.
So originally when it received the first frame, it thought that A was on port 1
then when it received the frame on port 3, it thought that A was on port 3
and now it thinks that A is on port 1
so we’ve got a lot of MAC address instability in the MAC address table.
Host B is receiving the same frame multiple times
but the biggest issue here is that
the frame get sent back to switch 1, gets flooded again
get sent back to switch 2 and this process continues over and over again.
We have a loop in this topology with the frame being duplicated
and sent round and round and round between these 2 switches.