September 25, 2023

How does a network switch know the MAC address

What is the difference between a MAC address and an IP address?

 

A network switch refers to sending Internet traffic to the MAC address of the correct device, not the IP address.

 

Each device connected to the Internet has an IP address. An IP address is a character set consisting of letters and numbers, such as 192.0.2.255 or 2001:0db8:85a3:000:8a2e: 0370:7334. An IP address is similar to a mail address, enabling Internet traffic directed to that address to reach the device. IP addresses often change: Due to the limited number of IPv4 addresses, user devices are often assigned new addresses when establishing new network connections.

 

IP addresses are used at Layer 3, which means that computers and devices on the Internet use IP addresses to send and receive data, regardless of which network they are connected to. All IP messages include their source IP address and destination IP address, just like email messages have destination and return addresses.

 

In contrast, a MAC address is a permanent identifier for each piece of hardware, somewhat like a serial number. Unlike IP addresses, MAC addresses do not change. MAC addresses are used in Layer 2, not Layer 3 – which means they are not included in the IP packet header. In other words, MAC addresses are not part of Internet traffic. They are only used in a given network.

 

How does a network switch know the MAC address of a device in the network?

 

The second layer network switch maintains a table in memory that matches the MAC address of the switch’s Ethernet port. This table is called a Content Addressable Memory (CAM) table.

 

Suppose computer A is connected to an Ethernet cable plugged into switch port 1, computer B is connected to port 2, and computer C is connected to port 3. When data arrives at computer A, the switch looks at its CAM table, sees where computer A is connected, and knows to forward computer A’s traffic at port 1, not port 2 or port 3.

 

The CAM form of the switch is stored in memory. “If the switch is turned off, the table will disappear. When the switch restarts, you must relearn the table.”

 

For now, assume that the network switch has just been opened and its CAM form has not yet been created. It does not know which port computers A, B, and C are connected to. It also doesn’t know their MAC address.

 

Suppose computer A sends a message to computer B. The switch performs the following steps to send a message to computer B and starts filling out its CAM form:

 

It records the MAC address of computer A and the port from which its messages come

 

Forwarding messages from computer A to all other computers on the network (except computer A); This is the so-called “flood”

 

When computer B answers, it also records the MAC address and port of computer B

 

The CAM of a switch is represented by knowing the location of computers A and B, as well as the MAC address of the user.

0 0 votes
Article Rating
Subscribe
Notify of
0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x