What is data link layer?

What is data link layer?

Introduction

The Data Link Layer is the second layer in the OSI (Open Systems Interconnection) reference model. It acts as a bridge between the physical hardware (Layer 1) and higher-layer software protocols.

The Data Link Layer of the OSI (Open Systems Interconnection) paradigm. It is in charge of guaranteeing stable data transport between two directly connected nodes in a network. It serves as a bridge between the Physical Layer (Layer 1) and the Network Layer (Layer 3), converting raw bits into organized data units known as frames.

Framing, or the packaging of bits from the physical layer into digestible frames for transmission, is one of the Data Link Layer’s essential activities. It also handles error detection and repair, flow control, and MAC (Media Access Control) addressing to ensure that frames are delivered correctly and in the proper order.

The Data Link Layer is separated into two sublayers:

  • Logical Link Control (LLC) is in charge of recognizing network layer protocols and managing errors.
  • Media Access Control (MAC): Controls protocol access to the physical network media via MAC addresses.

This layer is essential in both wired (Ethernet) and wireless (Wi-Fi) networks. For example, it specifies how devices use the shared medium in Ethernet via CSMA/CD and Wi-Fi via CSMA/CA. Devices like switches, network interface cards (NICs), and bridges typically function at the Data Link Layer.


data link layer

Functions of the data link layer

The Data Link Layer serves a variety of functions, including:

  • This layer receives the stream of bits from the network layer and divides it into manageable data units called frames.
  • Data link protocols determine which device has control over the link at any point in time.
  • This layer adds mechanisms to detect and retransmit lost frames, increasing reliability.
  • The Data link layer adds a header to the frame that contains a destination address.
  • Flow control is the technique through which the constant data rate is maintained on both sides so that no data gets corrupted. 
  • When data frames are sent on the link, both machines must be synchronized in order for the transfer to take place.

Sub layers: LLC and MAC

LLC

The Logical Link Control (LLC) sublayer is located above the Data Link Layer in the OSI paradigm. Its major function is to interact with the Network Layer (Layer 3) and facilitate logical communication between devices via a physical medium. LLC controls how data is structured, addressed, and managed when it arrives at a network node. LLC is responsible for recognizing and encapsulating network layer protocols, as well as ensuring error and flow control between devices.

It uses Service Access Points (SAPs) to multiplex numerous network protocols (such as IPv4, IPv6, and IPX) over the same physical connection. This allows different network layer protocols to reside on the same device and medium. The LLC, unlike the MAC sublayer, is independent of the physical media. It includes acknowledgment frames and retransmission methods to provide reliability, particularly in connection-oriented services. IEEE 802.2 specifies the most often used LLC protocol, which is compatible with Ethernet (IEEE 802.3) and Wi-Fi (IEEE 802.11).


MAC

In the OSI model, the lower Data Link Layer is represented by the Media Access Control (MAC) sublayer. Its primary function is to manage how devices access and use physical communication mediums like Ethernet cables or radio waves in Wi-Fi. This sublayer specifies the rules for sending and receiving frames across a shared network. MAC handles physical addressing via MAC addresses, which are globally unique identifiers provided to each device’s network interface card (NIC). These addresses are used to identify the source and destination of each frame in a local area network (LAN). Another critical function of the MAC sublayer is media access control. In shared networks, multiple devices attempt to use the same medium.

MAC ensures that data collisions are minimized or handled effectively using methods such as:

  • CSMA/CD (Carrier Sense Multiple Access with Collision Detection) for wired Ethernet
  • CSMA/CA (Collision Avoidance) for Wi-Fi

The MAC sublayer operates directly with the hardware, interfacing with the Physical Layer to send and receive bits. It is specified in standards such as IEEE 802.3 (Ethernet) and IEEE 802.11 (Wi-Fi).


Framing in the data link layer

Framing is a critical function of the Data Link Layer in the OSI paradigm. It involves breaking the data stream into manageable chunks known as frames. Each frame includes not only the raw data (payload), but also critical control information including source and destination MAC addresses and error-checking bits.

This technique allows the receiver to tell where one frame finishes and the next begins. Framing ensures that, even if bits are lost or duplicated, the receiver can correctly identify and handle individual data elements.

Framing also enables:

  • Error detection
  • Flow Control
  • Retransmission of Lost Frames
  • Sequence of data

Character count, bit stuffing, byte stuffing, and flag-based framing are several framing strategies.


Frame structure in the data link layer

A frame is the entire packet of data prepared by the Data Link Layer for transmission. While frame structures differ amongst protocols (e.g., Ethernet, HDLC, or PPP), they commonly include the following components:

Common frame fields:

  • Header – Includes control information, such as source and destination MAC addresses.
  • Payload – The actual data passed by the Network Layer.
  • Trailer – Frequently includes Frame Check Sequence (FCS) for error detection.

Data link protocols

  • ARP Address Resolution Protocol
  • CDP Cisco Discovery Protocol 
  • PPP Point-to-point protocol 
  • SMLT Split multi-link trunking
  • UDLD Unidirectional Link Detection
  • IEEE802.11 wireless LAN
  • HDLC High-level data link control
  • FDDI Fiber Distributed Data Interface
  • CAN Controller Area Network 
  • EAPS Ethernet Automatic Protection Switching
  • MPLS Multiprotocol Label Switching

Error Detection and Correction Techniques

The Data Link Layer is crucial for guaranteeing reliable communication over a physical medium that is frequently subject to noise, interference, and bit-level mistakes. To ensure data integrity, this layer employs a variety of error detection and correction techniques that identify and, in certain cases, repair faulty data during transmission.

Error detection techniques

Party Bit – Where a single bit is added to ensure even or odd parity, allowing for the detection of single-bit errors.

Checksum – Breaks data into blocks and appends a computed sum; the receiver recalculates the checksum to verify data integrity.

Cyclic Redundancy Check (CRC) – CRC treats data as a polynomial and divides it by a predefined value to generate a CRC code, which is highly effective in detecting burst errors.


Error correction techniques

Automatic Repeat Request (ARQ) – where the receiver requests retransmission if errors are detected

Forward Error Correction (FEC) – Adds redundant bits to the data so the receiver can detect and correct errors independently. It is often used in real-time communication (e.g., satellite links, VoIP)


Flow Control Mechanisms

In the OSI model’s Data Link Layer, flow control is a vital function that controls the rate at which data is delivered between a sender and a receiver. Its major objective is to prevent the receiver’s buffer from overflowing when the source sends data at a faster rate. To do this, the layer employs numerous techniques, the most notable of which are the Stop-and-Wait Protocol, Sliding Window Protocol, and Credit-Based Flow Control.

1. Stop-and-Wait Protocol

  • The sender sends 1 frame and waits for a signal (ACK) before sending the next.
  • Example: Like sending one WhatsApp message and waiting for a “Seen” before sending another.
  • Good for simplicity, but slow.

2. Sliding Window Protocol

  • The sender sends multiple frames before waiting for an acknowledgment.
  • There’s a “window size” — only that many frames can be sent at once.
  • Faster and more efficient.
  • Example: Sending 5 messages at once, and confirming only when replies come.

3. Credit-Based Flow Control

  • The receiver tells the sender how many frames it can accept (called “credits”).
  • The sender only sends that many frames.
  • Used in high-speed networks like Fibre Channel.

MAC Addressing and Address Resolution

Each device’s Network Interface Card (NIC) is assigned a Media Access Control (MAC) address, which:

  • Is 48 bits long (e.g., 00:1A:2B:3C:4D:5E)
  • Is globally unique
  • Identifies devices on the same local network

MAC addresses are used to ensure the correct delivery of frames on a LAN.


Wired and Wireless networks

The Data Link Layer behaves differently in wired vs. wireless environments.

  • Wired (Ethernet): Uses CSMA/CD for collision detection
  • Wireless (Wi-Fi): Uses CSMA/CA to avoid collisions before they occur

Merits and Demerits

Merits

  • Enables reliable node-to-node communication across a physical link.
  • Divides data into organized frames to facilitate transmission.
  • Detects and corrects transmission mistakes via CRC or parity bits.
  • Controls data flow to avoid buffer overflow at the receiver.
  • Assigns and utilizes MAC addresses for device-level addressing.
  • Manages media access in shared networks to avoid clashes.
  • It supports both full-duplex and half-duplex communication.
  • Acknowledgment systems make retransmission more efficient.
  • Separates logical communication (LLC) from physical access (MAC).
  • Improves local network efficiency and stability.

Demerits

  • Only allows for local (node-to-node) communication, not end-to-end.
  • Increases protocol overhead due to framing and control bits.
  • Acknowledgment and retransmission introduce latency.
  • Increases the processing complexity for error detection and correction.
  • Without Layer 3, it is useless to connect separate network segments.
  • Functions may be duplicated that are already handled by dependable physical linkages.
  • Can be inefficient in high-speed or low-error networks.
  • Limited experience managing traffic across various or massive networks.
  • Frame collisions continue to occur in high-load shared media.
  • The complexity rises with protocol support such as PPP, HDLC, and LLC.