4.3.4 · D3Computer Networks

Worked examples — Data link layer — framing, error detection (CRC computation), MAC

3,116 words14 min readBack to topic

Before we start, two reminders — the arithmetic, and the name of the quotient.

XOR = "are these two bits different?" — 1 if they differ, 0 if they match. Keep that picture in mind for every division below.


The scenario matrix

Every CRC/framing/MAC question is one of these cells. Each worked example is tagged with the cell it fills.

# Case class What makes it tricky Example
C1 Standard division — nonzero message, sender side Get the long division right Ex 1
C2 Receiver check, no error Remainder must be exactly 000 Ex 2
C3 Single-bit flip in transit Remainder ≠ 0 → detected Ex 3
C4 Undetectable error ( divisible by ) The one case CRC MISSES Ex 4
C5 Degenerate: all-zero message Remainder is 000, sanity anchor Ex 5
C6 Burst error of length ≤ r Guaranteed caught — why? Ex 6
C7 Framing overlap: bit stuffing Different tool, same layer Ex 7
C8 Exam twist: CSMA/CD min frame Units, worst-case round trip Ex 8

We reuse one running generator so the arithmetic stays familiar:

Recall Why does

mean and "append 3 zeros"? has 4 bits, so its highest power is ; the degree . We multiply by — appending zeros — to reserve 3 low slots for the check bits.


Ex 1 — Standard division (cell C1)

Forecast: guess now — will have 3 bits or 4? (It must have bits, since .)

  1. Append zeros → dividend 1101000. Why this step? This is : shift left to reserve 3 slots for the check bits, exactly as the parent's Step 1.

  2. XOR-divide by 1011, aligning under each leading 1, bringing bits down otherwise. Figure s01 shows the full XOR long division of 1101000 by 1011: the dividend is the top white row; each red row is one XOR of against the current leading bits; each white row below a red row is the running result after that XOR; the final green row is the surviving remainder 001. Trace top-to-bottom: whenever the leading bit of the running result is 1 we XOR 1011 under it, then slide right. Why this step? Long division asks "how many copies of fit, position by position?" In GF(2) the only possible answers are 0 or 1, so at each slot we either XOR in (leading bit 1) or skip (leading bit 0). Repeating this from the top until fewer than bits remain is exactly what strips out every multiple of , leaving only the remainder.

    Figure — Data link layer — framing, error detection (CRC computation), MAC
    Figure s01 — Ex 1 sender division: dividend 1101000 ÷ 1011, remainder 001 (green).

  3. Read the last 3 bits that survive → . Why this step? Division stops when what remains has fewer bits than ; that leftover is the remainder.

  4. Build the frame . Why this step? — the appended 3 zeros are overwritten by the 3 check bits.

Verify: the concrete XOR steps in Figure s01 end in 001; and dividing 1101001 by 1011 must give remainder 000 (that is the whole point of appending ). We confirm both in Ex 2 and in the machine check below.


Ex 2 — Receiver check, clean frame (cell C2)

Forecast: if the parent's algebra is right, you should predict 000 before dividing.

  1. Divide 1101001 by 1011 with the same XOR long division, shown explicitly in Figure s02 (top white dividend, red XOR rows, green all-zero remainder row). Why this step? The receiver runs the identical algorithm — it does not know separately; it just checks divisibility of the whole received string.

    Figure — Data link layer — framing, error detection (CRC computation), MAC
    Figure s02 — Ex 2 receiver division: clean frame 1101001 ÷ 1011, remainder 000 (green) → accept.

  2. Trace it: the quotient bits fall out and the final remainder is 000. Why this step? Because exactly — recall , so in GF(2) (since ). divides with no leftover.

  3. Decision: remainder 000accept. Why this step? A zero remainder means is a genuine multiple of , which is the exact property the sender engineered; seeing it, the receiver has no detectable error to report, so it passes the frame up.

Verify: 1101001 mod 1011 = 000 — visible in Figure s02 and checked in =VERIFY=. A zero remainder is the anchor truth every later example is measured against.


Ex 3 — Single-bit flip in transit (cell C3)

Forecast: the error polynomial is (a single power). The parent said single-bit errors are caught if has terms — and has three terms. So predict detected (nonzero remainder).

  1. Received string 1111001 where (a single 1 in the 3rd position from the left). Why this step? A flipped bit is literally XOR-ing a 1 into that position — that XOR is the error. Counting powers from the right (position 0 = rightmost), the 3rd-from-left bit of a 7-bit word sits at power , so .

  2. Divide 1111001 by 1011, worked out fully in Figure s03 (top white dividend, red XOR rows) — the surviving remainder row is nonzero, the alarm bell. Why this step? The receiver cannot know an error happened; it only trusts the remainder, so we must actually run the division.

    Figure — Data link layer — framing, error detection (CRC computation), MAC
    Figure s03 — Ex 3 division of the flipped frame 1111001 ÷ 1011, remainder 100 (red) ≠ 000 → detected.

  3. Remainder = 100 ≠ 000error detected, discard the frame. Why this step? Undetected requires ; here (a single term) and has three terms with nonzero constant, so — the remainder is forced nonzero.

Verify: 1111001 mod 1011 = 100 — visible in Figure s03 and checked below. Note CRC only detected; it did not tell us which bit. Repair needs a Hamming Code, not CRC.


Ex 4 — The undetectable error (cell C4)

Forecast: danger — if is a multiple of , the receiver sees another valid frame. Here exactly. Predict NOT detected.

  1. Compute received . Why this step? We deliberately choose divisible by to construct CRC's blind spot.

  2. Divide 1100010 by 1011 → remainder 000. Why this step? Received — still an exact multiple of (here the quotient is just ), so the division leaves nothing.

  3. Decision: remainder 000 ⇒ receiver wrongly accepts a corrupted frame.

Verify: 1100010 mod 1011 = 000 — checked below. This is why we pick a good : to make such (multiples of ) statistically rare. It is also why CRC is detection, never a guarantee.


Ex 5 — Degenerate: all-zero message (cell C5)

Forecast: an all-zero dividend can never make a leading 1 appear, so guess .

  1. Append 3 zeros → dividend 0000000. Why this step? Same rule regardless of content: .

  2. Divide: every leading bit is 0, so we never XOR in; nothing changes. Why this step? XOR division only acts when the top bit is 1; all-zero input triggers zero operations.

  3. Remainder , so . Why this step? When no XOR ever fires, the trailing 3 bits stay exactly as we appended them — all zeros — so this is the algorithm's fixed point and the cleanest test that our division routine is correct.

Verify: 0000000 mod 1011 = 000 — checked below. This is the sanity floor: . If your code ever returns nonzero here, your division is broken.


Ex 6 — Burst error of length ≤ r (cell C6)

Forecast: the parent claimed all bursts of length are detected. Predict remainder ≠ 0 for any nonzero burst up to 3 bits wide.

Part A — the general proof.

  1. Write the burst as where has degree and (a burst starts and ends with the flipped edges). Why this step? A burst confined to a window is a low-degree shifted left by into position — that factorisation is the key. In Figure s04 the white lane is the 7-bit frame, the red highlighted 3-cell window is , and the yellow arrow shows the shift that slides that window into place.

    Figure — Data link layer — framing, error detection (CRC computation), MAC
    Figure s04 — Ex 6: a burst as ; red window = (width ≤ r), yellow arrow = the shift.

  2. Ask: can ? has constant term 1, so (a power of shares no factor with a whose constant term is 1). Why this step? Divisibility of a product needs to divide one factor; it can't divide .

  3. So would have to divide — impossible because and . Why this step? A smaller-degree nonzero polynomial can't be a multiple of a larger one.

  4. Conclusion: since , the received word is not a multiple of , so the division leaves a nonzero remainderevery ≤3-bit burst is detected. Why this step? The receiver's verdict is exactly "remainder result of dividing by ". We just proved cannot divide and it does divide , so it cannot divide their XOR-sum — the remainder is forced nonzero, which is precisely the detection signal.

Part B — concrete numeric burst.

  1. Take the burst (a 3-bit burst on the low end) hitting : received . Why this step? We instantiate the proof with real bits so you can watch the remainder come out nonzero.

  2. Divide 1101110 by 1011, shown in Figure s05 (same colour convention) → remainder 010 ≠ 000 ⇒ detected, exactly as Part A guaranteed.

    Figure — Data link layer — framing, error detection (CRC computation), MAC
    Figure s05 — Ex 6 concrete burst: 1101110 ÷ 1011, remainder 010 (red) ≠ 000 → detected.

Verify: received and 1101110 mod 1011 = 010 (nonzero) — checked below, matching the visual in Figure s05.


Ex 7 — Framing overlap: bit stuffing (cell C7)

Forecast: the rule inserts a 0 after every five consecutive 1s. There are six 1s in a row, so the count reaches five inside that run — predict exactly one stuffed 0, giving output length bits.

  1. Scan left to right, counting consecutive 1s: 0 (count 0), then 1 1 1 1 1 — the count hits five. Figure s06 lays this out as a coloured tape: input cells on top, the run of 1s in yellow, and the single green stuffed 0 dropping into place after the fifth 1. Why this step? The rule triggers on the fifth consecutive 1, before the sixth is written.

    Figure — Data link layer — framing, error detection (CRC computation), MAC
    Figure s06 — Ex 7 bit stuffing: input 01111110 (8 bits, yellow run of six 1s) → output 011111010 (9 bits) with the green stuffed 0 after the fifth 1.

  2. Insert a 0 right after the fifth 1: 0 11111 0 …. Why this step? This guarantees the reserved flag 01111110 can never form inside payload — a Physical Layer noise-free boundary marker.

  3. Continue with the remaining 1 0: the counter reset to 0 at the insertion, so no more stuffing. Stuffed stream . Why this step? After the insertion the run-length counter resets; the leftover 1 0 never reaches five, so exactly one 0 was inserted — 8 input bits become 9 output bits.

Verify: input 8 bits → output 9 bits (exactly one 0 inserted); and the flag 01111110 does not occur as a substring of 011111010 — checked below.

Recall Why does bit stuffing belong on this same worked-examples page as CRC?

Both are data-link-layer jobs on the raw stream from the Physical Layer: framing marks boundaries, CRC checks integrity. An exam frame question often chains them — stuff, then CRC, then transmit toward Ethernet.


Ex 8 — Exam twist: CSMA/CD minimum frame (cell C8)

Forecast: the sender must still be transmitting when the farthest collision news returns — a full round trip . Predict .

  1. Worst-case round trip . Why this step? Signal goes out () and the collision echo comes back (); the sender needs to be mid-transmission the whole time to hear it.

  2. Bits sendable in that time: . Why this step? Bits = rate × time. This is the parent's inequality solved for .

  3. Plug in units carefully: , : Why this step? The and cancel, leaving pure bits — always sanity-check that seconds cancel.

  4. Convert to bytes: . Why this step? Ethernet's famous 64-byte minimum frame is exactly this number — that's the "aha".

Verify: bits bytes — checked below. (This is why runt frames < 64 bytes are dropped.) Contrast with Stop-and-Wait & Sliding Window, where timing bounds reliability throughput rather than collision detection.


Active Recall

Recall Which single cell of the matrix is CRC's blind spot, and what characterises it?

Cell C4: any error pattern that is a multiple of . Received is still divisible, so remainder is 000 and the error passes.

Recall In Ex 8, why

and not ? The sender needs the collision to reach the farthest node () AND the garbled echo to return () while it is still transmitting — a full round trip.

Remainder of good frame
Always 000 (frame is an exact multiple of ).
Remainder of Ex 3 single-flip frame 1111001
100 (detected).
Remainder of Ex 4 frame 1100010
000 (undetected — ).
Ethernet minimum frame from
512 bits = 64 bytes.
Recall Stuffed output of

01111110 (8 bits)? 011111010 (9 bits) — one 0 inserted after the fifth consecutive 1.