Layer 2 switch is A network device that forwards traffic based on MAC layer (Ethernet or Token Ring) addresses.
Bridging technology has been around since the 1980s (and maybe even earlier). Bridging involves segmentation of local-area networks (LANs) at the Layer 2 level. A multiport bridge typically learns about the Media Access Control (MAC) addresses on each of its ports and transparently passes MAC frames destined to those ports. These bridges also ensure that frames destined for MAC addresses that lie on the same port as the originating station are not forwarded to the other ports. For the sake of this discussion, we consider only Ethernet LANs.
Layer 2 switches effectively provide the same functionality. They are similar to multiport bridges in that they learn and forward frames on each port. The major difference is the involvement of hardware that ensures that multiple switching paths inside the switch can be active at the same time.
There are three distinct functions of layer 2 switching
Layer 2 switches and bridges remember the source hardware address of each
frame received on an interface, and they enter this information into a MAC database called a forward/filter table.
When a frame is received on an interface, the switch looks at the destination
hardware address and finds the exit interface in the MAC database. The frame is only
forwarded out the specified destination port.
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.