Layer 2 devices are networking hardware that operate at the data link layer of the OSI model. They make forwarding decisions based on physical addresses, most commonly MAC addresses. These devices ensure data packets reach their intended destination within a local network segment.
Key Layer 2 Devices
The most common Layer 2 devices are:
- Switches: Switches are multi-port bridges that learn MAC addresses and forward data frames efficiently within a local network. They significantly improve network performance compared to hubs by directing traffic only to the intended recipient. A switch creates a separate collision domain for each port, reducing collisions.
- Bridges: Bridges connect two or more network segments. They analyze the MAC address of incoming frames and forward them only to the relevant segment. Bridges are less common than switches in modern networks because switches offer superior functionality.
- Network Interface Cards (NICs): Every device connected to a network needs a NIC. The NIC is responsible for communicating with the physical network medium (cables, wireless). While a core component, it's less frequently identified solely as a Layer 2 device in the context of larger network architecture discussions.
How Layer 2 Devices Work
A Layer 2 device, such as a switch, works by examining the MAC address in the data frame header. It uses this address to determine where to forward the data. When a frame arrives, the source MAC address is added to the switch's MAC address table (a temporary table maintained in the device's memory, usually for around 300 seconds). The switch then uses this table to determine the correct port for forwarding. If the destination MAC address is unknown, it broadcasts the frame to all ports (except the receiving port), until it learns the destination MAC address.
Practical Examples
- A switch connects several computers in an office network, allowing them to communicate with each other.
- A bridge connects two LAN segments to increase the overall network size.
- A NIC in your computer allows it to connect to your home Wi-Fi router.