CS331 · Chapter 3 · Part 1 · Annotated SlidesData Link Layer: Framing and Error Control
Original
Overview

Data Link Layer: Framing and Error Control

What the data link layer does, how frames are marked off (byte and bit stuffing), single-bit vs. burst errors, and the three detection methods: parity (simple and two-dimensional), CRC and the Internet checksum, then retransmission vs. forward error correction. Tutorial 4 is entirely parity, CRC and checksum calculations; the worked answers are in the questions on each method’s slides.

How to read this page

Every original slide is shown unchanged. Yellow marks on a slide point to a numbered note: hover or tap a mark to jump to its note, and hover a note to see its marks. Questions tagged Past exam appeared on a real paper; Prediction questions are likely angles, not confirmed. Pick an answer to each question: a wrong pick tells you why it is wrong, so you can try again.

All 53 slides
  1. 1 Data-Link Layer
  2. 2 Chapter 3: Outline
  3. 3 Chapter 3 DLL services
  4. 4 Framing
  5. 5 DLL services
  6. 6 Framing
  7. 7 A frame in a character-oriented protocol
  8. 8 Byte stuffing and unstuffing
  9. 9 A frame in a bit-oriented protocol
  10. 10 Bit stuffing and unstuffing
  11. 11 Note: errors happen
  12. 12 Types of error
  13. 13 Note: single-bit error
  14. 14 Single-bit error
  15. 15 Note: burst error
  16. 16 Burst error of length 5
  17. 17 Example
  18. 18 Note: redundancy
  19. 19 Detection methods
  20. 20 The structure of encoder and decoder
  21. 21 Encoder and decoder for simple parity-check code
  22. 22 Note: parity check
  23. 23 Table Simple parity-check code C(5, 4)
  24. 24 Example 1
  25. 25 Example 2
  26. 26 Example 3
  27. 27 Note: what simple parity can detect
  28. 28 Note: two-dimensional parity
  29. 29 Two-dimensional parity
  30. 30 Two-dimensional parity: what it detects
  31. 31 CRC generator and checker
  32. 32 Note: the generator
  33. 33 A polynomial to represent a binary word
  34. 34 Division in CRC encoder
  35. 35 Division in the CRC decoder for two cases
  36. 36 Binary division in CRC checker
  37. 37 CRC summary
  38. 38 Standard polynomials
  39. 39 Advantages of Cyclic Codes
  40. 40 Example
  41. 41 Example (continued)
  42. 42 Checksum
  43. 43 Data unit and checksum
  44. 44 Checksum: sender site
  45. 45 Checksum: receiver site
  46. 46 Example 7
  47. 47 Example 8
  48. 48 Example 9
  49. 49 Error correction
  50. 50 Error correction 1: retransmission
  51. 51 Error correction 2: forward error correction (FEC)
  52. 52 Burst Error Correction Chunk Interleaving
  53. 53 Interleaving
Slide 1 / 53

Data-Link Layer

Slide 1: Data-Link Layer

Notes

  1. DLL services → framing (byte / bit stuffing) → error types → detection: parity, 2D parity, CRC, checksum → correction.

  2. Tutorial 4 = calculations on parity, CRC and checksum. Practise each by hand.

Slide 2 / 53

Chapter 3: Outline

Slide 2: Chapter 3: Outline

Notes

  1. This part is 3.1 introduction and 3.2 data link control (framing, error control). Part 2 is 3.3 media access control.

Slide 3 / 53

Chapter 3 DLL services

Slide 3: Chapter 3 DLL services

Notes

  1. Seen again Ch 1 Part 2, slide 28: Data link layer overview

Slide 4 / 53

Framing

Slide 4: Framing

Notes

  1. Framing = packing bits into frames so the receiver knows where each one starts and ends (like envelopes).

  2. The destination address says where it goes; the sender address lets the receiver acknowledge it.

Slide 5 / 53

DLL services

Slide 5: DLL services

Notes

  1. Trap Flow control protects the RECEIVER from being flooded; congestion control (Ch 9) protects the NETWORK.

  2. Seen again Ch 3 Part 2, slide 2: Media access control

  3. Seen again Ch 9, slide 6: Flow and error control at the transport layer

Exam angle

PredictionQ1

Making sure the sender does not send faster than the receiver can process is:

PredictionQ2

Controlling access to a shared medium is done by the:

Slide 6 / 53

Framing

Slide 6: Framing

Notes

  1. Character (byte) oriented: frame length is a whole number of bytes. Bit oriented: any number of bits.

Exam angle

PredictionQ1

A framing protocol whose frame length need not be a multiple of 8 bits is:

Slide 7 / 53

A frame in a character-oriented protocol

Slide 7: A frame in a character-oriented protocol

Notes

  1. A flag byte marks the start and end of every frame.

Slide 8 / 53

Byte stuffing and unstuffing

Slide 8: Byte stuffing and unstuffing

Notes

  1. Problem: the flag pattern can appear inside the data.

  2. Trap ESC itself must also be escaped, or the receiver would drop a real ESC byte from the data.

Exam angle

PredictionQ1

In byte stuffing, the sender adds an extra ESC byte:

PredictionQ2

Byte stuffing is done at the receiver.

Slide 9 / 53

A frame in a bit-oriented protocol

Slide 9: A frame in a bit-oriented protocol
Slide 10 / 53

Bit stuffing and unstuffing

Slide 10: Bit stuffing and unstuffing

Notes

  1. After five 1s in a row, the sender always inserts a 0, even if the next bit is already 0. So 01111110 can never appear in the data.

  2. Memory trick Count to five 1s, then add a 0. Restart the count after the stuffed 0.

Exam angle

PredictionQ1

After bit stuffing, the data 0111111 becomes:

PredictionQ2

Bit stuffing inserts a 0 after how many consecutive 1s?

PredictionQ3

Stuff the bits 0001111111001111101000 for transmission with flag 01111110.

Compare with the model answer

000111110110011111001000: a 0 goes in after the first five 1s of the 1111111 run and after the five 1s of 11111.

Slide 11 / 53

Note: errors happen

Slide 11: Note: errors happen
Slide 12 / 53

Types of error

Slide 12: Types of error
Slide 13 / 53

Note: single-bit error

Slide 13: Note: single-bit error
Slide 14 / 53

Single-bit error

Slide 14: Single-bit error
Slide 15 / 53

Note: burst error

Slide 15: Note: burst error

Notes

  1. Burst: TWO or more bits changed (not necessarily next to each other).

Slide 16 / 53

Burst error of length 5

Slide 16: Burst error of length 5

Notes

  1. Burst length = from the first corrupted bit to the last, counting the good bits in between.

  2. The faster the link, the more bits a burst of noise hits.

  3. Trap A burst of length 5 may corrupt only 3 bits: the length counts from first to last bad bit.

Exam angle

PredictionQ1

In a burst error, the corrupted bits must be consecutive.

PredictionQ2

Bits 3 and 9 of a frame are corrupted and nothing in between. The burst length is:

Slide 17 / 53

Example

Slide 17: Example

Notes

  1. Same 2 ms of noise: 2 bits on a slow link, 2 million on a fast one. That is why burst errors are worse at high rates.

Exam angle

PredictionQ1

A 5 ms burst of noise hits a 100 Mbps link. How many bits are affected?

Slide 18 / 53

Note: redundancy

Slide 18: Note: redundancy

Notes

  1. Every detection method sends EXTRA (redundant) bits along with the data.

Slide 19 / 53

Detection methods

Slide 19: Detection methods

Notes

  1. Parity check · CRC · checksum.

Exam angle

PredictionQ1

Which is NOT an error-detection method?

Slide 20 / 53

The structure of encoder and decoder

Slide 20: The structure of encoder and decoder

Notes

  1. Sender: a generator adds redundant bits. Receiver: a checker recomputes them and accepts or discards.

Slide 21 / 53

Encoder and decoder for simple parity-check code

Slide 21: Encoder and decoder for simple parity-check code
Slide 22 / 53

Note: parity check

Slide 22: Note: parity check

Notes

  1. Memory trick Even parity bit = 1 if the data has an ODD number of 1s (so the total becomes even).

Slide 23 / 53

Table Simple parity-check code C(5, 4)

Slide 23: Table Simple parity-check code C(5, 4)

Exam angle

PredictionQ1

With even parity, the dataword 1011 becomes:

Slide 24 / 53

Example 1

Slide 24: Example 1

Notes

  1. Each 7-bit ASCII character gets one even-parity bit: count the 1s and add 0 or 1 to make the count even.

Exam angle

Past exam · Tutorial 4

Q2 · even parity on 7-bit datawords

Past exam · Tutorial 4Q1

With even parity, the 7-bit dataword 1111000 becomes:

Past exam · Tutorial 4Q2

With even parity, 1010101 is sent as:

Slide 25 / 53

Example 2

Slide 25: Example 2
Slide 26 / 53

Example 3

Slide 26: Example 3

Exam angle

Past exam · Tutorial 4

Q2b · which received codewords are valid

PredictionQ1

With even parity, the receiver gets 10101010, 11110001 and 00000001. Which are valid, and can it correct the bad ones?

Compare with the model answer

10101010 has four 1s → valid. 11110001 has five 1s → invalid. 00000001 has one 1 → invalid. Simple parity only detects; it can’t tell which bit flipped, so the receiver discards and asks for retransmission.

Slide 27 / 53

Note: what simple parity can detect

Slide 27: Note: what simple parity can detect

Notes

  1. Trap Two flipped bits keep the parity the same, so simple parity misses every even number of errors.

Exam angle

PredictionQ1

Simple parity check can detect all burst errors.

PredictionQ2

Simple even parity will NOT detect an error when:

Slide 28 / 53

Note: two-dimensional parity

Slide 28: Note: two-dimensional parity

Notes

  1. 2D parity: arrange the data in rows; add a parity bit to each row AND a parity row for the columns.

Slide 29 / 53

Two-dimensional parity

Slide 29: Two-dimensional parity

Notes

  1. Row parities catch which row; column parities catch which column. One bad bit = the crossing point, so it can be corrected.

Exam angle

Past exam · Tutorial 4

Q1 · 2D parity for 1010, 0111, 1100, 1001

Past exam · Tutorial 4

Q8 · 2D parity with a burst error

PredictionQ1

Compute the 2D even parity for the datawords 1010, 0111, 1100, 1001.

Compare with the model answer

Row parities: 1010→0, 0111→1, 1100→0, 1001→0. Column parities: 1, 0, 0, 0, and the parity of the parity column is 1. Block sent: 1010|0, 0111|1, 1100|0, 1001|0, 1000|1.

Slide 30 / 53

Two-dimensional parity: what it detects

Slide 30: Two-dimensional parity: what it detects

Notes

  1. It misses 4 errors that sit at the corners of a rectangle: every row and column still has even parity.

Exam angle

PredictionQ1

Two-dimensional parity can correct a single-bit error.

PredictionQ2

Which error pattern can two-dimensional parity miss?

Slide 31 / 53

CRC generator and checker

Slide 31: CRC generator and checker

Notes

  1. Sender: append n zeros (n = divisor length - 1), divide, the remainder is the CRC. Send data + CRC.

  2. Receiver: divide data + CRC by the same divisor. Remainder 0 → accept; otherwise reject.

Slide 32 / 53

Note: the generator

Slide 32: Note: the generator
Slide 33 / 53

A polynomial to represent a binary word

Slide 33: A polynomial to represent a binary word

Notes

  1. Each 1 bit is a power of x: 1000011 = x⁶ + x + 1.

  2. Division uses XOR, with no carries.

  3. Memory trick Polynomial → bits: write a 1 for every power present, from the highest down to x⁰. x³ + x + 1 = 1011.

Exam angle

PredictionQ1

The generator x³ + x + 1 in binary is:

PredictionQ2

1000011 as a polynomial is:

Slide 34 / 53

Division in CRC encoder

Slide 34: Division in CRC encoder

Notes

  1. Dataword 1001 + 000 ÷ 1011 → remainder 110 → codeword 1001110.

  2. When the leftmost bit of the current remainder is 0, divide by 0000 instead (just bring the next bit down).

Exam angle

Past exam · Tutorial 4

Q5 · CRC of 11010011 with 1011

Past exam · Tutorial 4

Q7 · CRC of 101110 with x³ + x + 1

Past exam · Tutorial 4Q1

With generator 1011, the CRC for dataword 11010011 is:

Past exam · Tutorial 4Q2

With generator x³ + x + 1, the frame sent for data 101110 is:

Past exam · Tutorial 4Q3

With generator 1011, the CRC for dataword 1101 is:

Slide 35 / 53

Division in the CRC decoder for two cases

Slide 35: Division in the CRC decoder for two cases

Notes

  1. Remainder (syndrome) 000 → accept. Anything else → discard.

Exam angle

Past exam · Tutorial 4

Q5b · is 11010011101 accepted

Past exam · Tutorial 4

Q7b–c · checking received frames

Past exam · Tutorial 4Q1

Generator 1011. The receiver gets 11010011101. What happens?

Past exam · Tutorial 4Q2

Generator x³ + x + 1: the received frame 101110101 is accepted.

Slide 36 / 53

Binary division in CRC checker

Slide 36: Binary division in CRC checker

Notes

  1. A zero remainder means no error detected.

Slide 37 / 53

CRC summary

Slide 37: CRC summary

Notes

  1. Trap Generator 1011 has 4 bits → append 3 zeros and the CRC is 3 bits.

Slide 38 / 53

Standard polynomials

Slide 38: Standard polynomials

Notes

  1. CRC-32 is the one used in LANs (Ethernet’s FCS).

  2. Seen again Ch 4, slide 4: The Ethernet frame’s CRC field

Slide 39 / 53

Advantages of Cyclic Codes

Slide 39: Advantages of Cyclic Codes

Notes

  1. CRC catches single, double, odd-count and burst errors, and is fast in hardware.

Slide 40 / 53

Example

Slide 40: Example

Notes

  1. Length r + 1 slips by with probability 1/2^(r-1); longer ones with 1/2^r.

  2. Memory trick Degree = highest power. x⁶ + 1 → 6 → all bursts up to 6 bits.

Exam angle

PredictionQ1

The generator x¹⁸ + x⁷ + x + 1 detects all burst errors of length up to:

Slide 41 / 53

Example (continued)

Slide 41: Example (continued)

Notes

  1. Higher degree → longer bursts caught → that’s why LANs use CRC-32.

Slide 42 / 53

Checksum

Slide 42: Checksum

Notes

  1. Checksum: add all words (one’s complement), complement the sum, send it. The receiver adds everything; complemented result 0 = OK.

  2. Seen again Ch 9, slide 20: The UDP and TCP checksum

Slide 43 / 53

Data unit and checksum

Slide 43: Data unit and checksum
Slide 44 / 53

Checksum: sender site

Slide 44: Checksum: sender site

Notes

  1. Steps: split into 16-bit words, checksum field = 0, add with one’s complement, complement → checksum.

  2. Memory trick One’s complement addition: any carry out of the top bit wraps around and is added back at the bottom.

Slide 45 / 53

Checksum: receiver site

Slide 45: Checksum: receiver site

Notes

  1. Receiver: add all words INCLUDING the checksum, complement. 0 → accept, anything else → reject.

Slide 46 / 53

Example 7

Slide 46: Example 7

Notes

  1. Complement = flip every bit.

Exam angle

Past exam · Tutorial 4

Q9 · 8-bit checksum of four words

Past exam · Tutorial 4Q1

The 8-bit checksum of 10101010, 01010101, 11110000 and 00001111 is:

Past exam · Tutorial 4Q2

Sender words 1100110011001100 and 1010101010101010. The 16-bit checksum is:

Slide 47 / 53

Example 8

Slide 47: Example 8

Exam angle

Past exam · Tutorial 4

Q3b · verifying a received checksum

PredictionQ1

In Tutorial 4 Q3, the receiver gets checksum 0110010101100101 for the two words. The packet is error-free.

Slide 48 / 53

Example 9

Slide 48: Example 9

Notes

  1. Nonzero after complementing → corrupted.

Slide 49 / 53

Error correction

Slide 49: Error correction

Notes

  1. Two ways to fix errors: send it again, or send enough redundancy to fix it on arrival (FEC).

Slide 50 / 53

Error correction 1: retransmission

Slide 50: Error correction 1: retransmission

Notes

  1. Retransmission is bad for wireless (high bit error rate → too many resends) and for real-time multimedia (waiting = delay).

Exam angle

PredictionQ1

Retransmission is a poor fit for real-time multimedia because:

Slide 51 / 53

Error correction 2: forward error correction (FEC)

Slide 51: Error correction 2: forward error correction (FEC)

Notes

  1. FEC fixes errors at the receiver with no resend.

  2. XOR trick: send R = XOR of all blocks; any ONE lost block = XOR of R with the rest.

Exam angle

PredictionQ1

Blocks C1..C4 and R = C1 ⊕ C2 ⊕ C3 ⊕ C4 are sent, and C3 is lost. C3 equals:

PredictionQ2

Forward error correction needs the sender to retransmit corrupted data.

Slide 52 / 53

Burst Error Correction Chunk Interleaving

Slide 52: Burst Error Correction Chunk Interleaving

Notes

  1. Interleave: spread each packet’s chunks across several transmitted packets. Losing one packet then costs each original packet only one chunk, which multimedia can tolerate.

Slide 53 / 53

Interleaving

Slide 53: Interleaving

Notes

  1. The lost packet (orange) removes one chunk from each of the five packets instead of a whole packet.

Exam angle

PredictionQ1

A video stream loses one whole packet in a burst. How does chunk interleaving keep the video watchable?

Compare with the model answer

Each original packet’s chunks were spread over several transmitted packets (sent column by column). Losing one transmitted packet removes just one small chunk from each original packet, a gap small enough for multimedia to hide, instead of losing an entire packet.