4.3.4 · D4Computer Networks

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

2,499 words11 min readBack to topic

Level 1 — Recognition

L1.1 — Read a generator polynomial

Write the generator as a polynomial and state , the number of check bits, and how many zeros you append to the message.

Recall Solution

Read 11001 from the highest power down. Five bits → powers : Highest power present is , so . Check bits . You append 4 zeros to the message (multiply by ).

L1.2 — Bit stuffing recognition

The sender is about to transmit the payload bits 01111110. What must it actually send after bit stuffing, and why?

Recall Solution

The stuffing rule: after every 5 consecutive 1s in the data, insert a 0. Scan the payload one bit at a time, keeping a count of consecutive 1s:

  • 0 → count of ones resets to 0. Output so far: 0
  • 1 1 1 1 1 → five consecutive ones. Output them, then the rule fires: insert a stuffed 0 and reset the count. Output so far: 011111 + 0 = 0111110
  • remaining data 1 0 → the sixth original 1 (now the count starts fresh at 1), then 0. Output: 10

Final sent sequence (9 bits — exactly one stuffed 0 added). This guarantees the flag 01111110 (six ones in a row) can never appear inside the payload, because a 0 always breaks up any run before it reaches six.

L1.3 — MAC address vs IP address

Which of these is flat and which is hierarchical: a MAC address AA:BB:CC:DD:EE:FF or an IP address? Which is used for local delivery on the same link?

Recall Solution
  • MAC address = flat (no structure implying location), 48 bits, burned into the NIC. Used for local delivery on the one shared link.
  • IP address = hierarchical (network part + host part), used for end-to-end routing across networks — see Network Layer (IP). The link layer delivers within a link using MAC; the network layer forwards between links using IP.

Level 2 — Application

L2.1 — Full CRC long division

Message , generator . Compute the FCS (remainder) and the transmitted frame .

Recall Solution

has 3 bits → . Append 2 zeros: dividend 1011000. The method: scan the dividend left to right. Whenever the current leading bit is 1, XOR the 3-bit pattern 101 starting at that position (this is the "subtract " step over GF(2)). Whenever it is 0, do nothing and move one position right. The final bits left over are the remainder.

Here is the full aligned walk (the moving 3-bit window is underlined by the 101 below it):

 1011000     leading bit 1 -> XOR 101
 101
 -----
 0001000     next leading 1 is at position 4
    101
    -----
 0000010     next leading 1 is at position 6
      10 1   -> but only 2 bits remain; window is 101
      101
      -----
 0000000  R = last 2 bits = 10

Reading the trailing bits gives remainder . Let's sanity-check by re-tracing the three XOR events on the raw 7 bits 1011000:

  1. Position 0 leading 1: 101101 = 000. Stream → 0001000.
  2. Position 3 leading 1: 100101 = 001. Stream → 0000010.
  3. Position 5 leading 1: 1010 (last two bits, top of 101 aligned) leaves the final two bits 10.

So (this is confirmed by the machine check in =VERIFY=: ). Transmit .

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

The figure above lays the same division out as stacked XOR rows — follow the orange 101 rows (the parts we XOR) down to the plum remainder 10.

L2.2 — Receiver check

The receiver gets 1011010 with generator 101. Divide and decide: accept or reject?

Recall Solution

Divide 1011010 by 101. Since we constructed to be an exact multiple, the remainder is 00. Remainder accept (no detectable error).

L2.3 — Minimum frame size in CSMA/CD

An Ethernet-like link has bandwidth bit/s and one-way propagation delay . Find the minimum frame size in bits, then in bytes.

Recall Solution

The rule from the parent note: Why: the sender must still be transmitting when the worst-case collision signal returns after a full round trip . This is exactly why classic Ethernet's minimum frame is 64 bytes.


Level 3 — Analysis

L3.1 — Which errors slip past?

Using (), a single-bit error flips exactly one bit, so . Explain whether any single-bit error can go undetected.

Recall Solution

An error is undetected iff . Here . For to divide , since has only the factor repeated, would have to be a power of — i.e. would have to be 100...0 (only its top term). But has more than one term (). A polynomial with terms cannot divide . Therefore no single-bit error is undetected — all single-bit errors are caught. ✅

L3.2 — Odd-weight errors and the factor

Show that if has as a factor, then every error affecting an odd number of bits is detected. (Hint: evaluate polynomials at over GF(2).)

Recall Solution

Key tool — why substitute ? Over GF(2), plugging into a polynomial adds up all its coefficients mod 2. That sum the number of terms mod 2 the parity (odd/even) of how many bits are 1.

  • Let be an odd-weight error: it has an odd number of 1 coefficients, so .
  • Suppose . If , then too, meaning .
  • Evaluate at : .
  • But we said . Contradiction! So cannot divide an odd-weight ⇒ every odd number of bit errors is detected. ✅ (This is exactly the trick a simple parity bit uses; CRC generalises it — compare with Hamming Code which goes further and corrects.)

L3.3 — Burst error limit

has degree . A burst error of length flips a contiguous run of bits (first and last of the run are flipped, middle may be anything). For which burst lengths is detection guaranteed?

Recall Solution

A burst of length can be written where describes the run, , and has a nonzero constant term (its lowest bit is flipped).

  • does not divide (assuming has terms, so ).
  • So detection fails only if . That needs , i.e. , i.e. . Therefore every burst of length is guaranteed detected. Bursts of length may slip through, but only a tiny fraction of them.

Level 4 — Synthesis

L4.1 — Framing then CRC, in order

You must send payload 0111110 (7 bits) over a bit-stuffed link, and it carries a CRC with . Which happens first — stuffing or CRC — and produce the final on-wire bits (ignore the outer flags).

Recall Solution

Order matters: CRC is computed over the frame contents, then the whole thing (contents + FCS) is bit-stuffed for framing, and flags are added last. Reverse order would corrupt the CRC when a stuffed 0 is inserted.

Step 1 — CRC. , , append 00 → dividend 011111000. Divide by 101 using the same XOR method as L2.1. The trailing bits give remainder (confirmed by the machine check in =VERIFY=: ). Frame contents .

Step 2 — bit-stuff 011111010: scan for five consecutive 1s. 0 11111 010 — after the five 1s insert a 0: On-wire contents (between flags) . The receiver un-stuffs first (remove the 0 after five 1s) to recover 011111010, then CRC-checks it. ✅

L4.2 — Backoff analysis

In CSMA/CD binary exponential backoff, after the -th collision a station waits a random number of slots uniformly in . After the 3rd collision, list the possible waits and give the probability of waiting exactly 0 slots.

Recall Solution

After collisions, the range is → possible waits , that's equally-likely values. Why exponential? Each collision doubles the window, spreading contending stations further apart in time so a repeat collision becomes exponentially less likely — this stabilises a busy Ethernet segment.


Level 5 — Mastery

L5.1 — Design a generator

You need a CRC that catches (i) all single-bit errors, (ii) all odd-weight errors, and (iii) all bursts up to length 4. State the minimum degree and give a concrete meeting all three, then write its bit string.

Recall Solution

Requirements → constraints on :

  • (i) all single-bit: must have terms. ✅ easy.
  • (ii) all odd-weight: must have factor .
  • (iii) bursts up to length 4: need (bursts of length are caught). So minimum degree . Pick of degree 4 that has as a factor and terms. Take . Multiply over GF(2): ( over GF(2).) So . Bit string (powers ): . Check: 4 terms → ✅; contains factor by construction ✅ (); degree 4 ✅.

L5.2 — End-to-end scenario

A 10 Mbit/s () shared bus is long. Signal speed on the cable is . (a) Find one-way . (b) Find in bits and bytes. (c) A station sends a 64-byte frame — is that safe for collision detection?

Recall Solution

(a) (b) bits bytes. (c) 64 bytes bits bits, so the frame lasts far longer than one round trip — the sender is guaranteed still transmitting when any collision echo returns. Safe.


Active Recall

Recall For

, what is and how many zeros are appended? ; append 4 zeros.

Recall Order of operations: CRC vs bit-stuffing?

Compute CRC over payload first, then bit-stuff (payload+FCS), then add flags. Reverse breaks the check.

Recall Why does

guarantee odd-weight detection? for odd weight, but if then so — contradiction.

Recall

for , ? bits bytes.