Functions of a Switch
A switch is a device that is used at the Access or OSI Layer 2; a switch can be used to connect multiple hosts (PCs) to the network.
Unlike a hub, a switch forwards a message to a specific host. When any host on the network or a switch sends a message to another host on the same network or same switch, the switch receives and decodes the frames to read the physical (MAC) address portion of the message.
Forwards Frames with MAC address
When a message is sent between hosts on a network or the same switch, the switch checks its MAC address table for the destination address. A switch MAC address table contains a list of all active ports, host or PCs MAC addresses that are attached to it. If the destination MAC address is not found in the table, the switch will not have the necessary information to forward the message. When the switch cannot determine where the destination host is located, it will flood or forward the message out to all attached hosts. Each host compares the destination MAC address in the message to its own MAC address, but only the host with the correct destination address processes the message and responds to the it.
How Switches Learn MAC addresses
A switch builds its MAC address table by examining the source MAC address of each frame that is sent between hosts. When a new host sends a message or responds to a flooded message, the switch immediately learns its MAC address and the port to which it is connected. The table is dynamically updated each time a new source MAC address is read by the switch. In this way, a switch quickly learns the MAC addresses of all attached hosts.
Collision Prevention.
A switch prevents collisions by providing a circuit between the source and destination ports. This circuit provides a dedicated channel over which the hosts connected to the various ports on the switch can communicate. Each port is allocated with a separate bandwidth; these separate circuits allow many conversations to take place at the same time, without collisions occurring.