Master the working principle of the switch and the MAC table in three minutes, a must-see for the netizen!

The switch works at the second layer of the OSI model, the data link layer, which is mainly used for end users to access the network and exchange data frames.

The process of data frame exchange by the switch:

① Learning: When the switch is forwarding data, the switch records the MAC address and port of the sender. This process is called learning .

As shown in the figure: Host A wants to transmit a data frame to Host B. The switch receives the data frame from the E0 port, checks its source MAC address and records its corresponding E0 port into the MAC address table.

 image.png

  ②Flooding: The switch receives the data frame that needs to be forwarded, but there is no MAC address entry of the target end in the MAC address table, it will send this data frame to all ports (except the source port) .

As shown in the figure: there is no routing entry for host B in the switch routing table . At this time, the switch will forward the data frame received from host A to ports E1 , E2 , and E3 .

 image.png

 ③Forwarding: If the destination address of the data frame to be forwarded by the switch is known (existing in the MAC address table), the data frame will be sent to the port corresponding to the destination address .

As shown in the figure: when there is a MAC table entry of host B in the MAC address table of the switch , the data frame will be directly forwarded to the specific port E1 .

 image.png④Filtering: When forwarding, ports other than specific ports are not forwarded .

As shown in the figure: the switch does not forward ports E2 and E3 because of filtering. ⑤ Aging: When the switch learns a certain source MAC address, it will give this entry a timestamp ( similar to the effective time, this time can be set by itself, the default is five minutes ), whenever it receives data from this MAC address The time stamp will be updated when the frame is timed. If the data frame from this MAC address is still received after the time expires , the switch will remove this MAC entry.

 

2.  Interpretation of MAC table

The MAC address table mainly records the mapping relationship between the MAC address of the connected device and the switch port, and is queried during data forwarding.

as the picture shows:

PC1 and PC2 are connected to the switch at the same time

Use the display mac-address command on the switch to view the MAC address table

 image.png

 image.png

In the MAC address table:

a.  MAC Address item : indicates the host MAC address

b.  VLAN item: Indicates which VLAN this device is in , and the default device connected to the switch is VLAN1

( VLAN virtual local area network: a set of logical devices and users, not restricted by physical location )

c.  Port item: switch port


Thinking small question:

Is the aging time of the MAC address table entries of the switch fixed? Use your little head and join the discussion

 

Guess you like

Origin blog.51cto.com/14841124/2662973
Recommended