Skip to the content.

Lesson 6 – Data Link Layer (Layer 2)

Summary

In Lesson 6, we officially moved up from the Physical Layer (Layer 1), which covered the first five lessons, into the Data Link Layer (Layer 2). The professor illustrated the transition using a multi‑LAN diagram containing computers → switches → routers, and explained how message units grow in complexity as we move up the OSI model.


Part A — Transition From Layer 1 to Layer 2

A quick look at: VLANs and Inter-VLAN Routing

alt text

The following conceptual hierarchy exists:

OSI Layer Device Example Data Unit Name
Layer 1 – Physical Cables, NICs, bit-level transmission Cell / bit stream
Layer 2 – Data Link Switches Frame
Layer 3 – Network Routers Packet

📌 Increasing Data Abstraction

As we move upward in the OSI model:

This is why a cell becomes a frame, which later becomes a packet.


Layer 2 is responsible for node‑to‑node delivery. It ensures that the physical layer’s raw bits are grouped, structured, and reliable enough for the network layer.

⭐ Key Device: Switches

Switches operate using store-and-forward switching:

This behavior contrasts with routers (Layer 3), which make forwarding decisions based on IP headers.


Responsibilities of Layer 2

1. Framing

📘 Message → Cells (Framing Breakdown Diagram)

graph LR
    A[Header + Message] --> B[Header + C1]
    A --> C[Header + C2]
    A --> D[Header + C3]
    A --> E[Header + C4]

Each cell carries the same original frame header, while the message is segmented into smaller parts.

Framing means taking a stream of bits from Layer 1 and grouping them into structured, identifiable units called frames.

Why Do We Need Frames?

Layer 1 sends raw bits with no boundaries. Layer 2 must answer:

“Where does the message start, and where does it end?”

To do that, each frame contains:

📌 Layer Responsibilities

Each layer checks the layer below it and prepares data for the layer above it.

When a message moves down the layers:

Example:


Frame Boundary Detection

The receiver must know:

“These bits belong to the frame; these other bits do not.”

We where given the “beep before and after” analogy — meaning the sender marks boundaries.

One way to achieve this is Character Stuffing.

1. Character Stuffing / Byte Stuffing

Example using the character A as a delimiter:

The receiver scans forward:

Result


2. Bit Stuffing (Brief Overview)

Used when the protocol uses bit patterns instead of characters. For example, HDLC uses the pattern:

01111110   (flag)

Whenever the sender sees five consecutive 1s inside the data, it inserts a 0. The receiver removes these inserted 0s.

This prevents accidental appearance of the flag pattern inside the message.


Other Framing Methods (Brief Mentions)


2. Error Control (Introduction)

Layer 2 provides:

  1. Error Detection – identifying that something is wrong.
  2. Error Correction – locating and fixing the error.

Error Detection Examples

Error Correction Examples

(📌 Note: Full error‑control mechanisms such as parity, checksum, CRC, and Hamming will be discussed in Lesson 7.)


Switch Behavior — Flat vs. Intelligent Forwarding

Switches are originally flat devices, meaning:

Over time, switches build a MAC Address Table and become smarter.


Lesson Summary