4.3.4 · D5Computer Networks

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

2,395 words11 min readBack to topic

Symbols and terms this page uses (define before you trap)

Before the questions weaponise notation, here is every symbol and term so nothing appears "cold". Match each one to a picture in the figures below.

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

Above: a message 1101 becomes coefficients of ; appending zeros shifts it left to make room for the check bits.


Visual anchor 1 — why XOR is subtraction of

Each division step "subtracts" , but over GF(2) subtraction is just XOR (bitwise, no borrows). The table below shows why the two operations coincide.

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

Left panel: ordinary binary addition carries (). Right panel: GF(2) addition wraps () — no carry, so add = subtract = XOR. That is the only arithmetic CRC long division ever uses.

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

The full XOR long division of 1101000 ÷ 1011: at each row, wherever the leading bit is 1 we XOR (subtract) 1011; where it is 0 we do nothing and slide down. The final three bits 001 are the remainder we append — read the red arrows top to bottom.


Visual anchor 2 — bit stuffing and de-stuffing timeline

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

A bit-level timeline: the sender's run of five 1s triggers a stuffed 0 (coral); the receiver's rule "after five 1s, drop the next bit" removes exactly that same 0, so payload is restored and the flag 01111110 can never appear inside data.


Visual anchor 3 — CSMA/CD collision round trip

Here is the worst case, walked through with the diagram below.

The setup. Node A starts sending. Its signal takes one-way delay (seconds) to crawl down the cable to the far node B. Suppose B — hearing nothing yet, because A's signal has not arrived — begins transmitting an instant before A's front reaches it. The two signals collide right at B.

Why , not . That collision's "news" is itself just a signal, and it must travel all the way back from B to A: another . So A only learns of the collision at time after it began. To detect the collision, A must still be transmitting at that instant — if A had already finished, it would have nothing to compare against.

Turning "still transmitting for " into a bit count. A transmits at bandwidth bits per second. In time seconds it emits

The seconds cancel, leaving a pure number of bits. Since A must not finish before , its frame must be at least this many bits long:

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

Space–time diagram — read the axes first: the horizontal axis is position along the cable (node A on the left, far node B on the right); the vertical axis is time, increasing downward. The lavender line is A's frame front travelling A→B over time . The collision (coral dot) happens at B, the moment A's front arrives. The coral line is the collision news travelling B→A, taking another . The green bracket on A's side marks the total A must stay transmitting to catch it. (Same round-trip logic underlies Stop-and-Wait & Sliding Window timing.)


True or false — justify

True or false: A byte-count framing scheme is safe as long as the payload never contains the flag byte.
False — byte-count has no flag; its danger is the count field itself getting corrupted, after which the receiver misjudges the boundary and loses sync for all following frames.
True or false: Bit stuffing inserts a 0 after every five 1s including the 1s inside the real flag 01111110.
False — stuffing is applied to the payload only, before the flags are attached. The genuine flag is added afterward and is never stuffed, which is exactly why it stays unique.
True or false: If a CRC check gives remainder 0, the frame is guaranteed error-free.
False — remainder 0 only means the received polynomial is divisible by . An error pattern that is itself a multiple of slips through, so it is "assume OK", never "guaranteed OK".
True or false: CRC arithmetic is ordinary binary arithmetic with carries.
False — CRC uses GF(2): addition and subtraction are both XOR, so with no carry (see the two-panel figure above). That is what lets us implement division with simple XOR gates.
True or false: A larger generator polynomial always detects more errors.
Mostly true in spirit — a higher degree catches all bursts up to length and more error classes, but detection power depends on 's structure (e.g. having factor or terms), not degree alone.
True or false: In CSMA/CD, once a node hears the medium is idle it may transmit and forget about listening.
False — the "CD" stands for Collision Detection: it must keep listening while transmitting. If it stopped listening it could never learn a distant collision happened.
True or false: Wi-Fi uses CSMA/CD just like wired Ethernet.
False — radios can't reliably hear their own signal drowned by a collision, so Wi-Fi uses CSMA/CA (avoidance): random backoff plus ACKs, not collision detection.
True or false: A MAC address is hierarchical like an IP address, so routers use it to find networks.
False — MAC is flat (a burned-in 48-bit ID with no network structure). It's used for delivery on the local link only; hierarchical routing is the job of IP addresses.
True or false: Making Ethernet's cable longer lets you keep the same minimum frame size.
False — longer cable means larger one-way delay , and grows with . A longer segment forces a larger minimum frame (or lower bandwidth) to keep collisions detectable.

Spot the error

Spot the error: "We append the CRC remainder because XOR-ing it in cancels the message."
Wrong cause — appending doesn't cancel the message, it cancels the leftover remainder. Since (where is the discarded quotient), adding gives , killing the remainder so the total is a clean multiple of .
Spot the error: "We append zeros to the message before dividing, where ."
Wrong count — we append exactly zeros (multiply by ), reserving slots for the check bits. has bits but that's the divisor's length, not the number of appended zeros.
Spot the error: "During XOR long division, whenever the leading bit is 0 we still XOR with ."
Wrong rule — a leading 0 means we XOR with 000 (i.e. do nothing) and just bring the next bit down. We only XOR the actual when the leading bit is 1 (see the division figure).
Spot the error: "CRC can correct a flipped bit by locating it from the remainder."
Wrong capability — CRC only detects. It gives a nonzero syndrome but no reliable pointer to which bit. Correction needs a code like Hamming; a failed CRC triggers discard/retransmit.
Spot the error: "In byte stuffing we prefix ESC only before flag bytes in the data."
Incomplete — you must also escape a data byte that equals ESC itself (ESC → ESC ESC), otherwise the receiver can't tell a real escape from a data ESC and unstuffing breaks.
Spot the error: "Binary exponential backoff picks a fixed wait time that doubles each collision."
Wrong — the wait is a random number of slots drawn from after the -th collision (recall is the collision counter). The range doubles; the actual wait is random within it, which is what de-synchronises colliding nodes.

Why questions

Why can't we just reserve the flag pattern and skip stuffing entirely?
Because random payload data will eventually produce the exact flag pattern, creating a false boundary. Stuffing guarantees the reserved pattern can never occur inside data.
Why does adding the factor to let it catch all odd-numbered bit errors?
An error polynomial with an odd number of terms evaluates to at ; a multiple of evaluates to there. So an odd-weight can't be a multiple of and is always detected.
Why must the sender still be transmitting when the collision signal returns in CSMA/CD?
Collision detection compares what it hears to what it sends. Once it stops sending it has nothing to compare against, so a late-arriving collision would go unnoticed — hence the floor (see the space–time figure).
Why is the worst-case collision round trip and not just ?
A bit travels to the far end () where a collision occurs, and the collision news must travel all the way back (). The last-to-learn node therefore needs of airtime. See Stop-and-Wait & Sliding Window for related round-trip timing.
Why does CRC treat bits as polynomial coefficients rather than just as a number?
The polynomial view turns "shift, divide, remainder" into clean GF(2) algebra, where divisibility of by exactly characterises which errors escape — a property plain integer arithmetic can't express so neatly.
Why does the data link layer exist at all if the Physical Layer already moves bits?
The physical layer moves raw bits with no notion of message boundaries or bit-flips. The link layer adds framing, error detection, and access control to turn a dumb bit-pipe into a usable frame-delivery service.

Edge cases

Edge case: The payload ends with exactly five 1s and nothing after — does bit stuffing still insert a 0?
Yes — the rule fires after any run of five consecutive 1s regardless of what follows (even end of data). The receiver's matching de-stuffing rule expects and removes that stuffed 0.
Edge case: What happens in CRC if the message is all zeros?
The dividend is all zeros, so the remainder is and the frame is all zeros — perfectly divisible by . It's valid, but a valid all-zeros frame carries no information, which is why real links avoid it.
Edge case: An error burst of length exactly hits the frame — is it guaranteed caught?
Not guaranteed — CRC guarantees only bursts of length . A burst of length can coincide with a multiple of and slip through, though the probability is small.
Edge case: Two Ethernet nodes on a zero-length cable () collide — is a minimum frame size still needed?
In the idealised case , so no size floor is forced. Real cables always have , and Ethernet fixes 64 bytes to cover its maximum legal segment length.
Edge case: A single-bit error hits a frame but has only one term (say ). Is it caught?
No — a single-bit error is , and is divisible by whenever . A generator must have terms to guarantee catching all single-bit errors.

Active Recall

Recall Which one property of

guarantees all single-bit errors are caught? must have at least two terms; then no single term is a multiple of .

Recall Restate the minimum-frame inequality and name each symbol.

: = min frame bits, = bandwidth (bits/sec), = one-way propagation delay (sec). The seconds cancel, leaving bits.

Recall In backoff, what is

and what does it control? is the collision counter () for the current frame; it sets the backoff window slots, which doubles each collision.