Back to the 2024 paper

Module 2: Data Link Layer & MAC Sublayer

20247m

The following character encoding is used in a data link protocol: A: 01000111; B: 11001111; FLAG: 01111110; ESC: 11100000. Show the bit sequence transmitted (in binary) for the four-character frame: A A B ESC FLAG when each of the following framing methods are used:
i. Character count.
ii. Flag bytes with byte stuffing.
iii. Starting and ending flag bytes, with bit stuffing.

Worked SolutionAI Assisted

Given codes: A = 01000111, B = 11001111, FLAG = 01111110, ESC = 11100000

The question calls the frame "four-character" but lists five items (A A B ESC FLAG). The standard textbook frame is A B ESC FLAG (four characters), solved in Part 1. The five-item sequence exactly as printed is solved in Part 2 with the same method.


Part 1: frame = A B ESC FLAG

i. Character count

The first byte gives the frame length in characters, counting the count byte itself: 4 data characters + 1 = 5.

00000101 | 01000111 | 11001111 | 11100000 | 01111110
 count=5      A          B         ESC        FLAG

Bits: 00000101 01000111 11001111 11100000 01111110

(If the count is defined to exclude itself, use 4 = 00000100.)

ii. Flag bytes with byte stuffing

The frame starts and ends with FLAG. An ESC byte is inserted before every ESC or FLAG that occurs in the data.

Data: A B ESC FLAG → A B ESC ESC ESC FLAG

FLAG A B ESC ESC ESC FLAG FLAG

Bits: 01111110 01000111 11001111 11100000 11100000 11100000 01111110 01111110

iii. Starting and ending flags with bit stuffing

After five consecutive 1s in the data, insert a 0.

Data bits: 01000111 11001111 11100000 01111110

Five 1s occur (a) across the end of A and start of B, (b) across the end of B and start of ESC, and (c) inside FLAG. A 0 is inserted after each:

Stuffed data: 01000111110001111101100000011111010

Frame = FLAG + stuffed data + FLAG:

01111110 01000111110001111101100000011111010 01111110

(3 extra bits were added: 32 → 35 data bits.)


Part 2: frame exactly as printed = A A B ESC FLAG

i. Character count

Count = 5 characters + 1 = 6

00000110 01000111 01000111 11001111 11100000 01111110

ii. Byte stuffing

Data A A B ESC FLAG → A A B ESC ESC ESC FLAG

01111110 01000111 01000111 11001111 11100000 11100000 11100000 01111110 01111110
(FLAG, A, A, B, ESC, ESC, ESC, FLAG, FLAG)

iii. Bit stuffing

Data bits: 01000111 01000111 11001111 11100000 01111110

Stuffed data (0 inserted after each run of five 1s): 0100011101000111110001111101100000011111010 (43 bits)

Frame: 01111110 0100011101000111110001111101100000011111010 01111110


Summary: character count needs no special byte handling but one error in the count loses synchronisation; byte stuffing uses ESC bytes (the frame grows by one byte per FLAG or ESC in the data); bit stuffing works at bit level and is independent of the character code.

Similar questions

Official AppAndroid App

PYQDeck for Android

Solve BEU previous-year exam papers anywhere, anytime. Fast search, offline paper viewing, and step-by-step solutions designed specifically for your phone.