There are three distinct functions of layer 2 switching: address learning, forward/filter decisions, and loop avoidance.
Address learning Layer 2 switches and bridges remember the source MAC address of each frame received on an interface, and enter this information into a MAC table called a forward/filter table.
Forward/filter decisions When a frame is received on an interface, the switch looks at the destination MAC address and finds the exit interface in the MAC table. The frame is only forwarded out the specified destination port.
Loop avoidance If multiple connections between switches are created for redundancy purposes, network loops can occur. Spanning Tree Protocol (STP) is used to stop network loops while still permitting redundancy.
When a switch is first powered on, the MAC table is empty. When a frame is received on a port, the source MAC address is placed in the MAC address table, along with the port ID of the port on which it was received. If the MAC address was already in the table, its associated aging countdown timer is reset (300 seconds by default). Then the MAC address table is searched using the destination MAC address to determine which action to take.
- Forward If the destination MAC address comes from another port within the switch, then the frame is sent to the identified port for transmission.
- Flood If the destination MAC address is not in the MAC address table, then the frame needs to be flooded and is sent to all ports except for the port through which it arrived. This action is known as unicast flooding.
- Filter If the destination MAC address comes from the same port on which it was received, (in another words, source mac address and destination mac address have the same exit port) then there is no need to forward it, and it is discarded.
here is an video explaining flood, don't confuse flood with broadcast
ICND1 and ICND2 break down