100% Free Forever
AI-Powered Learning
Industry Expert Content
Certificates & Badges
Learn At Your Own Pace

What is the Data Link Layer (OSI Layer 2)?

Learn what the OSI Data Link layer does, MAC addressing, framing, error detection, and how switches use it, with interview Q&A.

easyQ26 of 224 in Computer Networks Est. time: 5 minsLast updated:
Open Code Lab

Expected Interview Answer

The Data Link layer is OSI Layer 2 — it packages raw bits from the Physical layer into structured frames, adds MAC addresses for local delivery, and detects (though does not always correct) transmission errors using a frame check sequence.

The Data Link layer is commonly split into two sublayers: Logical Link Control (LLC), which manages flow control and identifies the upper-layer protocol, and Media Access Control (MAC), which handles addressing and controls how devices share access to the medium (e.g., CSMA/CD on classic Ethernet). Switches operate at this layer, learning which MAC address sits on which port and forwarding frames only to the correct destination rather than broadcasting everywhere like a hub does. Each frame carries a source and destination MAC address plus a frame check sequence (CRC) that lets the receiver detect corruption introduced during transmission. VLANs, PPP, and Wi-Fi’s 802.11 framing all operate at this layer, giving it responsibility for organizing raw bits into a form that Layer 3 (IP) can build addressing and routing on top of.

  • Frames raw bits with source/destination MAC addresses
  • Detects transmission errors via a frame check sequence (CRC)
  • Enables switches to forward frames intelligently, not just repeat them
  • Manages shared medium access to avoid or resolve collisions

AI Mentor Explanation

The Data Link layer is like the scorer’s ball-by-ball entry sheet, where each delivery is recorded with the bowler’s name and batter’s name attached before it is filed — raw play (Physical layer) becomes a structured record with sender and receiver identified. If a scribbled entry is illegible, the scorer flags it as an error rather than guessing, just as a bad frame check sequence flags a corrupted frame. A team’s scoring assistant sorting sheets by which player they concern mirrors a switch forwarding frames by MAC address. This structuring step is what turns raw signal into something the next layer can use.

Step-by-Step Explanation

  1. Step 1

    Framing

    Raw bits from the Physical layer are packaged into frames with defined start/end boundaries.

  2. Step 2

    Addressing

    Source and destination MAC addresses are added to identify sender and local recipient.

  3. Step 3

    Error detection

    A frame check sequence (CRC) is computed so the receiver can detect corrupted frames.

  4. Step 4

    Forwarding

    A switch reads the destination MAC and forwards the frame only to the correct port.

What Interviewer Expects

  • Clear definition: frames bits and adds MAC addressing
  • Knows the LLC vs MAC sublayer split
  • Understands switches operate here and how they learn/forward by MAC
  • Aware of frame check sequence for error detection

Common Mistakes

  • Confusing MAC addressing (Layer 2) with IP addressing (Layer 3)
  • Thinking the Data Link layer corrects errors rather than just detecting them
  • Not knowing switches, not routers, primarily operate at this layer
  • Forgetting VLANs and Wi-Fi (802.11) framing also live at Layer 2

Best Answer (HR Friendly)

The Data Link layer takes the raw electrical signal from the wire and organizes it into structured chunks called frames, tagging each one with the sender and receiver’s hardware address. It is also the layer that catches basic transmission errors, and it is what lets a network switch smartly deliver data only to the right device instead of blasting it everywhere.

Code Example

Inspecting Layer 2 frame and MAC info on Linux
# Show MAC address and Layer 2 stats for an interface
ip -s link show eth0

# Watch raw Ethernet frames on the wire (headers only)
sudo tcpdump -e -n -c 5 -i eth0

Follow-up Questions

  • What is the difference between the LLC and MAC sublayers?
  • How does a switch build and use its MAC address table?
  • What happens when a frame fails the CRC check?
  • How do VLANs operate at the Data Link layer?

MCQ Practice

1. What addressing does the Data Link layer use?

The Data Link layer identifies devices locally using MAC (hardware) addresses.

2. Which device primarily makes forwarding decisions at Layer 2?

A switch reads destination MAC addresses to forward frames only to the correct port.

3. What does a frame check sequence (FCS) do?

The FCS is a CRC value that lets the receiver detect if a frame was corrupted in transit.

Flash Cards

What is the Data Link layer?OSI Layer 2 — frames bits, adds MAC addressing, and detects transmission errors.

Two Data Link sublayers?LLC (Logical Link Control) and MAC (Media Access Control).

What device operates at Layer 2?A switch, which forwards frames based on learned MAC addresses.

How are errors detected at Layer 2?Via a frame check sequence (CRC) appended to each frame.

1 / 4

Continue Learning