Spanning Tree Protocol, or STP,
is an additional ethernet feature
that is really important.
Now, when you look at the number for it,
it is known as 802.1d,
and so I want you to write that down
in your note sheet as well.
802.1d is the Spanning Tree Protocol, or STP.
Now, what does Spanning Tree Protocol do?
Well, it allows us to have redundant links
between different switches
and it will prevent loops in our network traffic.
Now, why is it important to prevent these loops?
Well, you may remember that we talked
about the availability of networks is measured in nines.
We want to have five nines of availability.
99.999% uptime,
which means that we're only going to get five minutes
of downtime each and every year.
Now, if I want to have a redundant network,
I have to be able to have multiple links to create that
and give me that five nines of availability.
Now let's take a look at a network
without Spanning Tree Protocol and see how it works.
Now you can see that the MAC address table here
can have corruption that occurs.
Let's say that I have PC2 trying
to send a message to PC1.
You can see that there's a redundant network here.
It can take a path going from Switch 4, to Switch 2,
to Switch 1, over to PC1.
Or it can take a path from Switch 4, to Switch 3,
to Switch 1, to PC1.
And that looks great because we have two different ways,
but if you remember how MAC address tables work
inside our switching tables, you're going to notice
that there's going to be a problem here.
When PC2 reaches out to talk to PC1,
Switch 4 is going to learn that the CC MAC address
for PC2 is coming in from that side.
Now it's going to broadcast that out
to Switch 3 and to Switch 2, who both learn that
and they put that in their MAC address table
for Port 0/2.
Then they go and tell Switch 1
and it's coming from both sides.
So Switch 1 now,
thinks that it can re-broadcast that out both sides,
which then feeds back to Switch 2 and Switch 3,
and this creates a loop known as a switching loop.
Now you can see it here in red
because as the data starts going back,
these interfaces start figuring out,
"Hey, how do I get to network CC?
Well, when I get to network device CC,
that MAC address, is that it comes through both interfaces.
And so both of those switches now tell me
that I can go there for CC
and that means I really don't know which way to go
because as a device on a network, I can only go one way
and I need to choose which way that is."
Now this switching loop can happen
and we get what's called a broadcast storm.
This is what's going to happen
if you don't have Spanning Tree Protocol
in your network, but if you do have Spanning Tree Protocol,
you can actually solve this problem.
So let's talk about how we can get through this.
Now we see this broadcast storm that's happening,
and if this broadcast frame is received by both switches,
they'll start to forward it to each other.
And so, one tells it and the other one tells it back,
and they keep going back and forth.
Think of it like this.
I tell you a secret,
and then you tell me that same secret,
and then I tell it to you again,
and you tell it to me again,
and we keep doing this over and over,
and each time more copies of that secret,
in this case, a frame,
are being forwarded back and forth between each other.
It can actually start replicating
and then being forward again, and again, and again
until your entire network is just consumed up
by all of these copies of this ARC packet
that's being sent out trying to tell everybody
where that device should be.
Now it does takes this to happen over time
through your entire network,
and eventually your network will just
crash under the weight of this.
So if your switch starts having this problem,
the only way to fix it
if you don't have Spanning Tree Protocol involved
is to actually unplug the switch,
wait about 30 seconds for all that data
to be forgotten and lost, and then plug it back in.
Now, that's not a great way to run a network.
So someone decided we're going
to create something electronic to fix this problem,
and that's where STP
or the Spanning Tree Protocol gets involved.
Now, the way STP works is that it uses a thing
called a root and a non-root bridge.
Now, a root bridge is where a switch is elected to act
as a reference point for the entire spanning tree.
The switch is then going to select the lowest bridge ID,
or BID, and that's going to be elected as our root bridge.
Now the bridge ID is made up of a priority value
and a MAC address with the lowest value
being considered the root bridge inside our network.
Now, if everything is considered equal,
we're just going to go with the manufacturer's MAC address
being the lowest and that one will be our root bridge,
whichever has the lowest assigned MAC address.
A non-root bridge is every other switch on the topology.
So one root, everybody else becomes non-root.
Now let's assume here we have Switches 1, 2, 3, and 4 again.
How's it going to end up looking
when we start implementing STP?
Well, if I look at Switch 2 and Switch 3,
their MAC addresses are all twos and all threes accordingly.
Both have the same priority
because they're all using the exact same cabling,
because priority is based on the category
of cable you're using.
Now, who is going to end up being my root bridge?
Well, if all the priorities are the same,
we're going to go with the one
that has the lowest MAC address.
So in this case, it's going to be Switch number two
because it had all twos as its MAC address.
That makes Switch number three, one,
and four all non-root bridges.
Now, when we look at the root bridge, Switch 2 in our case,
we also have to look at the concept
of a root port, designated port, and a non-designated port.
Now, when I talk about a root port,
this has to be assigned on every non-root bridge.
So I talked about Switches 1, 3,
and 4 were all considered non-root bridges,
so each one of those has to have one port assigned
as its root port.
Now, the port that is closest to the root bridge in terms
of cost and its number is going to be the root port.
If the cost is equal and all the cost is determined
based on those cable types we talked about,
then the lowest port number on the switch will be chosen.
The way we determine what the cost is,
is faster cables have a lower cost
and slower cables have a higher cost
because we want to put things
on the fastest cables possible.
So if I have a Cat 3 cable, a Cat 5 cable,
and a Cat 7 cable plugged into the switch,
then the port with the Cat 7 cable is going
to be considered the fastest port
because it has the fastest type of cable on it,
and therefore, it will be the root port
on this non-root bridge.
Now, if you have all the same type of cable,
all Cat 5, or all Cat 6, or all Cat 7,
then we're going to choose the lowest port number,
in this case, port number one on the switch.
Now the designated port is every network segment is going
to have at least one designated port on it.
The port closest to the root bridge in terms
of cost will be considered its designated port.
All of the ports on the root bridge
are considered designated ports
because they all are on the root bridge
and therefore, they're really, really fast.
Now, I'll show you this in a diagram
so it'll make a little bit more sense here.
You can see here the non-designated ports are the ports
that are going to block our traffic for us.
This is the benefit of STP.
This is where your loop-free topology
is going to come into play.
So as we look at this diagram,
you can see I have a single root port
on a non-root bridge.
The non-root bridge was Switch number three.
I designated it as purple
because this is the lowest number port.
Now it's Port 0/1 versus Port 0/2,
and it also has the lowest cost
because the cost of 19 is assigned to anything
that's using fast ethernet or a Cat 5 cable.
Remember, the faster the cable, the lower the cost.
Now all the other ports on this non-root bridge,
in our case, Switch number three,
are going to be considered non-designated.
This means that we're going to make them red.
If you think of it, red, think of it like a stop.
There's no traffic coming through those ports.
Now, when I go to the root bridge,
which was Switch number two,
all of those ports are considered designated.
These are all going to be considered blue in color
as shown in my diagram here,
and when traffic comes in from PC2 to go to PC1,
what is going to happen?
Well, port number 0/2 on Switch 3 is red
and it's not going to let traffic go through it,
it acts as a stop sign.
Traffic going from Switch 4, to Switch 2, to Switch 1,
and over to PC1 will be able to go through
based on the way the diagram shows it here.
If it comes all the way around
and it gets to Switch 4, to Switch 2, to Switch 1,
to Switch 3, it's going to get stopped at the root port.
Because again, the non-designated port here is not going
to allow it to broadcast back through.
This is what prevents our loop,
and this is what's going to make a C for us
in the diagram instead of a circle.
That's the whole benefit here of using root
and non-root bridges is that we put blocks in place,
so that we don't have a circle that completes
and allows things to create a broadcast storm.
Now, each port can go through a couple of states
as they do this process.
Non-designated ports are not forwarding traffic
during normal operations.
That's 'cause they're a red stop sign, right?
They receive information as a bridge protocol data unit,
or BPDU, and once they get that information,
they're not going to do anything with it
and they're not forwarding it.
Because again, those are non-designated ports,
they're red, they stop information.
Now, if a link in the topology goes down though,
then the non-designated port will detect that failure
and it can determine or not it needs
to transition itself into a forwarding state
and become a designated port or a root port.
As it goes through that forwarding state,
it's going to transition through four different states.
These four states are blocking, listening,
learning, and forwarding.
Now first it's blocking, and when it's blocking,
this is when it has that big red X on it.
And it's a non-designated port,
and it's going to take any
of those bridge protocol data units
and it's going to stop them and not forward them through.
They're being used at the beginning and on redundant links,
then we're going to switch to listening.
And it'll do this by populating the MAC address table
and starting to learn,
but it's not forwarding those frames yet.
Again, here we're creating that C, not a circle,
and so we don't have a loop that's happening.
Next, we move from listening to learning.
Now it's going to start processing
those bridge protocol data units.
And when it does that, the switch is going
to determine its role inside the spanning tree.
It's thinking, "Do I need to become a root port?
Do I need to become a designated port?
Or should I just stay as non-designated?"
Then it's going to decide if it needs to go into one
of those states as either a designated port or a root port.
If it decides it needs to do that,
then it's going to start forwarding those frames
and those protocol data units.
Now this is called forwarding
and it starts forwarding those frames over, and over,
and over again, and it starts taking over the process
of being the root port.
Now in our example, we either have a root port
or a non-designated port that are blocking.
We have our designated ports which are forwarding things,
so Switch 3 is not sending traffic through.
Now everything is going to go from Switch 4, to Switch 2,
to Switch 1, to PC1 in our example.
Now if Switch 2 goes down,
what will end up happening is Switch 3 will go
through those four states and it will then be able
to start forwarding that traffic.
It goes from blocking, to listening,
to learning, to forwarding,
and it'll take over as the root bridge
and its ports will become root ports,
and they'll have designated ports on them.
Then they'll be able to keep forwarding on.
Now, all this talk about link cost is really important,
and I kind of glossed over it earlier in the video,
so I want to go a little bit more in depth right now.
The link cost is an association
with the speed of a given link.
As I said before, the lower the link speed,
the higher the cost associated with it.
And so as you can see,
you might have something like a Cat 3 cable,
which is ethernet, and it's only 10 megabits per second.
Now, because that is a very slow cable,
it's going to have a very high cost,
so we'll give it a cost of 100.
Now, when I go to fast ethernet,
which is Cat 5 or 100 megabits per second,
that's a faster connection.
So my cost goes down.
It goes from 100 down to 19.
Now, you don't necessarily have to memorize these numbers
for cost for your exam,
but you should realize that if you have a lower speed,
you're going to have a higher number.
If you have a higher speed,
you're going to have a lower number.
In fact, there's this thing called long STP
that's been adopted recently
because higher link speeds kept being created
and we didn't have much room
to make those numbers smaller and smaller.
So as you can see here
with a fiber connection or a Cat 7 connection,
which might be 10 gigabits per second,
we have a cost of two.
If I went to 100 gigabits per second,
I really can't go much less than two,
I might be able to go to one.
And what they ended up doing with this long STP
was adopting values that actually go for 100 from a Cat 3,
to something like 2 million for a CAT 3,
and then we might have more room here at the bottom
for something like a 10 terabit per second connection.
So again, don't worry too much about the STP cost itself
and the numbers associated with it,
if you're dealing with designing a network,
you can always Google the cost table
and you can have it in your hand as you're designing things.
So you don't need to memorize these for the exam.
So for the exam, I want you to remember
that a lower speed is going to have a higher cost,
and a higher speed is going to have a lower cost.
If you remember that there's that inverse relationship
between speed and cost,
you're going to do good on those questions
that come up on the exam when you're dealing with STP.