What is Switch?
A switch is a fast network device that gets incoming data bundles and diverts them to their endpoint on a Local Area Network. A LAN switch functions at the second layer of the OSI model i.e. Data link layer (Layer 2), for this it can support a wide range of network protocol.
Switches are more progressive than Hubs and less proficient than routers. In contrast to Hubs, switches can limit the traffic to and from each port so that all devices linked to the switch has an adequate quantity of bandwidth.
Important Functions of Layer 2 Switches
Switches perform three important functions as follows
- Address learning
- The forward/filter decision
- Loop avoidance
When a new switch is powered on, it does not have a MAC-table populated in this memory. Once the host transmits data to another host, the switch broadcast the frame to all the connected ports. When the other host replies, it learns the MAC address of both the hosts and stores it in the MAC table.
In the aforementioned diagram, device C data send data to Device A. The switch will broadcast to all ports expect port fa0/3 since the address is learned. If device A replies, the switch will learn the MAC address of A and the port number is stored in the MAC table.
After a switch has learned the MAC address of all the devices connected to it, it intelligently forwards unicast frames to the correct host by comparing the destination MAC of the frame with the address in the MAC table. When it finds a match, it then sends the frame to the respective port associated with it.
Referring to the aforementioned diagram
When a frame is received in interface fa0/1, the switches will look into its MAC table for address learning. Through the forward port, the address is learnt so that the switch does a unicast on the port fa0/2. This ensures that the frame is only forwarded out of the correct destination port.
When a switch received a broadcast frame coming into one of its ports, it will check for the correct listing of the source MAC in its MAC table or update the same if necessary and check the destination MAC of the frame for a match in the table
Since FF-FF-FF-FF-FF-FF matches the MAC of all host. The switch will flood the frame i.e. it sends out to every so that every host will receive the same. At this point, the switch is act similar to a hub.
In case of multicast, the switch deals with this process in the same way as a broadcast, flooding all ports to make sure that it reaches all the possible hosts in the group. This is inefficient because the traffic also hits those hosts who do not want the frame.
Having multiple paths to destinations for the purpose of redundancy is a good design for a network. This enables the traffic to take an alternate link if one link is not performing.
However, this feature can often cause a lot of problems on the network for switches.