Unit3 DataLinkLayer Notes
Unit3 DataLinkLayer Notes
COMPUTER NETWORKS
The Data Link Layer Engine — Framing, Flow & Error Control
Syllabus Coverage
3.1 Functions of the Data Link Layer
3.2 LLC and MAC Sub-layers
3.3 Framing & Flow Control (Stop-Wait, Go-Back-N, Selective Repeat)
3.4 Error Detection & Correction (Parity, Checksum, CRC, Hamming Code)
3.5 Channel Allocation: Pure ALOHA, Slotted ALOHA, CSMA Variants
3.6 Ethernet Standards: IEEE 802.3 (CSMA/CD), 802.4 (Token Bus), 802.5 (Token Ring)
3.7 Wireless LAN: FHSS, DSSS, CSMA/CA, Bluetooth, Wi-Fi
3.8 Virtual Circuit Switching, Frame Relay & ATM
3.9 DLL Protocols: HDLC and PPP
Page 1 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
The Three Core Problems: Framing (Boundary), Flow Control (Pace), Error Control (Noise)
Raw chaotic bits enter the DLL Processor — structured, paced, protected frames exit
Page 2 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Simple analogy: Physical Layer = the road. Data Link Layer = the traffic management system.
It ensures data travels from one end of a link to the other — correctly, efficiently, without chaos.
Core Functions
(A) Framing: Divides the raw bit stream into discrete, identifiable units called Frames (Header +
Payload + Trailer).
(B) Physical Addressing (MAC): Each NIC has a 48-bit MAC address. DLL header carries source and
destination MAC.
(C) Error Detection: Appends FCS (CRC-32) so the receiver can detect bit corruption caused by
noise.
(D) Error Correction (FEC): Hamming codes let the receiver locate and correct single-bit errors
without retransmission.
(E) Flow Control: Sliding window mechanisms prevent a fast sender from overflowing the receiver's
buffer.
(F) Channel Access Control: Decides which station transmits when multiple devices share a medium:
CSMA/CD, CSMA/CA, Token Passing.
Page 3 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Result: The same LLC can work above Ethernet, Wi-Fi, Token Ring — without any changes.
Page 4 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
All Four Framing Methods — Character Count, Byte Stuffing, Bit Stuffing, Coding Violations
Character Count: a single bit flip in the count field desynchronises all subsequent frames
Page 5 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Character Count
HOW IT WORKS:
First byte of each frame holds total byte count (including itself).
Example: Frame 1: [5 | A B C D] Frame 2: [4 | E F G]
FATAL FLAW:
If the count byte is corrupted by noise (5 becomes 4), the receiver draws a boundary
one byte too early. The rest of the stream is permanently misaligned.
All subsequent frames are lost — cascading failure.
Page 6 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Byte Stuffing in PPP — ESC bytes injected wherever FLAG appears in data
Page 7 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Worked Example:
Original: 0 1 1 1 1 1 1 0 1
Stuffed: 0 1 1 1 1 1 [0] 1 0 1 <-- 0 inserted after five 1s
Page 8 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Flow Control: High-capacity sender vs slow receiver buffer — buffer overflow destroys data
Page 9 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Page 10 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Stop-and-Wait: Send one frame, stop, wait for ACK, then send the next
Page 11 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
resends ACK
(d) DAMAGED: CRC error detected --> receiver sends NAK --> sender retransmits
immediately
The link sits IDLE 99.8% of the time! Sliding Window protocols fix this.
Go-Back-N (Window=4): Frame 1 lost → NAK → Frames 1,2,3,4 ALL retransmitted — wasteful
Go-Back-N Rules
Window size N: sender can keep up to N unacknowledged frames in flight simultaneously.
On error: Retransmit the damaged frame AND ALL frames sent after it.
Receiver: Discards ALL out-of-order frames. Buffers only 1 frame at a time.
Page 12 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Numerical Example
Window N = 7, propagation a = 5
eta = 7 / (1 + 10) = 7/11 = 63.6%
Selective Repeat: Only Frame 2 retransmitted; Frames 3 and 4 buffered — maximum efficiency
Page 13 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Side-by-Side: Go-Back-N discards all; Selective Repeat buffers and fills the gap
Window size restriction: max window <= 2^(n-1) to prevent sequence number ambiguity
(n = number of bits in sequence number field)
Page 14 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
ARQ Efficiency Matrix — Stop-and-Wait (Low), Go-Back-N (Medium), Selective Repeat (High)
Windo Rcvr
Protocol Retransmit Scope Efficiency Best For
w Buffer
Stop-and-Wait 1 Current frame only 1 frame 1/(1+2a) Simple short links
Error frame + all
Go-Back-N Up to N 1 frame N/(1+2a) Low-error links
after
Up to
Selective Repeat Only the bad frame N frames N/(1+2a)* High-error/long-delay links
N/2
Page 15 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Single Bit Error (brief static) vs Burst Error (sustained noise) — burst is the real threat
Types of Errors
Single-Bit Error: Only 1 bit flips. Most rare. Example: 10110 --> 10100
Multiple-Bit Error: 2+ non-adjacent bits flip.
Burst Error: A CONTIGUOUS run of bits corrupted by sustained interference.
Most common in practice — noise affects milliseconds = many bits.
Burst length = distance from first to last corrupted bit.
Page 16 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Parity Check (scale balance) and Checksum (one's complement wrap-around addition)
Used by: TCP and UDP (16-bit Internet Checksum), IPv4 header checksum.
Page 17 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
CRC XOR Division — M=110010, G=1101: remainder 110 appended to form codeword 110010110
RECEIVER:
1. Divide received codeword (M+R) by same G using XOR.
2. Remainder = 000 --> No error detected. Accept frame.
3. Remainder ≠ 000 --> Error detected. Discard frame.
CRC-32 (used in Ethernet): Detects ALL single-bit, double-bit, burst <= 32 bits errors.
Detects 99.99997% of all longer burst errors.
Generator
CRC Standard Used In
Degree
CRC-8 8 bits ATM header, SMBus
CRC-16 16 bits USB, HDLC, Modbus serial
CRC-32 32 bits Ethernet 802.3, Wi-Fi 802.11, ZIP, PNG, SATA
CRC-64 64 bits HDLC extended, iSCSI, ISO 3309
Page 18 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Hamming(7,4): P1+P2 fail, P4 passes => syndrome 011 = position 3 => flip bit 3 to correct
Hamming(7,4) Construction
Positions: 1 2 3 4 5 6 7
Content: P1 P2 D1 P4 D2 D3 D4
(parity bits at powers of 2; data bits fill the rest)
Each parity bit is set so XOR of all its covered positions = 0 (even parity).
Page 19 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Goal: Allocate the shared channel fairly and efficiently among N competing stations.
Throughput: S = G x e^(-2G)
Maximum at G = 0.5: S_max = 0.5 x e^(-1) ≈ 18.4%
Even under ideal load, Pure ALOHA wastes 81.6% of channel capacity!
Throughput: S = G x e^(-G)
Maximum at G = 1.0: S_max = 1 x e^(-1) ≈ 36.8%
Page 20 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Non-Persistent: If idle --> transmit. If busy --> wait RANDOM time, sense again.
Lower collision rate, slightly higher idle time. Best overall throughput.
p-Persistent: If idle --> transmit with probability p, defer to next slot with (1-p).
Tunable trade-off between collision probability and delay.
Page 21 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Page 22 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Only the station holding the TOKEN may transmit. NO COLLISIONS ever.
1. Token holder transmits queued frames.
2. Passes token to logical successor (not physical neighbour).
3. Process repeats around the logical ring.
Page 23 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Page 24 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Signal spread over 22 MHz bandwidth. Even if some chips are corrupted,
the receiver can recover the original bit using cross-correlation.
Used by: IEEE 802.11b (11 Mbps)
Page 25 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
PHASE 3 — TEARDOWN:
Source sends release packet. Routers remove VCI entries, free resources.
Page 26 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
ADVANTAGE of fixed size: Hardware switches process cells at full line speed.
No variable-length parsing needed -- enables Gbps switching in silicon.
Header fields:
VPI (8 bits): Virtual Path Identifier -- groups multiple VCIs between same two switches.
VCI (16 bits): Virtual Channel Identifier -- identifies specific virtual circuit.
HEC (8 bits): CRC-8 over header -- corrects single-bit header errors.
CLP (1 bit): Cell Loss Priority -- CLP=1 cells may be dropped under congestion.
Catego
Full Name Description Example Use
ry
CBR Constant Bit Rate Fixed guaranteed bandwidth + delay Voice calls, videoconferencing
VBR Variable Bit Rate Bursty traffic with QoS guarantee Compressed video (MPEG)
ABR Available Bit Rate Uses spare capacity, no strict QoS File transfer
Unspecified Bit
UBR Best-effort, no QoS Email, web browsing
Rate
Page 27 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Station Types
Station Type Role Issues / Receives
Controls the link. Polls secondaries. Manages error recovery.
Primary Issues Commands
Usually a router.
Operates under primary control. Cannot initiate without being
Secondary Sends Responses
polled.
Both Commands and
Combined Combines both roles. Used in peer-to-peer balanced links.
Responses
Transfer Modes
Mode Full Name Who Initiates Used For
Only Primary (secondaries
NRM Normal Response Mode Multi-point terminal networks
polled)
Asynchronous Response Secondary (when channel
ARM Unbalanced point-to-point
Mode idle)
Asynchronous Balanced
ABM Either combined station Balanced P2P -- used by PPP, LAPB
Mode
Page 28 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
PPP Sub-protocols
Sub-
Full Name Purpose
protocol
Link Control Negotiates link parameters: frame size, compression, auth method, loop
LCP
Protocol detection
Network Control Family: IPCP (IPv4), IPv6CP, IPXCP. Assigns IP addresses per NL
NCP
Protocol protocol.
Password Auth
PAP Simple plaintext: client sends username+password. Weaker.
Protocol
Challenge Challenge-response with MD5. Password never sent over the link.
CHAP
Handshake Auth Stronger.
PPP Frame: [ 0x7E | 0xFF | 0x03 | Protocol 2B | Data 0-1500B | FCS | 0x7E ]
Flag (0x7E): Start/end delimiter. Byte stuffing: 0x7E in data --> 0x7D 0x5E
Address (0xFF): Always broadcast -- PPP is point-to-point, addressing unnecessary
Control (0x03): Unnumbered info -- no sequence numbers at DLL
Protocol (2B): 0x0021=IPv4, 0x0057=IPv6, 0xC021=LCP, 0x8021=IPCP
Data (0-1500B): Network Layer packet. MRU negotiated by LCP (default 1500B)
FCS (2-4B): CRC-16 or CRC-32 -- detection only
PPP Connection Phases: Dead --> Establish --> Authenticate --> Network --> Open -->
Terminate
Dead: No physical connection.
Establish: LCP negotiates frame size, auth method, compression.
Authenticate: Optional. PAP or CHAP verifies the user.
Network: NCP(s) configure NL protocols. IPCP assigns IP addresses.
Open: Data flows. LCP monitors with Echo-Request/Echo-Reply.
Page 29 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Page 30 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
The Complete DLL Engine: Raw Input --> Framing --> Error Control --> ARQ Flow Control --> Output
Page 31 of 32
Computer Networks | Unit 3: Data Link Layer | Student Study Notes
Key Formulas
Pure ALOHA: S = G x e^(-2G) --> S_max ~18.4% at G = 0.5
Slotted ALOHA: S = G x e^(-G) --> S_max ~36.8% at G = 1.0
CRC remainder: R = (M x 2^r) mod G(x) [XOR polynomial division]
Stop-and-Wait: eta = 1 / (1 + 2a) [a = [Link] / [Link]]
Go-Back-N: eta = N / (1 + 2a) when N < (2a + 1)
100% efficiency: N >= (2a + 1) [window fills the pipe]
Hamming parity bits: 2^r >= m + r + 1 [m = data bits, r = parity bits]
Ethernet min frame: 2 x tau x B = 512 bits = 64 bytes [tau = one-way delay]
Page 32 of 32