How Switch Works? How Does Switch Learn MAC Addresses? – Switch provides data communication between a computer or any device connected to the network. So how does Switch work and learn the MAC addresses of computers?
How Switch Works? How Does Switch Learn MAC Addresses?

How Switch Works? How Does Switch Learn MAC Addresses?

How Switch Works? How Does Switch Learn MAC Addresses?

Switches that are commonly used on the network and act as switching provide data transmission according to MAC addresses. Each network device connected to the ports of the switch has a MAC address. So the Switches register their MAC addresses to own tables and then use the MAC addresses in the table for fast data transmission.

So, how does one Switch learn MAC address of computers? Let’s say there are 2 computers on the network. For example; PC1 is pinging PC2. When pinging, the source and destination IP addresses are immediately designed by the ICMP protocol. However, because PC1 does not know the MAC address of PC2, PC1 broadcasts a Broadcast message to the network. Makes the broadcast task ARP (Address Resolution Protocol).

PC1 edits the target part as ff: ff: ff: ff: ff: ff to broadcast. In short, PC1 uses the ARP protocol to ask who has the IP address 192.168.5.10. The ARP address resolution protocol finds the MAC address with the IP address 192.168.5.10 and the next step is to ping the PC2.

In our previous articles, we have discussed What is Switch in Networking and What are The Methods of Switching. In this article, we will examine how does Switch learn MAC address of computers on the network.

Our Recommendation

You can purchase “CCNA in 60 Days” from Amazon.

Examining How Does Switch Work Using WireShark in GNS3

After making a small network topology using the GNS3 program, we will ping PC2 via PC1. We will do a Packet Analysis using WireShark on the cable between PC1 and Layer 2 Switch before pinging. Follow the steps below to examine how to learn the MAC addresses of a computer on the network.

   Step 1

First, run the GNS3 program and create a new project.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 2

Drag and drop one Layer 2 Switch and two VPCS computers to GNS3 workspace. As the example, define one IP address block and add the descriptions to GNS3 workspace.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 3

After assigning IP addresses to VPCS computers, check the configuration with the show ip command at the command prompt. Do not forget PC1 MAC address information.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 4

The IP address information on PC2 is as follows. Do not forget the PC2 MAC address here.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 5

As there is no data transmission on the network, the MAC address table on the Switch will be empty. You can see the MAC table with the show mac address-table command on the switch.

Computers send ARP Broadcast (ff: ff: ff: ff: ff) over the network at certain times and create their own MAC table. MAC addresses are kept in Cache for up to 10 minutes. Therefore, when the computer wants to send the packet again, it will not broadcast ARP because it knows the MAC address of the target computer.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 6

To start the WireShark program in GNS3, click on the connection between PC1 and Layer 2 Switch.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 7

Click the OK button in the window that opens.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 8

The WireShark program will open as soon as you press OK. In the image below you can see that the package analysis is done.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 9

You can see that the ARP protocol is activated on the WireShark program as soon as pings to PC2 from PC1.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 10

Click Broadcast ARP option for more detailed information. As you can see in the following image, PC1 broadcasts to ff:ff:ff:ff:ff:ff as the destination address because PC2 does not know IP address.

As a result, the MAC address of the 192.168.5.10 IP address has reached with the ARP Broadcast broadcast. And now PC1 will start the Ping operation (ICMP) immediately after learning the MAC address of PC2.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 11

When we click on the 25th column on WireShark, we can see that ARP address resolution is now complete. We can also see PC1 and PC2 in the source and destination address fields.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 12

If we look at the MAC table with the show mac address-table command on the switch after the ping is completed, we can see that the MAC addresses of PC1 and PC2 are tabled.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 13

If you want to delete the MAC table entries on the switch, you can do this with the clear mac address-table command.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 14

You can also use the show arp command to see the MAC address records in VPCS PC1 and PC2 and use the clear arp command to delete it.

How Switch Works? How Does Switch Learn MAC Addresses?

   Step 15

And finally, you can use the Stop Capture option on GNS3 to close the WireShark packet analysis program.

How Switch Works? How Does Switch Learn MAC Addresses?

How Switch Works? How Does Switch Learn MAC Addresses? ⇒ Video

You can watch how Switch works and how does Switch learn MAC address of any computer on the network and you can also subscribe to our YouTube channel…

  Final Word

How Switch Works? How Does Switch Learn MAC Addresses? – We can do this by entering Static MAC address records instead of learning Dynamic MAC address to reduce ARP Broadcast broadcast on Cisco branded or any brand Switches and improve network performance. Also on Windows operating systems, we can display the MAC address table with arp -a command.

If this article is helpful, send me feedback by commenting! Thanks in advance, take care of yourself!

Also, you can add to browser bookmarks by pressing the CTRL+D to read this article later!

Articles Related to How Switch Works? How Does Switch Learn MAC Addresses?
Products Related to How Switch Works? How Does Switch Learn MAC Addresses?
Related Products

Leave a Reply

Your email address will not be published. Required fields are marked *

four × 4 =