- Home >
- Explainers >
- OSI Layers
OSI Layer 2: Core Functions, Protocols, Security and Performance
- 12 minutes to read
Table of Contents
What Is OSI Layer 2 (Data Link Layer)?
OSI Layer 2, the Data Link Layer, provides node-to-node data transfer across a physical network link by framing data into frames, detecting and correcting errors, and controlling access to the network media. It uses MAC addresses for local network addressing, handles flow control to prevent data overload, and is responsible for reliable data transmission between adjacent network devices like switches and network interface cards (NICs).
Key functions of this layer include:
- Framing: The Data Link Layer packages data received from the Network Layer (Layer 3) into frames, which are chunks of data for transmission on the local network segment.
- Error detection & correction: It implements mechanisms to detect and sometimes correct errors that occur during transmission over the physical layer, ensuring data integrity.
- Flow control: This layer manages the rate of data transmission between devices to prevent a sender from overwhelming a receiver, a process known as flow control.
- Media Access Control (MAC): The MAC sublayer is responsible for controlling how network devices access the physical medium, resolving collisions when multiple devices try to transmit simultaneously.
- Physical addressing (MAC addresses): Layer 2 uses MAC addresses, unique identifiers assigned to network interface cards, to direct frames to the correct destination within the local network.
The Data Link Layer is often divided into two sublayers to manage its diverse functions:
- Media Access Control (MAC): Manages access to the physical network medium and uses MAC addresses for local addressing.
- Logical Link Control (LLC): Handles error control and flow control, interfacing with the upper layers of the OSI model.
The Role of Layer 2 in the OSI Model
Layer 2 bridges the gap between the physical hardware and higher-level protocols. It is responsible for converting raw bits from the physical layer into structured frames that can be processed by Layer 3 (network layer). This includes attaching source and destination MAC addresses, which identify devices within the same local network.
One of the tasks of the data link layer is to ensure error detection and handling through mechanisms like frame check sequences (FCS). It also manages access to the physical medium using protocols like CSMA/CD in Ethernet and CSMA/CA in Wi-Fi, controlling when devices can transmit data.
Layer 2 enables devices to communicate within the same broadcast domain and is integral to local area network (LAN) operations. By encapsulating Layer 3 packets into frames, it supports forwarding decisions made by switches and provides a foundation for network segmentation and virtual LANs (VLANs).
Core Functions of the Data Link Layer
Framing and Data Encapsulation
At Layer 2, data received from higher levels is packaged into structures known as frames. This framing process involves adding headers and trailers to the raw data payload, providing information needed for addressing, control, and error checking. Each frame is a self-contained unit that specifies start and end points, which helps hardware distinguish between individual messages on the network medium and separate valid transmissions from background noise or errors.
Encapsulation at the data link layer also establishes boundaries for data, supporting reliable delivery on shared media. The source and destination addresses, along with frame type information, ensure the network devices can process or forward the frame correctly.
Error Detection and Correction
Error detection at Layer 2 is typically handled by including special codes or checksums in the frame trailer, most often using methods like cyclic redundancy check (CRC). When a frame arrives at its destination, the receiving device recalculates the checksum and compares it to the value in the trailer.
If the values don’t match, the frame is identified as corrupted, prompting error handling procedures such as dropping the frame or requesting retransmission. While basic error detection is universal at Layer 2, not all Layer 2 protocols implement automatic error correction.
Some provide only detection, leaving correction to higher layers or manual processes. Others, like certain wireless protocols, may incorporate limited retransmission or acknowledgment schemes to improve reliability.
Flow Control and Reliable Delivery
Flow control mechanisms at Layer 2 regulate the pace at which frames are transmitted between sender and receiver. Without flow control, faster senders could overwhelm slower receivers, leading to dropped frames and inefficient network utilization. Most Layer 2 protocols address this with techniques such as pause frames (in Ethernet) or buffer management schemes that help coordinate transmission based on available resources at each endpoint.
Reliable delivery is further supported by acknowledgment schemes, retransmission strategies, or reserved information fields that track the status of frames in transit. While these capabilities aren’t as sophisticated as those found at higher layers like TCP, Layer 2 flow control and reliability mechanisms ensure that data isn’t needlessly lost or duplicated in the local transmission phase.
Addressing with MAC Addresses
Physical addressing is a feature of Layer 2, accomplished through the use of media access control (MAC) addresses. Each network interface on a device is assigned a unique MAC address, which is included in the header of every frame. This ensures that data is delivered to the correct physical device on the local network, regardless of higher-level IP addressing or protocols that may exist above Layer 2.
MAC addresses enable device-to-device communication within the same network segment and are fundamental to how switches make forwarding decisions. As frames traverse a network, each switch inspects the destination MAC address to decide whether to forward, filter, or broadcast the frame.
Sublayers of the Data Link Layer
Logical Link Control (LLC) Sublayer
The logical link control (LLC) sublayer, defined in IEEE 802.2, is responsible for managing communication between Layer 2 and the upper layers of the OSI model. LLC provides services like connection setup, maintenance, and teardown, as well as framing, addressing, and optional error and flow control.
This sublayer handles multiplexing protocols over the same data link, meaning multiple higher-level protocols can share a single physical link without conflicts. LLC also manages the sequencing and acknowledgment of frames, delivering services similar to those of transport protocols, albeit limited in scope to the local segment.
It ensures that frames are correctly identified and delivered to the appropriate Layer 3 protocol or application service. This isolation of logical control from physical access tasks allows hardware and software to evolve independently while retaining compatibility within the standardized stack.
Media Access Control (MAC) Sublayer
The media access control (MAC) sublayer operates closer to the physical network infrastructure and manages how devices on the same local network segment access the shared communication medium. It handles the assignment and recognition of hardware (MAC) addresses, implements collision avoidance and resolution techniques, and protects the integrity of data flows by enforcing rules on media access.
MAC protocols vary depending on the network type and can include carrier sense multiple access with collision detection (CSMA/CD), token passing, or polling schemes. The MAC sublayer also helps manage traffic by filtering frames based on their destination MAC addresses.
Switches use MAC address tables to make forwarding decisions, ensuring that only intended recipients receive data and that broadcast domains remain contained. By policing the use of shared resources and applying consistent addressing standards, the MAC sublayer is critical for efficient Layer 2 operation in modern networks.
Tips from the expert

Steve Moore is Vice President and Chief Security Strategist at Exabeam, helping drive solutions for threat detection and advising customers on security programs and breach response. He is the host of the “The New CISO Podcast,” a Forbes Tech Council member, and Co-founder of TEN18 at Exabeam.
Tips from the expert:
In my experience, here are tips that can help you better secure, optimize, and troubleshoot OSI Layer 2 (Data Link Layer) in enterprise networks:
- Implement MAC address rate limiting to prevent table poisoning: Set thresholds for the number of MAC addresses a single port can learn. This mitigates MAC flooding attacks and prevents rogue devices from exhausting switch resources.
- Use dynamic ARP inspection (DAI) with DHCP snooping for ARP integrity: Enable DAI in conjunction with DHCP snooping to verify ARP responses against known DHCP bindings. This thwarts ARP spoofing by validating MAC-to-IP mappings dynamically.
- Harden STP by explicitly configuring root bridge roles: Don’t rely on default STP elections; manually assign bridge priorities to ensure critical core switches are elected as root bridges. This prevents attackers from hijacking STP with superior priority claims.
- Segment wireless and wired networks into separate VLANs with ACLs: Avoid blending wired and wireless clients in the same Layer 2 domain. Use VLAN segmentation and Layer 3 access control lists (ACLs) to limit unnecessary cross-talk and contain wireless-specific threats.
- Enable port security with sticky MAC and violation actions: Use sticky MAC address learning for trusted ports and configure violation responses (shutdown or restrict) to immediately block unauthorized devices trying to impersonate valid endpoints.
How Layer 2 Interacts with Other OSI Layers
Relationship with Layer 1 (Physical Layer)
Layer 2 relies on Layer 1 (physical layer) for the actual transmission of unstructured bits over the network’s physical medium, be it copper wire, fiber optic, or wireless radio waves. The physical layer handles the voltages, currents, modulation, and timing required to send data from one point to another, while Layer 2 structures this data into frames that have context, destination, and error checking mechanisms.
The interface between Layer 2 and Layer 1 is critical for successful data exchange. Layer 2 must account for the limitations and behaviors of the underlying medium, adapting frame sizes, timing, and transmission strategies accordingly. In return, Layer 2 offers a level of abstraction and organization, filtering out spurious or noisy data.
Relationship with Layer 3 (Network Layer)
The data link layer delivers data to Layer 3, the network layer, once it has been correctly framed, addressed, and checked for errors. Layer 3 is responsible for logical addressing, routing, and the delivery of packets across networks, which can involve transit through multiple Layer 2 segments.
Layer 2 passes only the data relevant to its local segment and relies on Layer 3 to handle delivery beyond the local network. This separation enables flexible, scalable networks. Layer 2 ensures that only clean, verified data is handed off to Layer 3, reducing the risk of widespread network errors.
Layer 3 leverages Layer 2 for reliable local delivery and focuses its own resources on end-to-end routing, addressing, and policy enforcement. The synergy between these layers is essential for functional internetworking and for supporting complex, multi-segment network topologies.
Common Layer 2 Protocols and Standards
Ethernet (IEEE 802.3)
Ethernet is the most ubiquitous Layer 2 protocol, forming the basis for nearly all wired local area networks. Defined by the IEEE 802.3 standard, Ethernet specifies frame structure, MAC addressing, media access methods (like CSMA/CD), and standard data rates (ranging from 10 Mbps to 400 Gbps and beyond).
Its design allows scaling from small workgroup networks to large enterprise deployments. A feature of Ethernet is its support for broadcast and multicast frames, enabling device discovery and group communications. Switches use Ethernet frames’ MAC addresses to forward traffic only to intended recipients, helping control congestion and scalability.
Wi-Fi (IEEE 802.11)
Wi-Fi, governed by the IEEE 802.11 family of standards, brings Layer 2 functionality to wireless networks. It specifies not only how frames are structured and addressed but also details authentication, encryption, and radio-frequency management. Wi-Fi’s MAC sublayer is enhanced to cope with wireless challenges like signal interference, roaming, and shared channel contention.
A major aspect of Wi-Fi’s Layer 2 operation is support for dynamic association and authentication, which allow mobile devices to join and leave networks seamlessly. Features like frame retransmission, adaptive rate selection, and error correction make Wi-Fi suitable for a range of settings, from home access points to enterprise and public deployments.
PPP and HDLC
The point-to-point protocol (PPP) and high-level data link control (HDLC) are both Layer 2 protocols specialized for direct serial connections, such as WAN links provisioned between routers. PPP encapsulates frames for reliable delivery and adds features like authentication (PAP, CHAP), link negotiation, and multiplexing of Layer 3 protocols.
It is widely used for dial-up, DSL, and many VPN implementations. HDLC serves a similar purpose but is more often found in hardware-based WAN applications and within proprietary vendor environments. HDLC frames are simple and efficient, enabling simplified control and minimal overhead.
Frame Relay and ATM
Frame relay and asynchronous transfer mode (ATM) are Layer 2 protocols designed for WAN environments, providing high-speed, efficient data transfer over dedicated circuits or virtual connections.
Frame relay uses variable-size frames to maximize throughput and minimize overhead, making it popular for business-class and carrier-grade links prior to widespread broadband adoption. It is based on a simpler error checking and correction model, assuming the underlying physical links are reliable.
ATM takes a different approach, segmenting all data into fixed-size cells (53 bytes) to support predictable quality of service (QoS) and low latency, which is useful for voice, video, and mixed traffic types. ATM’s complexity and cost limited its deployment mainly to carrier networks and large institutions.
VLAN Tagging (IEEE 802.1Q)
VLAN tagging, defined in IEEE 802.1Q, allows the segregation of a physical network into multiple virtual local area networks (VLANs) at Layer 2. VLAN tags inserted into Ethernet frames enable network devices to recognize and enforce logical segmentation, even when traffic shares physical switches and cabling.
This boosts security, simplifies management, and isolates broadcast domains, which helps limit network congestion and failure impact. 802.1Q tagging is essential for modern network design, especially in multi-tenant or enterprise environments. Switches use VLAN tags to forward frames to the appropriate ports, maintaining separation between different user groups, departments, or applications.
Security Threats and Attack Vectors at Layer 2
MAC Table Exhaustion
MAC table exhaustion attacks target network switches, particularly those running in default or unmanaged modes. A switch tracks the association between MAC addresses and physical ports using a MAC address table to efficiently forward frames.
Attackers flood the network with frames containing bogus, randomly generated MAC addresses, causing the switch to fill its address table to capacity. Once the table is full, most switches revert to “fail-open” behavior, broadcasting all incoming frames to every port. This degrades network performance and enables attackers to sniff traffic not intended for them, potentially capturing sensitive data.
ARP Spoofing
ARP spoofing (or ARP poisoning) exploits the address resolution protocol, a fundamental Layer 2/Layer 3 function that maps IP addresses to MAC addresses. Attackers send forged ARP messages on a local network segment, tricking devices into associating the attacker’s MAC address with the IP address of a legitimate peer, such as a default gateway or server.
This redirection enables man-in-the-middle attacks, in which an attacker intercepts, modifies, or reroutes network traffic. The impact can range from session hijacking and credential theft to denial of service.
DHCP Spoofing
DHCP spoofing attacks target the dynamic host configuration protocol, which assigns IP addresses and other network settings on Layer 2 segments. An attacker deploys a rogue DHCP server on the local network, responding more quickly than the legitimate server to IP address requests from clients.
This causes unsuspecting hosts to accept malicious configuration settings, such as incorrect default gateways or DNS servers. As a result, attackers gain the ability to intercept or reroute network traffic, launch further man-in-the-middle attacks, or disrupt network operations.
BPDU Manipulation
BPDU (bridge protocol data unit) manipulation attacks target spanning tree protocol (STP), which is responsible for preventing loops in Layer 2 networks. Attackers inject fake BPDUs with manipulated priority or root bridge parameters, potentially altering the network’s logical topology or causing service disruptions as switches recalculate paths.
This can result in a hostile device being designated as the root bridge, gaining visibility or control over large portions of network traffic. Attackers may also deliberately destabilize the network, causing outages or degraded performance.
Learn more in our detailed guide to OSI layers attacks (coming soon)
Best Practices for Optimizing Layer 2 Performance
Here are some of the ways that organizations can improve their Layer 2 performance.
1. Maintain Accurate VLAN Design and Segmentation
Accurate VLAN design underpins efficient network segregation and helps localize broadcast traffic, reducing unnecessary congestion and improving fault isolation. Each VLAN should correspond to organizational needs, grouping devices with similar function or security requirements.
Avoid overlapping subnets or excessively large VLANs, which can increase collision domains and complicate troubleshooting. Documenting VLAN assignments and policies ensures that growth, changes, and troubleshooting efforts remain manageable. Dynamic VLAN assignment technologies, such as 802.1X with RADIUS integration, provide additional flexibility while enforcing security standards.
2. Implement Spanning Tree Protocol (STP) Efficiently
Spanning tree protocol (STP), defined by IEEE 802.1D and its enhancements, is essential for preventing Layer 2 loops that can lead to broadcast storms and network outages. Proper STP configuration ensures that only non-redundant paths remain active, with redundant links available for immediate fault recovery.
Efficient STP implementation involves setting bridge priorities, enabling rapid failover features like RSTP (802.1w), and safeguarding root bridge selection. Hardening STP with features such as BPDU Guard, Root Guard, and Loop Guard prevents malicious or accidental topology changes that could disrupt the network.
3. Minimize Broadcast Domains
Large broadcast domains can lead to congestion, high CPU utilization on end devices, and security risks, as broadcast traffic is delivered to all nodes within a domain. Splitting the network into smaller, logically segmented VLANs limits the scope of broadcast storms and isolates faults or misconfigurations to defined segments, protecting the broader network.
Strategically placing Layer 3 boundaries or leveraging router-on-a-stick designs further reduces the size of broadcast domains. This approach prevents unnecessary traffic from propagating across the entire network, improves security, and simplifies incident response.
4. Secure the Data Link Layer (MAC Filtering, 802.1X)
Securing Layer 2 access is crucial for preventing unauthorized network use, device impersonation, and lateral movement by attackers. Enforce MAC filtering to permit only known, trusted devices on sensitive ports, and leverage IEEE 802.1X for port-based network access control with authentication protocols like EAP (extensible authentication protocol).
These measures provide a first line of defense at the port level against common attacks or policy violations. Integrating Layer 2 security with centralized authentication and accounting systems allows for consistent policy enforcement, user tracking, and rapid response to suspicious activity.
5. Monitor and Automate Layer 2 Performance Metrics
Continuous monitoring of Layer 2 health and performance is vital for preemptive troubleshooting and fast incident response. Track metrics such as frame error rates, port utilization, MAC address table occupancy, VLAN traffic patterns, and STP status. Deploy network management systems that aggregate this data and trigger alerts for abnormal conditions or degraded performance.
Automation tools can simplify configuration enforcement, firmware updates, and policy compliance across the Layer 2 domain. Scheduled audits and vulnerability assessments should complement automated tasks, ensuring proactive risk reduction and rapid mitigation of issues.
Network Security with Exabeam
Exabeam’s security operations platform contributes to bolstering network security, including aspects related to OSI Layer 2. The platform ingests and analyzes various data sources, including network flow information, system logs, and user activity records. This comprehensive data collection provides visibility into the communication patterns and device behaviors occurring at the data link layer. By establishing baselines for normal Layer 2 operations, the platform can detect deviations that may signal a compromise or an attack vector.
When suspicious activity is identified, such as unexpected MAC address changes, unusual ARP traffic, or rogue DHCP server attempts, the platform correlates these events with other security intelligence. This correlation helps to contextualize Layer 2 anomalies within a broader threat landscape, allowing security teams to understand the potential impact and origin of an attack. The system’s ability to track sessions and user identities across different layers aids in attributing malicious Layer 2 actions to specific users or devices.
By leveraging advanced analytics and behavioral modeling, the platform supports the detection of sophisticated Layer 2 attacks that might evade traditional signature-based defenses. The goal is to provide security teams with actionable insights to investigate and respond to threats efficiently. This approach enables a more robust security posture by addressing vulnerabilities and malicious activities that specifically target the fundamental communication mechanisms at the data link layer.
Learn More About Exabeam
Learn about the Exabeam platform and expand your knowledge of information security with our collection of white papers, podcasts, webinars, and more.
-
Blog
What’s New in New-Scale April 2026: Securing the Agentic Enterprise With Behavioral Analytics
- Show More