ELEC3506

Data LinkLecture 314 min

Framing — Packing Bits Into Frames

How the data link layer turns a raw bit stream into distinguishable frames, and the two ways it marks where one frame ends and the next begins.

By the end of this page you should be able to

  • Explain why a raw bit stream needs to be packed into frames
  • Describe where the data link layer actually runs, in hardware
  • Distinguish fixed-size and variable-size framing
  • Describe the header, trailer, flag and bit-stuffing that build a frame

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

FramingFrame lengthExampleHow the boundary is known
Fixed-sizeEvery frame the same length, decided in advanceATMImplicit — the length itself is the delimiter
Variable-sizeFrames can differ in lengthEthernetExplicit — needs a flag marking start and end
ATM and Ethernet are the lecture's own pairing for this comparison.

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:

FramingStuffing techniqueHow it works
Character-oriented
(byte-oriented)
Byte stuffingAn escape character is inserted before any data byte that happens to match the flag byte.
Bit-orientedBit stuffingA 0 is inserted after five consecutive 1s, so the data can never reproduce the flag pattern.
The slides do not state this pairing — it is the standard treatment, given here because Tutorial 3 Q3 asks you to compare the two protocol families directly.

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:

  1. A LAN technology sends every frame at a fixed 48 bytes. Does it need a flag to mark frame boundaries?
  2. 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.

Check yourself

  1. The physical layer only sends a raw stream of bits. What problem does framing solve?
  2. Where does the data link layer actually run?
  3. A network uses frames that are always exactly 53 bytes long, with no end-marker needed. What kind of framing is this?
  4. Why is bit stuffing needed?
  5. The frame header carries a source and destination address. What kind of address is this?