It is a challenge to configure, troubleshoot, or manage
a device if we're not sure how it works.
So in this Nugget, I'd like to share
with you the basics of how a Layer 2 switch operates.
So let's begin by introducing this topology,
and we're pretty proud of it.
We have three PCs--
PC-1, 2, and 3--
and each of them are connected physically
with a little patch cable that goes from their network
interface card at their PC down to the port on this switch.
So PC-1 is physically connected to port 1/1,
PC-2 is physically connected to port 1/2, and PC-3--
da-da-da-da-- connected to port 1/3.
Also, for this topology, I have assigned each of the PCs
a network layer address, and that's these top numbers.
PC-1 can be reached at 10.0.0.11, PC-2 at 10.0.0.22,
and PC-3 at 10.0.0.33.
I've also included the Layer 2 MAC address, or at least
a portion of it, for each of the computers.
Because it is 12 digits long, I thought
I'd just go ahead and put an x.x for the first eight characters,
and then write out the last four digits, which I've done here.
So PC-1's MAC address, its Layer 2 address,
ends in 6800, PC-2 ends and 6801, and PC-3 ends in 6802.
So now that we've been introduced
to the topology in this three-node network,
let's talk about what this switch right here
does for a living.
So we plug that in.
It's powered on.
And one of the first things this switch is
going to do and continue to do is to listen to the frames
as they come in and learn.
And the question might be, well, what
exactly is it going to learn?
Well, it's going to learn the MAC addresses
on the PCs or other devices that are connected to its ports.
And the way it does that, it pays attention
to the source MAC address.
And let's use PC-1 as an example.
Let's imagine that PC-1 is sending
a frame of data, bit by bit, into the network
through this port on the switch.
And it just so happens I had conveniently available a packet
capture showing the Layer 2 information that PC-1
would be using if it was communicating with PC-2.
And just to give a clear picture of what's happening,
PC-1 is doing a ping here.
It's sourcing it from its IP address of 10.0.0.11,
and it's pinging over to 10.0.0.22, right here.
Now, that's the Layer 3 information, but at Layer 2,
that corresponds to the source Layer 2 address of the MAC
address ending in 6800-- this guy right here--
going to the destination MAC address of 6801,
which is this guy right here.
So as PC-1 sends his frame into the switch,
from a learning perspective, the switch
is looking at the source MAC address on the incoming frames,
because the switch is curious and wants
to know where all the MAC addresses live.
So in short, when PC-1 sends a frame into the network
and includes its source MAC address,
the switch is going to build a table.
It's going to say, OK, MAC address x.x.6800,
that MAC address, because I saw it come in on port 1/1,
is associated with port 1/1.
So once these devices have all sent at least one frame
into the network, which includes their source MAC address,
the switch is going to have learned and then
put into a table all their MAC addresses
and where they can be reached.
So we're getting PC-2.
The MAC address is x.x.6801, and it's associated with port 1/2.
And for PC-3, it's the MAC address
that ends in 6802 on port 1/3.
So the major concept is that the switch
is listening and learning regarding the source
MAC addresses for all the frames that enter its ports.
And then, secondly, it's building a table
so if it ever needs to forward a frame to any
of those MAC addresses, it knows exactly which port it
should send the frame out to reach that destination MAC
address.
And one of the beautiful things about a Layer 2 switch
is that it can do intelligent forwarding.
Case in point.
If PC-2 is going to send a frame to PC-3,
it can craft that frame with PC-3's Layer 2 destination
address.
And when that frame goes into the switch, the switch says,
hmm, I know where that MAC address
lives that ends in 6802.
It's off of port 1/3.
And it can forward that directly to that port
and forward it to PC-3, and that traffic never
even had to bother PC-2 at all.
It wasn't for PC-2, PC-2 didn't care about it,
and we're not interrupting anybody else
except for PC-3, who's going to receive that frame.
And if this switch is just powered on
and hasn't learned where everybody lives yet
and it receives the frame--
let's imagine that PC-1 sends a frame into the network--
the switch looks at the destination address,
and the switch looks at this table it's built and says,
oh, I don't know where that destination lives.
The switch is going to err on the side of caution,
and it's going to forward that frame out
to every other port where there's a device connected
with the hope that whoever that frame was for
would have a chance to take a look at it.
And what the switch is not going to do,
it's not going to bother forwarding the frame
out the same port that it came in
on because that would be silly.
If PC-1 is sending a frame, PC-1 already knows about that frame.
So a frame coming into the switch
where the switch does not know where that destination MAC
address lives is forwarded to all other ports.
And that same kind of activity happens
if a device sends a broadcast into the network.
Let's imagine that PC-3 sends a broadcast frame
into the switch.
A broadcast is also going to be forwarded out all other ports
because it's a broadcast.
Somebody might need to see it.
So the processing of an unknown destination address
and a broadcast are handled the same on the Layer 2 switch.
They're sent out every other port except for the port
that that frame came in on.
In this Nugget, we've taken a look
at the basic operations of a Layer 2 switch.
I hope this has been informative for you,
and I'd like to thank you for viewing.