Knowledge / Computer Science and Engineering / Data link layer: framing, error control and MAC

Data link layer: framing, error control and MAC

Computer Science and Engineering (B.E./B.Tech) · Computer networks · free study notes for exams, placements and interviews

In short

The data link layer (OSI layer 2) turns a raw, error-prone bit pipe into a link that delivers *frames* between two directly connected nodes. Its four jobs are framing (marking where a frame starts and ends), error control (detecting or correcting bit errors and retransmitting), flow control (not drowning a slow receiver) and medium access control (deciding who transmits when a link is shared). It is the heaviest-scoring area of computer networks in GATE CS - sliding-window efficiency, CRC division, Hamming codes, minimum Ethernet frame size and ALOHA throughput appear almost every year - and it is standard interview ground for network engineer, NOC, embedded firmware and switching/routing roles at Cisco, Juniper, Nokia, Ericsson, Tejas Networks, C-DOT, HFCL, Jio, Airtel, Qualcomm and the service companies (TCS, Infosys, Wipro, HCLTech). On the job it explains CRC errors on an interface, runt and giant frames, duplex mismatch and MAC-table behaviour on a switch.

Explained

Services, sublayers and addressing

Framing

Error detection and correction

Flow and error control protocols (ARQ)

Medium access control (MAC)

Key points

Formulas and examples

Transmission time Tt = L / B (L = frame length in bits, B = bandwidth in bits/s, Tt in s)
Propagation delay Tp = d / v (d = distance in m, v = signal speed ≈ 2 × 108 m/s in copper/fibre ⇒ 5 µs per km)
a = Tp / Tt (dimensionless; bandwidth-delay product in frame units)
Stop-and-Wait efficiency η = 1 / (1 + 2a); with frame-error probability p, η = (1 − p) / (1 + 2a)
Sliding window efficiency η = N / (1 + 2a), capped at 1 (N = window size in frames)
Throughput = η × B; window for full utilisation N ≥ 1 + 2a
Sequence-number bits: GBN N ≤ 2n − 1; Selective Repeat N ≤ 2n−1
Hamming code: 2r ≥ m + r + 1 (m = data bits, r = parity bits, n = m + r)
CRC: transmitted = (data × xr) with the remainder of division by G(x) appended; deg G(x) = r
Minimum frame length L_min = 2 × Tp × B = slot time × B
Pure ALOHA S = G e−2G, max 0.184; Slotted ALOHA S = G e−G, max 0.368 (G = attempts per frame time)
Backoff wait = k × slot time, k random in [0, 2n − 1] for the n-th collision (n ≤ 10)

Example 1 - Stop-and-Wait on a long link, and the window it needs. Link: B = 1 Mbps, frame L = 1000 bits, distance 4000 km, v = 2 × 108 m/s.

Example 2 - CRC generation and checking. Data 1101011011, generator G(x) = x⁴ + x + 1 → 10011, so r = 4.

11010110110000 ÷ 10011
11010 ^ 10011 = 01001  -> bring 1 -> 10011 ^ 10011 = 00000
bring 1 -> 00001 ; bring 0 -> 00010 ; bring 1 -> 00101 ; bring 1 -> 01011
bring 0 -> 10110 ^ 10011 = 00101 ; bring 0 -> 01010
bring 0 -> 10100 ^ 10011 = 00111 ; bring 0 -> 01110   (no bits left)

Example 3 - Hamming code: build it, then correct an error. Data m = 7 bits: 1011001. Check bits: 2r ≥ 7 + r + 1 → r = 4 (16 ≥ 12), so n = 11.

Example 4 - Minimum Ethernet frame size. Classic 10BASE5 segment chain: worst-case one-way delay including repeaters = 25.6 µs, so round trip 2Tp = 51.2 µs at B = 10 Mbps.

Example 5 - ALOHA throughput with real numbers. Channel 1 Mbps, fixed frames of 1000 bits ⇒ frame time 1 ms. 50 stations each generate 20 frames/s.

ProtocolSender windowReceiver windowRetransmitsSeq-number boundBest for
Stop-and-Wait ARQ11the one frame1 bitshort, slow links
Go-Back-N ARQN1lost frame + all afterN ≤ 2n − 1low error rate
Selective RepeatNNonly the lost frameN ≤ 2n−1high error / high BDP
MAC schemeTypeMax throughputDeterminismExample
Pure ALOHArandom18.4%noneearly satellite, RFID-like bursts
Slotted ALOHArandom36.8%nonereservation/request channels
CSMA/CDrandom + sensehigh at low loadnonelegacy half-duplex Ethernet
CSMA/CArandom + avoid~50-70% of PHY ratenoneWi-Fi (802.11)
Token passingcontrollednear 100%bounded delayToken Ring, FDDI, industrial LANs
TDMA/FDMA/CDMAchannelisedfixed per userstrongcellular, satellite trunks

Where it is used

Interview questions

Common mistakes

Related topics

OSI and TCP/IP models · IP addressing and subnetting · TCP, UDP, HTTP and DNS · Wireless and mobile networks · Routing algorithms and protocols · Information theory and channel coding

Open in the Knowledge reader →Find jobs →