Switching in the Data Link Layer
In any extensive network, data must be forwarded efficiently from a source device to its intended destination without congesting the entire system. This intelligent routing of data frames at the Data Link Layer is known as switching.
A network switch is an intelligent device that receives incoming data frames and strictly forwards them only to the specific port where the destination device is connected. This is vastly superior to older hub devices, which blindly broadcast data to every single connected device.
How a Switch Forwards Data
A switch relies on hardware MAC addresses to make intelligent forwarding decisions. It actively builds a MAC address table that maps every connected device's MAC address to its specific physical port on the switch.
- Known Unicast: The destination MAC address is already recorded in the table. The switch forwards the frame directly to the correct port.
- Unknown Unicast: The destination MAC address is not yet in the table. The switch floods the frame to all ports except the incoming port until it receives a response and learns the correct location.
- Broadcast: The frame is explicitly intended for all devices on the network. The switch forwards it out of every port except the incoming port.
Types of Switching Networks
- Circuit Switching: A dedicated communication path is physically established between two devices before any data is transferred. This path remains exclusively locked for the entire session, ensuring constant bandwidth but wasting resources if no data is actively flowing.
- Packet Switching: Data is fragmented into smaller, independent units called packets. These packets travel independently through the network and share resources with other users, making it highly efficient for modern networks like the internet.
- Message Switching: The entire message is transmitted from node to node using a store and forward approach. It is rarely used today due to excessive storage overhead and high transmission delays.
Switch Forwarding Techniques
- Store and Forward Switching: The switch receives the entire frame and rigorously checks it for errors using a Cyclic Redundancy Check before forwarding it. This guarantees high reliability but introduces a slight transmission delay.
- Cut Through Switching: The switch immediately begins forwarding the frame the exact moment it reads the destination MAC address. This method is incredibly fast but lacks error checking.
Spanning Tree Protocol (STP)
When redundant switches are connected to prevent complete network failures, they can accidentally create infinite routing loops known as broadcast storms. The Spanning Tree Protocol automatically detects these physical loops and mathematically blocks certain ports to create a loop free logical topology.
Virtual LAN (VLAN)
A Virtual LAN is a logical grouping of networking devices that acts as if they are connected to the exact same physical network, regardless of their actual physical location.
Without VLANs, every device on a switch receives all broadcast traffic. As a network scales, this broadcast traffic consumes massive amounts of bandwidth. VLANs solve this by logically dividing a single physical switch into multiple isolated broadcast domains.
Key Benefits of VLANs
- Reduced Broadcast Traffic: Broadcasts are strictly contained within their specific VLAN, freeing up bandwidth across the rest of the network.
- Enhanced Security: Devices in one VLAN cannot natively communicate with devices in another VLAN, keeping sensitive departmental data completely isolated.
- Logical Grouping: Users can be grouped by department or function rather than by physical desk location.
VLAN Tagging and Links
When VLANs span across multiple physical switches, the switches must be able to identify which VLAN a traveling frame belongs to. This is accomplished using the IEEE 802.1Q standard, which inserts a strict VLAN ID tag into the frame.
- Access Link: A direct connection between a switch and an end user device. Frames traveling on access links do not contain VLAN tags.
- Trunk Link: A high capacity connection strictly between two switches. Frames traveling on trunk links are explicitly tagged with their VLAN ID so multiple VLANs can share the same physical cable.
Inter VLAN Routing
Because each VLAN is a completely isolated broadcast domain, devices in different VLANs cannot natively speak to one another. To permit communication between two separate VLANs, a Layer 3 routing device must be used to inspect the IP addresses and securely route the traffic between them.
Switch vs Hub Comparison
| Feature | Network Switch | Network Hub |
|---|---|---|
| OSI Layer | Data Link Layer (Layer 2) | Physical Layer (Layer 1) |
| Data Forwarding | Intelligently forwards to a specific port. | Blindly broadcasts to all ports. |
| Collision Domain | Provides a separate collision domain per port. | Operates as one single massive collision domain. |
| Intelligence | Highly intelligent, utilizes a MAC address table. | No intelligence, cannot read addresses. |
