By the end of this chapter you'll be able to…

  • 1Apply bit stuffing and de-stuffing and explain why the flag can never appear in payload
  • 2Compute a CRC and state exactly which error classes a degree-r generator detects
  • 3Relate minimum Hamming distance to detection and correction capability
  • 4Size a Hamming code and place its parity bits, then read a syndrome as a position
  • 5Compute the ratio a and apply it to stop-and-wait and sliding window utilisation
  • 6State and justify the window bounds for go-back-N and selective repeat
  • 7Derive and compare pure and slotted ALOHA throughput
  • 8Distinguish the CSMA persistence variants and explain why wireless uses avoidance not detection
  • 9Derive the CSMA/CD minimum frame size and explain what breaks below it
  • 10Describe switch learning, flooding, and why spanning tree is required
💡
Why this chapter matters in GATE
The data link layer frames, detects errors and arbitrates a shared medium, and every mechanism does its job by adding some form of redundancy. GATE concentrates on the computable parts: bit stuffing, CRC, Hamming code sizing, sliding window utilisation from the propagation-to-transmission ratio, ALOHA throughput, and the CSMA/CD minimum frame size.

Before you start — revise these

🔗
Binary arithmetic and exclusive-or
🔗
Transmission and propagation delay as independent quantities
🔗
Basic probability and the exponential function

The Data Link Layer

The physical layer delivers a stream of bits that may be corrupted, and several machines may be shouting into the same wire.

The organising fact is that the data link layer has three jobs: mark where frames begin and end, detect or correct the errors the physical layer introduced, and arbitrate access when the medium is shared.

Everything in this chapter is one of those three, and the recurring theme is that each job is solved by adding redundancy of some kind, whether a delimiter, a checksum or a backoff interval.

The second organising fact is that the efficiency of any sliding window protocol is governed by a single ratio, the propagation delay divided by the transmission delay. Once that number is known, every utilisation formula follows.

The third is that a shared medium forces a minimum frame size. A sender must still be transmitting when the furthest collision could reach it, otherwise it will never learn that its frame was destroyed.

1. Framing

Framing marks where one frame ends and the next begins, and four methods exist.

A character count field states the frame length. It is simple and catastrophically fragile: one corrupted count desynchronises the receiver permanently.

Byte stuffing delimits frames with a flag byte and escapes any occurrence of that byte inside the payload with an escape byte, escaping the escape byte in turn. It assumes byte-oriented data.

Bit stuffing uses the flag pattern 01111110 and, whenever the sender emits five consecutive ones in the payload, inserts a zero. The receiver removes any zero following five ones, and the flag can therefore never appear in the data.

Physical layer coding violations use signal patterns that encode no data bit, which costs no bits at all but requires a coding scheme with spare patterns.

Bit stuffing is the method to know for the exam, because it is the one that produces computable answers.

2. Error Detection

A single parity bit detects any odd number of bit errors and misses every even number. Two-dimensional parity, adding a parity bit per row and per column, detects all one, two and three bit errors and corrects any single one.

A checksum sums the data as integers and transmits the complement, and is used by IP, TCP and UDP. It is cheap and weak, missing errors that cancel out.

A cyclic redundancy check treats the message as a polynomial over the field with two elements, divides by a generator polynomial, and appends the remainder.

With a generator of degree , exactly check bits are appended, and the receiver divides the whole received frame by the same generator, expecting a zero remainder.

CRC properties are what make it standard. A generator with more than one term detects all single-bit errors. A generator with the factor detects all odd numbers of errors. A degree- generator detects all burst errors shorter than or equal to .

Errors are detected, not corrected, and the frame is discarded and retransmitted.

3. Error Correction and Hamming Distance

The Hamming distance between two codewords is the number of positions in which they differ.

The minimum distance of a code determines its power.

To detect up to errors, the minimum distance must be at least , since fewer errors then cannot reach another valid codeword.

To correct up to errors, the minimum distance must be at least , so that any corrupted word remains nearer its original than any other codeword.

Hamming codes place parity bits at power-of-two positions. Bit position checks every position whose binary representation has bit set.

With parity bits, must be at least , where is the number of data bits, since the syndrome must name every position plus the no-error case.

The syndrome, read as a binary number, gives the position of the single error directly, which is the elegance of the construction.

4. Flow Control and Sliding Windows

Stop-and-wait sends one frame and waits for its acknowledgement.

Define as propagation delay divided by transmission delay. Then the sender is busy for one transmission time out of a cycle lasting transmission times.

Utilisation is therefore , which collapses on long or fast links where is large.

Sliding window protocols keep several frames outstanding. With window size , utilisation becomes , capped at 1.

The window size needed for full utilisation is therefore .

Go-back-N discards every frame after a lost one and retransmits from the lost frame onward. The receiver needs no buffer beyond one frame, and the sender window is at most for an -bit sequence number.

Selective repeat buffers out-of-order frames and retransmits only what was lost. It needs receiver buffering, and both windows are at most .

The tighter bound for selective repeat is not arbitrary. If the windows could be larger, a retransmitted old frame could be mistaken for a new one, because the receiver cannot tell which lap of the sequence space it is on.

5. Medium Access

Pure ALOHA transmits whenever a frame is ready. A frame is destroyed if any other transmission begins within one frame time before or after it, giving a vulnerable period of two frame times.

Its throughput is , maximised at giving about 0.184.

Slotted ALOHA forces transmissions to start at slot boundaries, halving the vulnerable period to one frame time.

Its throughput is , maximised at giving about 0.368, exactly double.

Carrier sense multiple access listens before transmitting.

One-persistent CSMA transmits as soon as the channel goes idle, which guarantees a collision if two stations were both waiting. Non-persistent CSMA waits a random time before sensing again, reducing collisions and adding delay. P-persistent CSMA transmits with probability in each idle slot.

CSMA with collision detection aborts as soon as a collision is sensed, which is what Ethernet does on shared media, and requires the minimum frame size derived below.

CSMA with collision avoidance is used in wireless, where a station cannot listen while transmitting, so collisions cannot be detected and must be avoided through backoff and optional request-to-send handshakes.

Binary exponential backoff picks a random wait from to slots after the -th collision, capping at 10 and giving up after 16 attempts.

6. Ethernet and Bridging

The minimum frame size follows from collision detection. A sender must still be transmitting when the worst-case collision signal returns, so transmission time must be at least twice the propagation delay across the network.

For classic 10 Mbps Ethernet with a 2500 metre maximum span and repeaters, the round-trip worst case is about 51.2 microseconds, which at 10 Mbps is 512 bits, or 64 bytes.

Raising the rate to 100 Mbps while keeping 64 bytes forces the span down by a factor of ten, which is why fast Ethernet segments are shorter. Gigabit Ethernet instead added carrier extension to keep useful distances.

A hub is a physical layer repeater and joins everything into one collision domain. A bridge or switch operates at the data link layer and separates collision domains, forwarding only where necessary.

Switch learning is the mechanism worth understanding. A switch reads the source address of every arriving frame and records which port it came from. When forwarding, it looks up the destination: if known, it sends only to that port; if not, it floods to every port but the arrival port.

The spanning tree protocol prevents loops. A loop in a switched network causes broadcast frames to circulate forever, since there is no time-to-live field at the data link layer, so the protocol elects a root and disables redundant links.

A broadcast storm is what happens without it. One broadcast frame entering a loop is duplicated at every switch on every pass, and the traffic grows until the segment is unusable.

A switch is therefore not a transparent improvement on a hub in every respect. It divides collision domains but not the broadcast domain, which is why virtual LANs exist: they partition one physical switch into several broadcast domains that a router must join.

7. Worked Examples

Example 1. Apply bit stuffing to the payload 0111111011111011111110 and show what the receiver recovers.

The rule: after five consecutive ones, insert a zero.

Scan left to right. The bits are 0, then 111110, then 11111, then 011111, then 110.

Position by position. After the leading 0, five ones appear at positions 2 to 6, so a zero is stuffed after position 6. The next bit is the original 1, then 0.

Continuing, the next run of five ones triggers another stuffed zero, and so on.

The stuffed output is 0111110101111100111110110, where each inserted zero follows exactly five ones.

The receiver's rule is the mirror image: on seeing five ones followed by a zero, delete the zero.

On seeing five ones followed by a one, the receiver knows it is a flag or an error, since the sender could never have produced six consecutive ones in the payload.

That is the whole point of the scheme. The flag 01111110 contains six ones and is therefore unambiguous, and no payload can imitate it.

The overhead is bounded: in the worst case of all ones, one bit is added every five, giving 20 percent, and on typical data it is negligible.

Example 2. Compute the CRC for the message 1101011011 with generator 10011.

The generator has degree 4, so append 4 zeros to the message, giving 11010110110000.

Divide by the generator using modulo-2 arithmetic, which is exclusive-or with no carries.

The division proceeds by aligning the generator under the leftmost 1 and taking the exclusive-or, then shifting.

The remainder of this standard computation is 1110.

The transmitted frame is the original message with the remainder appended, that is 11010110111110.

The receiver divides the received frame by the same generator.

A zero remainder means no detected error; any non-zero remainder means the frame is discarded.

Why this works: appending the remainder makes the transmitted polynomial exactly divisible by the generator, because subtracting the remainder in modulo-2 arithmetic is the same as adding it.

The detection guarantee follows from the generator's degree. Any error burst shorter than or equal to 4 bits changes the polynomial by an amount that the degree-4 generator cannot divide, so the remainder becomes non-zero.

Example 3. How many parity bits are needed to correct a single error in 8 data bits, and where do they go?

The requirement is , since the syndrome must identify any of the positions or report no error.

Try : , while . Insufficient.

Try : . Sufficient.

So 4 parity bits are needed, giving a 12-bit codeword.

They go at positions 1, 2, 4 and 8, the powers of two.

Each checks the positions whose index has the corresponding bit set. The parity bit at position 1 checks positions 1, 3, 5, 7, 9, 11. The bit at position 2 checks 2, 3, 6, 7, 10, 11. The bit at 4 checks 4, 5, 6, 7, 12. The bit at 8 checks 8, 9, 10, 11, 12.

On reception, recompute all four parities and read the results as a 4-bit binary number, least significant first.

That number is the position of the erroneous bit, and zero means no error, which is why the construction is so economical.

Example 4. A 1 Mbps link has a one-way propagation delay of 10 milliseconds and frames of 1000 bits. Compute the utilisation of stop-and-wait and the window size needed for full utilisation.

Transmission time is millisecond.

Propagation delay is 10 milliseconds, so .

Stop-and-wait utilisation is percent.

The sender transmits for 1 millisecond and then waits 20 milliseconds for the round trip, which is exactly what the formula says.

For full utilisation the window must satisfy frames.

With a 5-bit sequence number, go-back-N permits a window of , which is sufficient.

Selective repeat permits only , which is not, so a 6-bit sequence number would be needed there.

This asymmetry is worth carrying. For the same utilisation target, selective repeat needs one more sequence bit than go-back-N, and it buys that with far lower retransmission cost on a lossy link.

Example 5. A CSMA/CD network runs at 100 Mbps over 1 kilometre with a signal speed of metres per second. Compute the minimum frame size.

One-way propagation delay is microseconds.

Round-trip is 10 microseconds.

The sender must still be transmitting when a collision signal from the far end could return, so transmission time must be at least 10 microseconds.

At 100 Mbps, 10 microseconds carries bits, which is 125 bytes.

So the minimum frame size is 1000 bits.

Consider what happens if a shorter frame is sent. A station transmits 500 bits, finishes after 5 microseconds, and considers the frame delivered.

A collision that began at the far end 4 microseconds in reaches the sender at 9 microseconds, by which time the sender has stopped listening.

The frame is destroyed and the sender never learns, so the loss is left for a higher layer to detect after a timeout, which defeats the purpose of collision detection entirely.

The general relation is , and it shows why raising the rate forces either shorter cables or larger minimum frames.

Example 6. Compare pure and slotted ALOHA at and at , and explain the factor of two.

Pure ALOHA throughput is .

At : . This is its maximum.

At : , which is lower, since the channel is now overloaded.

Slotted ALOHA throughput is .

At : .

At : . This is its maximum.

The factor of two in peak throughput comes entirely from the vulnerable period.

In pure ALOHA a frame is destroyed by any transmission starting within one frame time before or after it, a window of two frame times.

Slotting forces all transmissions to begin at slot boundaries, so a frame can only be destroyed by another frame in the same slot, halving the window to one frame time.

Halving the vulnerable period doubles the exponent's denominator, which is exactly the difference between and .

Note that even slotted ALOHA wastes 63 percent of the channel, which is why carrier sensing was invented, and why Ethernet reaches far higher utilisation despite using the same random access idea.

Summary

The data link layer frames, detects errors and arbitrates a shared medium, and every mechanism here adds redundancy of some kind.

Framing uses character counts, byte stuffing, bit stuffing or coding violations. Bit stuffing inserts a zero after five ones so the flag 01111110 can never appear in data, with a worst-case overhead of 20 percent.

A single parity bit catches odd error counts only. A CRC with a degree- generator appends bits and detects every burst up to length , all single-bit errors, and all odd error counts if divides the generator.

Detecting errors needs minimum distance ; correcting needs . A Hamming code needs parity bits satisfying , placed at powers of two, and the syndrome names the erroneous position directly.

With the ratio of propagation to transmission delay, stop-and-wait achieves and a window of achieves , so full utilisation needs . Go-back-N allows a window of , selective repeat only .

Pure ALOHA peaks at 0.184 and slotted ALOHA at 0.368, the factor of two coming from halving the vulnerable period. CSMA variants differ in what they do when the channel is busy, and collision detection needs the frame to last at least a round trip.

The minimum frame size is , which is 64 bytes for classic Ethernet and is why faster Ethernet either shortened cables or extended carriers.

Switches learn source addresses, flood unknown destinations, and rely on the spanning tree protocol because data link frames carry no time-to-live. A switch divides collision domains but not the broadcast domain, which is what virtual LANs address.

Key formulas & results

Everything to memorise for the exam hall, in one card. Screenshot this for revision.

The organising principle
three jobs: framing, error control, medium arbitration
Each is solved by adding redundancy, whether a delimiter, a checksum or a backoff interval.
Bit stuffing rule
insert a 0 after five consecutive 1s; the flag is 01111110
The receiver deletes any 0 following five 1s, so six consecutive 1s can only be a flag. Worst-case overhead is 20 percent.
CRC detection guarantees
degree r generator appends r bits and detects all bursts of length at most r; a factor of x+1 catches all odd error counts
The transmitted polynomial is exactly divisible by the generator, so a non-zero remainder means a detected error.
Hamming distance requirements
detect d errors needs minimum distance d+1; correct d errors needs 2d+1
Correction requires the corrupted word to stay nearer its original than any other codeword.
Hamming code sizing
2 to the power r is at least m + r + 1
The syndrome must name any of the m+r positions plus the no-error case. Eight data bits need four parity bits.
The ratio a
a = propagation delay divided by transmission delay
Every utilisation formula in this chapter is a function of this one number.
Stop-and-wait utilisation
1 divided by (1 + 2a)
The sender is busy one transmission time out of a cycle lasting 1 + 2a transmission times.
Sliding window utilisation
N divided by (1 + 2a), capped at 1; full utilisation needs N at least 1 + 2a
Same for go-back-N and selective repeat in the error-free case; they differ in retransmission cost, not in ideal throughput.
Window size bounds
go-back-N allows 2 to the m minus 1; selective repeat allows 2 to the (m minus 1)
Selective repeat's tighter bound prevents a retransmitted old frame from being mistaken for a new one.
ALOHA throughput
pure: G times e to the minus 2G, peak 0.184 at G = 0.5; slotted: G times e to the minus G, peak 0.368 at G = 1
The factor of two comes entirely from slotting halving the vulnerable period from two frame times to one.
CSMA/CD minimum frame size
L is at least 2 times d times R divided by v
The sender must still be transmitting when the worst-case collision signal returns, which gives 64 bytes for classic Ethernet.
⚠️

Traps GATE sets — and how to dodge them

These are the exact option-traps and misreads that cost marks under negative marking.

WATCH OUT
Stuffing a zero after six ones instead of five
Stuff after five, precisely so that six can never occur in the payload. Stuffing after six would allow the flag pattern to appear.
Why it happens: The flag has six ones, so six feels like the trigger count.
WATCH OUT
Treating CRC as an error-correcting code
CRC detects and the frame is discarded and retransmitted. Correction is the job of Hamming codes and their relatives.
Why it happens: It is a strong check and the syndrome contains information, so correction seems within reach.
WATCH OUT
Using minimum distance d to correct d errors
Correction needs 2d+1, because the corrupted word must remain strictly nearer its original than any other codeword.
Why it happens: The detection rule d+1 is remembered and the correction rule is assumed to be similar.
WATCH OUT
Computing a as transmission over propagation
a is propagation divided by transmission. A long fast link has large a, which is exactly when stop-and-wait collapses.
Why it happens: The ratio can be written either way and the formula is memorised without its definition.
WATCH OUT
Giving selective repeat a window of 2 to the m minus 1
Selective repeat needs 2 to the (m minus 1), which is roughly half. It buffers out-of-order frames and so must be able to distinguish laps of the sequence space.
Why it happens: The go-back-N bound is learned first and the two look similar.
WATCH OUT
Stating slotted ALOHA peaks at G = 0.5
Pure peaks at G = 0.5 with 0.184; slotted peaks at G = 1 with 0.368. Differentiating each throughput expression gives the peak directly.
Why it happens: The pure ALOHA peak location is remembered and applied to both.
WATCH OUT
Ignoring the round trip in the minimum frame size derivation
The collision signal must travel out and back, so transmission time must cover twice the one-way propagation delay.
Why it happens: One-way propagation is the quantity usually given, so it is used directly.
WATCH OUT
Believing a switch divides the broadcast domain
Broadcast frames are flooded to every port, so the broadcast domain is unchanged. Dividing it needs virtual LANs and a router to join them.
Why it happens: It divides collision domains, and both are described as domains.

Exam-pattern practice

PYQ-style questions with full solutions. Work through them as a readiness check — mark yourself honestly and get your gap report at the end.

Readiness check

Are you exam-ready for Data Link Layer: Framing, Error Detection, Medium Access & Ethernet Bridging?

10 problems from this chapter. Try each one, reveal the worked solution, mark yourself honestly — get your gap report at the end.

10 questions~7 min

5-minute revision

The whole chapter, distilled. Read this the night before the exam.

  • Three jobs: framing, error control, medium arbitration; each adds redundancy
  • Bit stuffing inserts a 0 after five 1s so the flag 01111110 is unambiguous
  • Worst-case stuffing overhead is 20 percent
  • A degree-r CRC generator appends r bits and detects every burst up to length r
  • A generator with factor x+1 detects all odd numbers of errors
  • CRC detects but never corrects; the frame is discarded
  • Detect d errors needs distance d+1; correct d needs 2d+1
  • Hamming needs 2 to the r at least m+r+1, parity bits at powers of two
  • The syndrome read as binary gives the erroneous position directly
  • a is propagation over transmission; everything else follows from it
  • Stop-and-wait utilisation is 1 over (1+2a); window N gives N over (1+2a)
  • Full utilisation needs N at least 1+2a
  • Go-back-N window is 2 to the m minus 1; selective repeat is 2 to the (m minus 1)
  • Pure ALOHA peaks at 0.184 with G = 0.5; slotted at 0.368 with G = 1
  • The factor of two is the halved vulnerable period
  • CSMA variants: one-persistent, non-persistent, p-persistent
  • Wireless uses collision avoidance because a station cannot listen while transmitting
  • Binary exponential backoff waits 0 to 2 to the k minus 1 slots, capped at k = 10, 16 attempts
  • Minimum frame size is 2dR over v; 64 bytes for classic Ethernet
  • Switches learn source addresses and flood unknown destinations
  • Spanning tree is needed because frames carry no time-to-live; switches do not divide broadcast domains

GATE question blueprint

How this topic is asked, tier by tier — so you can prep to the pattern.

Typical weightage: 7

Question styleMarks eachTypical countWhat it tests
Sliding window protocols21
Medium access21
Framing and error detection11
Error correction11
Ethernet and bridging11

Exam-hall strategy

Battle-tested tips from mentors and toppers for this topic under the sectional clock.

  1. Compute a first in every sliding window question, since every formula depends on it, and check whether the question gives one-way or round-trip propagation. For window sizing, state whether the protocol is go-back-N or selective repeat before choosing a bound, because the two differ by roughly a factor of two. For minimum frame size, always double the one-way propagation delay before multiplying by the rate. Bit stuffing questions are mechanical: scan left to right and reset the run counter after each inserted zero. For ALOHA, remember the peak locations as well as the peak values, since questions often supply G and ask which protocol performs better at it. When a question asks what breaks, the answer usually involves the sender ceasing to listen before the collision returns.

Beyond the exam

Where this skill shows up in the job you're competing for — and in life.

Ethernet

Ethernet, Wi-Fi and every storage interface compute a CRC in hardware on every frame, which is why the polynomial arithmetic in this chapter runs billions of times a second

HDLC and PPP use exactly the bit stuffing scheme describe…

HDLC and PPP use exactly the bit stuffing scheme described here, and PPP still carries most consumer broadband sessions

Error-correcting codes descended from Hamming's construct…

Error-correcting codes descended from Hamming's construction protect DRAM, flash storage and every deep-space link, where retransmission is impossible or too slow

Wi-Fi's request-to-send and clear-to-send handshake exist…

Wi-Fi's request-to-send and clear-to-send handshake exists specifically to address the hidden terminal problem that makes collision detection impossible

Spanning tree convergence delays were a notorious source …

Spanning tree convergence delays were a notorious source of data centre outages, which is why modern fabrics use routed designs or newer protocols that avoid blocking links

Where else this topic is tested

Prepare once, score in every exam that asks it.

GATE CS
GATE DA
UGC NET Computer Science
ISRO Scientist SC
BARC Computer Science

Questions aspirants ask

Pulled from the Q&A community and mentor sessions.

Header Logo