The idea
The physical layer only does one job: it pushes bits onto a wire, or pulls them off one, as a continuous stream. On its own that stream has no boundaries — no way to tell where one message stops and the next starts, and no addressing to say who it is for.
The data link layer’s first job is to fix that. It packs the message into frames: distinguishable units, each carrying enough structure that the receiving hardware can find the edges and read the addressing, before anything above it even gets involved.
A message is usually broken into a number of smaller frames rather than sent as one large one.
Where this actually happens
How it works
Hardware, not just software
The data link layer is not purely a piece of operating system code. Lecture 3 places it in the network interface card (NIC), or the equivalent chip on an Ethernet or WiFi device — a combination of hardware, software and firmware. It attaches into the host’s system buses, for example PCI.
Under IEEE 802.2 the data link layer is split into two sublayers:
- LLC — Logical Link Control
- MAC — Media Access Control
The lecture names both without going further into what each does day to day. Sharing one medium between multiple talkers — the part of the picture MAC sits closest to — is Module 4’s subject, not this one.
What goes in a frame
Every frame carries three kinds of content:
- Header — the source and destination addresses. These are physical addresses, added at this layer, and they are a different kind of address from the logical (IP) address carried inside the datagram the frame wraps.
- Trailer — redundant bits used for error detection. What those bits look like and how they are computed is its own topic, covered next.
- Flag — where a frame’s length can vary, a pattern marking the beginning and end of the frame, and signalling which protocol is in use.
Two ways to frame a message
| Framing | Frame length | Example | How the boundary is known |
|---|---|---|---|
| Fixed-size | Every frame the same length, decided in advance | ATM | Implicit — the length itself is the delimiter |
| Variable-size | Frames can differ in length | Ethernet | Explicit — needs a flag marking start and end |
Variable-size framing is the harder case, and it is why the flag exists at all: if the frame’s length is not fixed in advance, something inside the frame has to say where it starts and stops.
How it works
Flag and bit stuffing
The flag is a specific bit pattern placed at the start and end of the frame. Whenever the receiver sees that pattern, it knows a frame boundary is there.
That creates an obvious problem: what if the data itself happens to contain
the exact same pattern? Bit stuffing is the fix — the sender inserts an
extra 0 into the data whenever it would otherwise produce something that
looks like the flag, and the receiver strips that extra bit back out once the
frame has been correctly identified.
Character-oriented and bit-oriented
The slide names two kinds of variable-size framing — character-oriented and bit-oriented — side by side, and then gives one shared set of bullets under both. It does not say which technique belongs to which.
That is worth knowing before you read the slide, because the standard answer pairs them the other way round from how the slide’s layout suggests:
| Framing | Stuffing technique | How it works |
|---|---|---|
| Character-oriented (byte-oriented) | Byte stuffing | An escape character is inserted before any data byte that happens to match the flag byte. |
| Bit-oriented | Bit stuffing | A 0 is inserted after five consecutive 1s, so the data can never reproduce the flag pattern. |
Tutorial 3 (Q3) also asks which is more common historically and today. The slides do not answer that, so check your tutorial solution rather than relying on this page for it.
Where marks get lost
Header and trailer do different jobs
It is easy to blur these two together under “the extra stuff around the data.” They are not interchangeable:
- The header carries addressing — who sent the frame, who it is for.
- The trailer carries error-detection bits — whether the frame arrived intact.
A question asking “what does the trailer contain” that gets answered with an address is a wrong answer.
Check yourself
Two checks:
- A LAN technology sends every frame at a fixed 48 bytes. Does it need a flag to mark frame boundaries?
- What problem does bit stuffing solve, and how does the receiver undo it?
Answers: no — fixed-size framing does not need an explicit boundary marker,
because the length itself tells the receiver where the frame ends. Bit
stuffing prevents the data from accidentally matching the flag pattern by
inserting an extra 0; the receiver removes that extra bit once it has used
the flag to find the frame boundary.
In the exam
- Describe the services of the data link layer. Encapsulate the datagram into a frame, add header and trailer, add physical addressing — that is the standard short answer (Tutorial 3, Q1).
- Define framing and say why it is needed. A continuous bit stream has no boundaries; framing gives the receiver a way to find them and adds addressing (Tutorial 3, Q2).
- Fixed-size vs variable-size framing. ATM vs Ethernet is the lecture’s own pairing. Fixed-size needs no boundary marker; variable-size does.
- Header vs trailer. Header = addresses. Trailer = error-detection redundancy. Do not swap them.
- What bit stuffing is for. Stopping a data pattern from being mistaken for the flag.
- Where the data link layer runs. NIC or equivalent chip — hardware, software and firmware together, attached via the host’s system bus.