OSI Model·Lesson 5 of 12

Layer 2 — Data Link

01

From Bits to Frames

Layer 1 gives us a stream of raw bits, but a bare stream of 1s and 0s isn't very useful — where does one message end and the next begin? That's the problem the Data Link layer (Layer 2) solves. It groups the bits into tidy, labelled packages called frames, puts a local address on each one, and makes sure it gets to the correct device on the same local network.

The one-liner

Layer 2 handles node-to-node delivery: it moves a frame from one device to the next device it's directly connected to, using hardware (MAC) addresses. Think 'one hop at a time' within a single local network.

🤝

Passing a note down a row

Imagine passing a folded note along a row of people until it reaches the right person. Each hand-to-hand pass is a single 'hop', and you only need to know your immediate neighbour to make the pass. The Data Link layer works hop by hop like this — it worries about getting the frame to the next directly connected device, not the whole journey across the internet.

02

What It's Responsible For

The Data Link layer takes on several jobs that turn a raw bit stream into reliable local delivery:

Data Link layer responsibilities

  • Framing — grouping bits into structured frames with a clear start and end, so the receiver knows where each one begins
  • Physical addressing — stamping each frame with the sender's and receiver's MAC (hardware) addresses
  • Error detection — adding a check value so the receiver can spot a frame that got corrupted in transit
  • Flow control — pacing the sender so it doesn't overwhelm a slower receiver
  • Media access control — deciding which device is allowed to transmit when several share the same medium
03

MAC Addresses

The address used at this layer is the . Every network adapter — your laptop's Wi-Fi card, your phone's chip — is given one by the manufacturer, and it's meant to be unique to that piece of hardware. It's a 48-bit number usually written in hexadecimal, like 00:1A:2B:3C:4D:5E. Because it identifies the physical device, it's often called the physical or hardware address.

Here's a distinction beginners must nail: a MAC address is not the same as an IP address. The MAC address (Layer 2) identifies a device on the local network and doesn't change as it moves around a building. The IP address (Layer 3, the next layer up) is a logical address used to route data across different networks. Roughly: MAC gets a frame to the right device on this network; IP gets a packet to the right network in the first place.

MAC address (Layer 2)IP address (Layer 3)
TypePhysical / hardwareLogical
Assigned byThe manufacturerThe network / admin
ScopeThe local networkAcross networks (the internet)
Changes?Fixed to the deviceCan change by location
Used forDelivery to the next deviceRouting to the right network
04

Two Sublayers

The Data Link layer is split into two smaller sublayers, each with a focused role. Knowing their names is a common interview detail:

The two sublayers

  • LLC (Logical Link Control) — the upper sublayer; handles flow control and error control and provides a clean interface to the Network layer above
  • MAC (Media Access Control) — the lower sublayer; adds MAC addresses and decides who gets to use the shared medium and when
05

Devices That Live Here

The classic Layer 2 device is the . Unlike a hub, which blindly copies signals everywhere, a switch reads the MAC address on each frame and forwards it only to the port where that device actually is. That's why a switch is called 'smart' and a hub is not. A bridge and a standard network adapter also operate at this layer.

🚫

"MAC addresses are used to route data across the internet."

MAC addresses only work within a single local network — they get a frame to the next directly connected device. Routing across many networks is done with IP addresses at the Network layer. A MAC address never travels beyond the local link; each hop uses fresh source and destination MAC addresses.

Q:What is the role of the Data Link layer?

A: It provides node-to-node (hop-to-hop) delivery over a single link. It frames the bit stream into frames, adds source and destination MAC addresses, detects transmission errors, does flow control, and manages access to a shared medium. It has two sublayers — LLC and MAC — its PDU is the frame, and switches and bridges operate here.

Quick Revision Cheat Sheet

Layer number: 2

Job: Node-to-node delivery over a single link

PDU (data unit): Frame

Addressing: MAC (physical / hardware) address, 48-bit

Key tasks: Framing, error detection, flow control, media access

Sublayers: LLC (Logical Link Control) and MAC (Media Access Control)

Devices: Switch, bridge, network adapter