The basic function of switches is to connect devices to the network.
of course they can do far more but every other feature they have is to support connecting devices
primarily switches work at layer 2 when we think about layer 2 we think about things like mac
addresses ethernet frames and vlans a lot of modern switches support some layer 3 functions
that means ip addressing routing and that sort of thing for this section of the series we're
going to focus our attention on layer 2. we commonly use ethernet protocols in our networks
each ethernet frame has a source mac address and a destination mac address ethernet and layer 2
in general is used to deliver frames from one hop to the next this means that with each hop
the source and destination mac will be updated the source will be the device that's sending
and the destination will be the next hop along the path this process is called frame rewrite
switches don't count as hops in this sense that is they don't update the
source and destination mac addresses of each frame that passes through them
so what are switches for connectivity all devices need to be connected to each other in some way
but we can't literally connect every device to every other device
imagine how many cables we would need instead the switch uses a process called frame switching
instead of connecting devices directly to each other devices connect to switches as you can see
this is so much simpler when a frame arrives at a switch the switch decides which link or
interface to send the frame out of this makes sure that the frame gets to the correct destination
the next question is how does a switch know which link to send the frame on it does
this by learning the mac addresses of connected devices and the interfaces they are connected to
these details are stored in the mac address table when a frame arrives at a switch port the switch
takes a look at the destination mac address remember that this is in the ethernet header
it looks for this mac address in the mac address table here it finds the port that
the mac address belongs to it then forwards the frame out of this port we should ask ourselves
what happens if the mac address we're looking for is not in the mac table this means that the
switch hasn't learned about this mac yet in this case it will flood the frame out of all ports
that means a lot of devices will get that frame most will ignore it as it's not meant for them
the correct device will send its reply which the switch will see the switch can then learn which
interface this device is connected to and add the entry to the mac address table for next time
do you want to see what a real mac address table looks like
from the cli we can use the command show mac address table here we can see all the mac
addresses that the switch knows about and the port that should be used to reach them
entries don't stay in here forever though once an entry is learned a timer starts if
more traffic involving that mac address is seen then the timer resets but if the timer expires
the entry is removed from the table this is one way the switch keeps the table fresh for example
we might have a laptop that we disconnect from one port and then connect to another port if the
mac address table didn't clean up after itself traffic might get sent out the wrong interface
if you're planning on taking the ccna exam we have a few extra resources to get you ready
these include study notes quizzes flash cards transcripts and the command line summaries
check the video description to get a link to each of these resources
usually quiz explanations are for members of the site however i've
made all the quizzes in this video available to everyone so you can see if you like them