πŸ”Œ Network Device: Switch

A Switch is a networking device that operates primarily at Layer 2 (Data Link Layer) of the OSI model, though some switches can also function at Layer 3 (Network Layer).


πŸ”Ή What is a Switch?

A Switch is an intelligent device used in LANs to connect multiple devices (like computers, printers, and servers). It uses MAC addresses to forward data only to the intended recipient, making communication more efficient compared to hubs.


πŸ”Ή How Does a Switch Work?

  1. Learning: The switch examines the source MAC address of each incoming frame and stores it in a MAC address table (a.k.a. forwarding table).
  2. Forwarding:
    • If the destination MAC address is known, the switch forwards the frame to the specific port where the destination device is connected. This minimizes unnecessary traffic on other ports, enhancing network efficiency.
    • If the destination MAC address is unknown, the switch doesn’t know which port to forward the frame to. In this case, the frame is flooded to all ports (except the port it came from), ensuring that the frame reaches the intended device. Once the destination device responds, the switch learns its MAC address and updates its MAC table for future use.
  3. Filtering: Unicast, multicast, and broadcast frames are filtered according to the destination.

πŸ”Ή Types of Switches

TypeDescription
UnmanagedPlug-and-play, no configuration required. Used in homes or small offices.
ManagedOffers advanced features (VLANs, QoS, SNMP). Used in enterprise networks.
Layer 3 SwitchSupports routing functions, works at Network Layer too.
PoE SwitchPowers devices like IP cameras and VoIP phones through Ethernet cables.

πŸ”Ή Switch vs. Other Devices

FeatureHubSwitchRouter
OSI LayerLayer 1 (Physical)Layer 2 (Data Link)Layer 3 (Network)
Data ForwardingBroadcasts to all portsUses MAC address tableUses IP address & routing table
IntelligenceNoMedium (MAC aware)High (IP + Routing aware)
EfficiencyLowHighVery High

πŸ”Ή Switch Features

  • MAC Address Table: Maps MAC addresses to ports.
  • Full Duplex Communication: Devices can send/receive simultaneously.
  • Loop Prevention: Uses protocols like STP (Spanning Tree Protocol).
  • VLAN Support (on managed switches): Segments networks logically.

πŸ› οΈ Common Use Cases

  • Building LANs in offices or homes.
  • Connecting devices in data centers.
  • VLAN segmentation for security and traffic management.
  • Enabling Power over Ethernet (PoE) for IP-based devices.

πŸ”Ή Switch in OSI & TCP/IP Models

OSI LayerRole of Switch
Layer 2Reads MAC addresses, forwards frames
Layer 3 (optional)Performs IP routing (Layer 3 switch)

πŸ“ Summary

Switches are central to efficient LAN communication, replacing hubs for their intelligent frame forwarding based on MAC addresses. They reduce network congestion, enhance performance, and support modern networking features like VLANs, PoE, and loop prevention.


Next Up: Routers, Bridges, Hubs, and other Networking Devices