Protocols → HDLC (bit-oriented, bit stuffing) | PPP (byte-oriented, point-to-point)
2.1.1 Introduction to Data Link Layer
📖 Data Link Layer (Layer 2): Takes packets from the Network Layer, wraps them into frames, and delivers them reliably from one node to the next directly connected node over the physical link.
💡 Real-life Analogy:
Think of a courier chain. The Network Layer decides the route Delhi → Mumbai. The Data Link Layer is the local delivery boy who carries the parcel only from one hub to the next hub, checks it is not damaged, and does not overload the next hub.
Main jobs of Data Link Layer
Framing: divides the bit stream into frames
Physical addressing: adds sender and receiver MAC address in the frame header
Error control: detects and corrects damaged or lost frames
Flow control: stops a fast sender from drowning a slow receiver
Access control: decides who uses a shared link (MAC sub-layer)
Sub-layer
Work
LLC (Logical Link Control)
Flow control, error control, interface to Network Layer
MAC (Media Access Control)
Access to shared channel, MAC addressing, frame delimiting
⚠️ Key Point: PDU of Data Link Layer = Frame. It works hop-to-hop, while Transport Layer works end-to-end.
2.1.2 Design Issues of Data Link Layer
📖 Data Link Layer: Layer 2 of OSI. Provides reliable node-to-node delivery of frames over a physical link using MAC (physical) addresses.
💡 Rule: Flag = 01111110. After every five consecutive 1s in data, sender inserts a 0; receiver removes it. Data: 0111111011111 → Sent: 011111010111110 (zero stuffed after each run of five 1s).
Byte stuffing: Flag byte in data is preceded by an ESC byte. Used in PPP. Bit stuffing is used in HDLC.
2.1.3 Error Detection & Correction
📖 Types of Errors
Single-bit error: only 1 bit is changed
Burst error: 2 or more consecutive bits changed (length = first to last corrupted bit)
Method
Working
Remark
Parity
Add 1 bit so total 1s is even (or odd)
Detects odd-bit errors only; 2D parity detects more
Checksum
Sum data in 1s complement, send complement of sum; receiver sum must be all 1s
Used in IP/TCP/UDP
CRC
Append n zeros (n = generator degree), divide by generator using XOR, remainder = CRC
Detects burst errors; used in Ethernet
Hamming Code
Parity bits at positions 1,2,4,8…; need 2r ≥ m+r+1
Detects & corrects single-bit error
📐 CRC Example
Data = 1001, Generator = 1011 (x³ + x + 1)
Append 3 zeros → 1001000
XOR division gives remainder 110
Transmitted frame = data + CRC = 1001110
Receiver divides by 1011 → remainder 000 → no error
Hamming: Syndrome (parity check bits read as binary) gives the position of the erroneous bit. Syndrome 0 means no error.
2.1.4 Parity Check — Worked Example
📖 Parity bit: One extra bit added so the total number of 1s is even (even parity) or odd (odd parity). Receiver counts the 1s; a wrong count means an error.
💡 Example: data word 1101011, even parity
Count the 1s in 1101011 = 5 (odd)
Even parity needs an even total, so parity bit = 1
Transmitted: 11010111 (parity bit added at the end), now six 1s
If the data were 1101010 (four 1s), parity bit would be 0
Limit: Parity detects only an odd number of bit errors. Two flipped bits keep the count even and go unnoticed. 2D parity (row + column parity) catches more.
2.1.5 Checksum Step by Step
📖 Checksum: Sender adds all data words, takes the 1s complement of the sum, and sends it with the data. The receiver adds everything again, including the checksum. If the final result (after complement) is all 0s, data is accepted.
Side
Steps
Sender
1) Divide data into equal words (8 bits here) 2) Add all words 3) If carry goes beyond 8 bits, wrap it around (add carry to the result) 4) Complement the sum = checksum 5) Send data + checksum
Receiver
1) Add all received words + checksum 2) Wrap carry 3) Complement. All 0s = no error, otherwise discard the frame
Worked example with 4 frames is in the PYQs tab (Test-2, Q6).
2.1.6 CRC & Hamming Code — Worked Examples
📖 CRC (Cyclic Redundancy Check): Sender divides data (plus appended zeros) by a fixed generator polynomial using XOR (modulo-2) division. The remainder is attached to the data. Receiver divides again; remainder 0 means no error.
Step 1 — Choose generator
Generator 1011 (x³ + x + 1) has 4 bits, so degree n = 3.
Step 2 — Append zeros
Data 1001 + three zeros = 1001000.
Step 3 — XOR division
Divide 1001000 by 1011 (subtract = XOR, no borrow).
Step
Bits taken
XOR → remainder
1
1001 first 4 bits
⊕ 1011 (leading bit 1) = 0010 → 010
2
0100 010 + next bit 0
⊕ 0000 (leading bit 0) = 0100 → 100
3
1000 100 + next bit 0
⊕ 1011 (leading bit 1) = 0011 → 011
4
0110 011 + next bit 0
⊕ 0000 (leading bit 0) = 0110 → 110
✅ Rule: leading bit 1 → XOR with the generator (1011). Leading bit 0 → XOR with 0000. After the last bit, the remainder 110 is the CRC.
Step 4 — Send
Codeword = data + CRC = 1001110. Receiver divides by 1011 and gets remainder 000, so frame is accepted.
📖 Hamming Code (7,4): Adds parity bits at positions that are powers of 2 (1, 2, 4). Each parity bit checks a fixed group of positions, so the failing checks point to the exact error position.
Parity bit
Checks positions
p1
1, 3, 5, 7
p2
2, 3, 6, 7
p4
4, 5, 6, 7
💡 Hamming Example (even parity)
Data bits d3 d5 d6 d7 = 1 0 1 1
p1 = parity of (d3, d5, d7) = (1, 0, 1) → 0
p2 = parity of (d3, d6, d7) = (1, 1, 1) → 1
p4 = parity of (d5, d6, d7) = (0, 1, 1) → 0
Codeword (position 1 to 7) = 0110011
Bit 6 flips → received 0110001. Re-check: p1 ok, p2 fails, p4 fails
Syndrome (p4 p2 p1) = 110 = 6 → flip bit 6 back to correct
✅ CRC: catches all burst errors up to length n, very reliable, cheap in hardware.
❌ CRC cannot correct errors, only detect. Hamming corrects 1 bit but cost is extra parity bits.
📝 Practice: data 10110101, G(x) = x³ + x + 1 (1011)
Append 3 zeros → 10110101000
Divide by 1011 (XOR). Remainder = 100
Transmitted codeword = 10110101100
Receiver divides by 1011 → remainder 000 → accepted
2.1.7 Stop-and-Wait Protocol
📖 Stop-and-Wait: Simplest flow control. Sender sends one frame and waits for its ACK before sending the next.
💡 Analogy: Sending a WhatsApp message and not typing the next one until the other person replies "ok".
Step 1
Sender sends frame 0 and starts a timer.
Step 2
Receiver checks frame, sends ACK.
Step 3
ACK arrives before timeout → send next frame. Timer expires first → resend same frame.
✅ Pros: Very simple, needs only 1 buffer.
❌ Cons: Link is idle while waiting, so long-distance links are badly wasted.
Example: Tt = 1 ms, Tp = 20 ms → a = 20. Efficiency = 1/(1 + 2a) = 1/41 ≈ 2.4%. This is why sliding window is needed.
2.1.8 Sliding Window Protocols
📖 Sliding Window: Sender may transmit multiple frames before ACK arrives. Frames are numbered; window = range of sequence numbers allowed to be outstanding. Improves link utilization over Stop-and-Wait.
Feature
Stop-and-Wait
Go-Back-N
Selective Repeat
Sender window
1
2m − 1
2m−1
Receiver window
1
1
2m−1
On frame loss
Resend that frame
Resend lost frame and all after it
Resend only the lost frame
ACK
Per frame
Cumulative
Individual
Buffering at Rx
None
None (out-of-order discarded)
Needed (out-of-order stored)
Complexity / Efficiency
Low / Lowest
Medium / Medium
High / Best
📐 Sliding Window Formulas
a = Tp / Tt
Stop-and-Wait efficiency η = 1 / (1 + 2a)
Optimal window = 1 + 2a
Efficiency = N / (1 + 2a) when N < 1 + 2a
2.1.9 Go-Back-N Explained Simply
📖 Go-Back-N (GBN): A sliding window protocol where the sender can send several frames without waiting, but the receiver accepts frames only in order. If one frame is lost or damaged, the sender goes back to that frame and resends it and every frame after it.
💡 Real-life analogy: A teacher dictates pages 1, 2, 3, 4 to you. You miss page 2. You cannot write page 3 before page 2, so you ignore pages 3 and 4. The teacher repeats from page 2.
Step
What happens (window size = 4)
1
Sender sends frames 0, 1, 2, 3 one after another (no waiting)
2
Receiver gets 0 and 1, sends ACK 0, ACK 1
3
Frame 2 is lost. Frame 3 arrives but is out of order, so receiver discards it
4
Sender's timer for frame 2 expires (timeout)
5
Sender goes back and resends 2 and 3 (and anything sent after them)
❌ Cons: Wastes bandwidth because good frames are resent. Sender window must be at most 2m − 1, otherwise old and new frames get confused.
Go-Back-N: F2 is lost, F3 is thrown away, sender goes back and resends F2 and F3.
2.1.10 Selective Repeat Explained Simply
📖 Selective Repeat (SR): Like Go-Back-N the sender sends many frames, but the receiver keeps out-of-order frames in a buffer and the sender resends only the lost frame.
💡 Analogy: You miss page 2 of the dictation but still write pages 3 and 4. You just ask the teacher to repeat page 2 alone.
Step 1
Sender sends F0, F1, F2, F3. F2 is lost.
Step 2
Receiver stores F3 in its buffer and sends a NAK or individual ACK for F3; F2 is missing.
Step 3
Only F2 is resent. Receiver now delivers F2, F3 to the upper layer in order.
Go-Back-N
Selective Repeat
Resends
Lost frame + all after
Only lost frame
Receiver buffer
Not needed
Needed
Window size limit
2m − 1
2m−1
Best for
Reliable links, simple hardware
Noisy / long links
2.1.11 Media Access Control (MAC) Layer
📖 MAC: Sub-layer of Data Link Layer that decides who may transmit on a shared channel and avoids collisions.
Protocol
Vulnerable Time
Throughput S
Max Efficiency
Pure ALOHA
2 × Tfr
G·e−2G
18.4% (G = 0.5)
Slotted ALOHA
Tfr (time slots)
G·e−G
36.8% (G = 1)
CSMA — Carrier Sense Multiple Access ("listen before talk")
Persistence
Behaviour
1-persistent
Sense continuously; send immediately when idle (p = 1). High collision chance
Non-persistent
If busy, wait random time and sense again. Fewer collisions, more delay
p-persistent
If idle, send with probability p, else wait one slot (for slotted channels)
CSMA/CD
CSMA/CA
Used in
Wired Ethernet (802.3)
Wireless LAN (802.11)
Idea
Detect collision while sending, stop, send jam signal, binary exponential backoff
Avoid collision: IFS wait, random backoff, optional RTS/CTS handshake, ACK
Condition
Tt ≥ 2 × Tp (min frame size)
Cannot detect collision in wireless, so avoid it
2.1.12 ALOHA Explained — with Numerical
📖 ALOHA: The oldest random-access protocol. A station sends whenever it has data. If no ACK comes (collision), it waits a random time and resends.
💡 Analogy:Pure ALOHA = people talking in a room without any rule. Slotted ALOHA = everyone may speak only when a bell rings (slot start), so overlaps are fewer.
Pure: a frame collides if any other frame starts within 2 × Tfr, so vulnerable time = 2Tfr
Slotted: collision only when two stations pick the same slot, vulnerable time = Tfr
Throughput S vs load G. Slotted ALOHA peaks at double the height of Pure ALOHA.
📐 Numerical — ALOHA Throughput
Given: Tfr = 1 ms, system generates 500 frames/s
G = 500 × 1 ms = 0.5
Pure ALOHA: S = G·e−2G = 0.5 × e−1 = 0.184 → 184 frames/s succeed
Slotted ALOHA (G = 1, i.e. 1000 frames/s): S = G·e−G = e−1 = 0.368 → 368 frames/s succeed
2.1.13 CSMA/CD — How Ethernet Handles Collisions
💡 Analogy: A group discussion: you listen before speaking, and if two people start together both stop, wait a random time, and try again.
Step 1 — Sense
Listen to the channel. If busy, wait.
Step 2 — Transmit
Channel idle → start sending the frame and keep listening.
Step 3 — Collision?
If another signal is detected, stop at once and send a short jam signal so everyone knows.
Step 4 — Backoff
After the n-th collision pick random K from 0 to 2n − 1 and wait K × slot time (binary exponential backoff). Give up after 16 attempts.
Minimum frame size: Sender must still be sending when the collision signal returns, so Tt ≥ 2Tp. For 10 Mbps Ethernet, 2Tp = 51.2 µs → min frame = 51.2 µs × 10 Mbps = 512 bits = 64 bytes.
⚠️ Why wireless cannot use CD: A wireless node cannot listen while sending, so CSMA/CA avoids collisions instead.
2.1.14 HDLC & PPP
HDLC
PPP
Full form
High-Level Data Link Control
Point-to-Point Protocol
Type
Bit-oriented (bit stuffing)
Byte-oriented (byte stuffing)
Frame
Flag | Address | Control | Data | FCS | Flag
Flag (7E) | Address (FF) | Control (03) | Protocol | Payload | FCS | Flag
Frame types
I (Information), S (Supervisory: ACK/NAK), U (Unnumbered: link setup)
Classless Addressing (CIDR): No fixed classes; address written as a.b.c.d/n (n = prefix length). Avoids address wastage of classful scheme.
A 0…
B 10…
C 110…
D
E
First octet 0–255 split by class: A 1–126 · B 128–191 · C 192–223 · D 224–239 (multicast) · E 240–255 (reserved)
💡 Quick example: IP 172.25.14.8. First octet 172 = 10101100 (starts with 10) → in range 128–191 → Class B, default mask 255.255.0.0 (/16). Network ID = 172.25.0.0, host part = 14.8. (172.16.0.0 – 172.31.255.255 is reserved for private use.)
2.2.2 MAC Address vs IP Address
💡 Analogy: MAC address is like your name (fixed, tied to you). IP address is like your home address (changes when you move to another city/network).
Point
MAC Address
IP Address
Full form
Media Access Control
Internet Protocol
Layer
Data Link Layer (Layer 2)
Network Layer (Layer 3)
Size
48 bits (6 bytes)
32 bits (IPv4) / 128 bits (IPv6)
Format
Hexadecimal, e.g. 00:1A:2B:3C:4D:5E
Dotted decimal, e.g. 192.168.1.10
Assigned by
Manufacturer (burned into NIC card)
Network admin or DHCP server
Changes?
Permanent (physical address)
Changes with network (logical address)
Scope / use
Delivery between two directly connected devices (hop to hop)
End-to-end delivery across networks (routing)
Device
Switch / Bridge
Router
Remember: MAC changes at every hop, IP stays the same from source to destination.
2.2.3 IPv4 Packet Header
📖 IPv4 Header: Control information added in front of data by the Network Layer. It is 20 bytes minimum and 60 bytes maximum. Routers read it to decide where to send the packet. Each row below is 32 bits.
Version (4)
IHL (4)
Type of Service (8)
Total Length (16)
Identification (16)
Flags (3) | Fragment Offset (13)
Time To Live (8)
Protocol (8)
Header Checksum (16)
Source IP Address (32)
Destination IP Address (32)
Options + Padding (0 to 40 bytes, optional)
Explanation of each field
Field
Size
Purpose
Version
4 bits
IP version. 4 for IPv4
IHL
4 bits
Header length in 32-bit words (min 5 = 20 bytes, max 15 = 60 bytes)
Type of Service
8 bits
Priority / quality of service (DSCP)
Total Length
16 bits
Header + data in bytes (max 65,535)
Identification
16 bits
Same ID for all fragments of one packet, used to reassemble
Combines several contiguous small networks into one larger block (reverse of subnetting)
Rule 1: blocks must be contiguous
Rule 2: number of blocks must be a power of 2
Rule 3: first address must be divisible by total block size
Example: 4 class C blocks 200.1.0.0 – 200.1.3.0 → 200.1.0.0/22
.0 – .63
.64 – .127
.128 – .191
.192 – .255
192.168.1.0/24 → 4 subnets of /26, each with 64 addresses (62 usable hosts)
2.2.5 Subnet Calculation — Step by Step
📐 Subnet Calculation — 5 Steps
Find the class from the first octet
Convert the mask to /n (count the 1s)
Subnet address = IP AND mask
Block size = 256 − mask octet
Broadcast = next subnet address − 1
Why subnet? Better use of IP addresses, less broadcast traffic, easier management and security, each department gets its own network.
Full solved example is in the PYQs tab (Test-2, Q7).
2.2.6 Routing Algorithms
📖 Optimality Principle: If router J lies on the optimal path from I to K, then the optimal path from J to K is on the same route. All optimal routes to a destination form a sink tree.
Algorithm
Working
Key Points
Shortest Path
Dijkstra: repeatedly pick unvisited node with least distance, relax neighbours
Needs full topology; basis of Link State
Flooding
Router sends every incoming packet on all lines except the arrival line
Very reliable, no topology needed; duplicates (use hop counter / sequence no.)
Distance Vector
Each router shares its whole table with neighbours only (Bellman-Ford). Used in RIP
Slow convergence, count-to-infinity problem (fix: split horizon, poison reverse)
Link State
Router learns neighbours, builds LSP, floods to all, runs Dijkstra. Used in OSPF
Fast convergence, more memory/CPU, scalable
2.2.7 Distance Vector — Worked Example
📖 Idea (Bellman-Ford): New distance = cost to neighbour + neighbour's distance to destination. Router keeps the minimum.
A —1— B→B —2— C→A wants C
Step
A's table for C
Why
Start
∞
A only knows B (cost 1)
A receives B's vector (B→C = 2)
1 + 2 = 3 via B
Better than ∞, so update
Link A–C (cost 5) added
min(3, 5) = 3 via B
Keep the smaller one
2.2.8 Dijkstra Steps & Count-to-Infinity Problem
Dijkstra Step 1
Set distance of source = 0, all others = ∞. Mark all nodes unvisited.
Step 2
Pick the unvisited node with smallest distance and mark it visited.
Step 3
For each neighbour, if (distance of picked node + link cost) is smaller than its current distance, update it.
Step 4
Repeat steps 2 and 3 until the destination is visited. Trace back parents to get the path.
💡 Count-to-Infinity: Network A — B — C. A reaches C via B (cost 2). The B–C link breaks. B hears from A "I can reach C in 2", so B thinks C = 3 via A. Then A updates to 4 via B, B to 5, and the costs keep rising forever.
✅ Fixes:Split horizon (do not tell a neighbour about routes learned from it), poison reverse (advertise such routes as ∞), and set a maximum hop limit (RIP uses 16 = infinity).
2.2.9 Multicast Routing & DVMRP
📖 Multicast: One sender delivers data to a group of receivers. Group addresses are Class D (224.0.0.0 – 239.255.255.255).
Type
Delivery
Example
Unicast
One → one
Web page request
Broadcast
One → all hosts
ARP request
Multicast
One → selected group
Live video, online class
💡 Analogy: A newsletter. The sender sends one copy to the post office, and copies are made only for people who subscribed.
IGMP: Host-to-router protocol. Hosts send join and leave reports; the router sends periodic queries to learn which groups still have members.
📖 DVMRP (Distance Vector Multicast Routing Protocol): A multicast routing protocol based on the distance vector idea (like RIP). It builds a source-based shortest-path tree for each (source, group) and delivers one multicast stream to all group members by flood and prune.
⚙️ Working Principle — 5 Steps
Neighbour & route exchange: routers find neighbours and exchange distance-vector route tables (metric = hop count, 32 means unreachable). This gives each router the shortest path back to every source
Flood with RPF: the first multicast packet is flooded. Each router applies Reverse Path Forwarding: accept the packet only if it arrived on the interface used to reach the source, else drop (stops loops)
Prune: a router with no group members downstream sends a Prune message upstream, so the branch stops receiving that group for some time
Graft: when a new member joins later (IGMP join), the router sends a Graft message upstream to restore the pruned branch quickly
Result: data flows only along the pruned shortest-path tree to routers that have members
R3 has no members and is pruned. The switch forwards to H1 only because of IGMP snooping.
Working with managed switches
Device
Role
Host
Tells local router which group it wants using IGMP join
Router
Runs DVMRP: builds tree, floods, prunes, grafts
Managed switch (Layer 2)
Does not run DVMRP. Uses IGMP snooping (and IGMP querier, VLANs) to limit multicast inside the LAN. A Layer-3 managed switch can also run a multicast routing protocol
Switch WITHOUT IGMP snooping
Managed switch WITH IGMP snooping
Multicast frame
Treated like broadcast: sent out of all ports
Sent only to ports that have joined the group
How it learns
Does not learn
Listens to IGMP join/leave between hosts and router, keeps a group → port table
Effect
Non-member hosts are also flooded
Saves bandwidth, non-members get nothing
✅ Pros: Simple, uses proven distance-vector logic, shortest path for every source.
❌ Cons: Flooding wastes bandwidth, keeps per-source state, scales poorly and converges slowly like all distance-vector protocols. Mostly replaced by PIM today.
2.2.10 Congestion Control
📖 Congestion: Too many packets in the network → queues fill up, delay rises, packets are dropped, throughput collapses.
Open Loop (Prevention)
Closed Loop (Cure)
Policies applied before congestion (retransmission, window, ACK, discard policy, admission)
Uses feedback after congestion (choke packet, backpressure, ECN)
Leaky Bucket
Token Bucket
Output
Constant rate always
Bursts allowed (if tokens available)
Idea
Bucket leaks at fixed rate; overflow packets discarded
Tokens added at rate r (capacity C); a packet needs a token to go
Idle host
Credit wasted
Saves tokens for later burst
Use
Smoothing bursty traffic
Flexible traffic shaping
📐 Token Bucket Burst Time: S = C / (M − r) (C = bucket capacity, M = max output rate, r = token rate)
2.2.11 Leaky & Token Bucket — Concept and Numerical
💡 Leaky Bucket: A bucket with a small hole. Water (packets) may pour in at any speed, but it drips out at a fixed rate. If the bucket overflows, extra water is lost. 💡 Token Bucket: Tokens are coins collected over time. To send a packet you spend a coin, so after a quiet period you can send a quick burst.
📐 Numerical — Token Bucket Burst Time
Given: C = 1 MB, r = 2 MB/s, M = 10 MB/s
Formula: S = C / (M − r)
Substitute: S = 1 / (10 − 2) = 1 / 8
Burst time S = 0.125 s
Data sent in burst = M × S = 10 × 0.125 = 1.25 MB (1 MB from bucket + 0.25 MB from new tokens)
2.2.12 Congestion Prevention Policies by Layer
Layer
Policies
Data Link
Retransmission policy, out-of-order caching, acknowledgement policy, flow control
Network
Virtual circuit vs datagram, packet queueing and service, discard policy, routing algorithm, packet lifetime
6️⃣ ChecksumAdd words, wrap carry, complement. Receiver total + checksum = all 1s.
7️⃣ SubnettingClass from 1st octet, IP AND mask. 180.25.21.172 /18 → Class B, subnet 180.25.0.0
📡 Chapter 2.1 — Data Link Layer
1. Framing & Bit Stuffing
📖 Definition: Framing splits the bit stream into frames. Bit stuffing inserts a 0 after every five consecutive 1s so data never looks like the flag 01111110.
💡 Example: Data 0111111011111 → sent 011111010111110. Receiver removes the stuffed 0s.
0 1 1 1 1 10 ← stuffed1 01 1 1 1 10 ← stuffed
Data 0111111011111 → after every five 1s a 0 is inserted
2. Error Detection & Correction
📖 Definition: Parity, Checksum and CRC detect errors. Hamming code can also correct a single-bit error.
💡 Example: CRC: data 1001 ÷ generator 1011 → remainder 110 → frame sent = 1001110. Even parity: 1101011 has five 1s → parity bit 1 → sent 11010111.
Parity→Checksum→CRC
Hamming = detect + correct 1 bit
p1
p2
d3
p4
d5
d6
d7
Hamming (7,4): positions 1–7. Parity bits (red) sit at positions 1, 2, 4
3. Sliding Window (Stop-and-Wait, GBN, SR)
📖 Definition: Sender can send many frames before an ACK. Window = how many frames may be outstanding.
📖 Definition: HDLC is a bit-oriented Data Link protocol (frame types I, S, U). PPP is a byte-oriented point-to-point protocol (LCP, NCP, PAP/CHAP).
💡 Example: Dial-up / ISP link uses PPP. HDLC marks frames with flag 01111110.
Flag
Address
Control
Data
FCS
Flag
HDLC frame (bit-oriented, bit stuffing)
Flag 7E
Addr FF
Ctrl 03
Protocol
Payload
FCS
Flag
PPP frame (byte-oriented, byte stuffing)
🌍 Chapter 2.2 — Network Layer
1. IP Addressing & Classes
📖 Definition: IPv4 address is a 32-bit logical address (network ID + host ID) written in dotted decimal. Classless (CIDR) uses a.b.c.d/n.
💡 Example: 180.25.21.172 → first octet 180 is in 128–191 → Class B (default mask /16).
A 0…
B 10…
C 110…
D
E
Class A 1–126 · B 128–191 · C 192–223 · D 224–239 (multicast) · E 240–255 (reserved)
2. Subnetting & Supernetting
📖 Definition: Subnetting splits one network into smaller ones. Supernetting joins contiguous networks into a bigger block.
💡 Example: 192.168.1.0/24 → borrow 2 bits → /26 → 4 subnets × 64 addresses (62 hosts). Four class C blocks → /22.
.0–.63
.64–.127
.128–.191
.192–.255
192.168.1.0/24 split into four /26 subnets
📐 Formulas
Subnets = 2n
Hosts per subnet = 2h − 2
Subnet address = IP AND mask
3. MAC vs IP Address
📖 Definition: MAC is a physical 48-bit Layer 2 address. IP is a logical 32-bit Layer 3 address.
💡 Example: MAC = your name (fixed). IP = your home address (changes with network).
MAC48-bit hex · Layer 2 · set by manufacturer · hop-to-hop
IP32-bit dotted decimal · Layer 3 · set by admin/DHCP · end-to-end
4. IPv4 Packet Header
📖 Definition: Control information the Network Layer adds in front of data. Size 20 bytes minimum, 60 bytes maximum.
💡 Example: TTL starts at e.g. 64; every router subtracts 1; at 0 the packet is dropped. Protocol 6 = TCP, 17 = UDP.
Version (4)
IHL (4)
Type of Service (8)
Total Length (16)
Identification (16)
Flags (3) | Fragment Offset (13)
Time To Live (8)
Protocol (8)
Header Checksum (16)
Source IP Address (32)
Destination IP Address (32)
Options + Padding (0 to 40 bytes, optional)
5. Routing (Flooding, Distance Vector, Link State)
📖 Definition: Routing decides the path of a packet. Flooding sends on all lines. Distance Vector shares tables with neighbours. Link State floods link info to everyone and runs Dijkstra.
💡 Example: Distance Vector: A–B cost 1, B–C cost 2 → A learns C = 3 via B. RIP uses DV, OSPF uses Link State.
Share table with neighbours→Bellman-Ford update
Learn own links→Flood LSP to all→Run Dijkstra
6. Multicast Routing (DVMRP)
📖 Definition: Multicast = one sender to a group. DVMRP is a distance-vector multicast routing protocol that floods with RPF, then prunes branches with no members and grafts them back when a member joins.
💡 Example: R3 has no members → sends Prune. A host joins via IGMP → router sends Graft. A managed switch with IGMP snooping sends multicast only to member ports.
7. Congestion Control
📖 Definition: Congestion = too many packets in the network, so delay and loss rise. Leaky and Token bucket shape the traffic.
💡 Example: C = 1 MB, r = 2 MB/s, M = 10 MB/s → burst time S = C/(M−r) = 0.125 s.
Leaky: output always constant. Token: saved tokens let a burst go out.
🧠 Tricks to Remember
CD = Detect (wired Ethernet) | CA = Avoid (wireless)
Slotted ALOHA = double of Pure ALOHA (18.4% → 36.8%)
Class first bits: 0, 10, 110, 1110, 1111 = A, B, C, D, E
DV = tells neighbours everything | LS = tells everyone own links
MAC changes at every hop, IP stays same end-to-end
Section A: 5 × 2 = 10 marks · Section B: 2 × 5 = 10 marks
Attempt all questions
Section A — 2 Marks Questions
2M2026-27
Q1. List various Data Link Layer design Issues. [CO3]▼
Answer:
Services to the Network Layer: unacknowledged connectionless, acknowledged connectionless, acknowledged connection-oriented
Framing: dividing the bit stream into frames (character count, byte stuffing, bit stuffing)
Error control: detecting and correcting damaged, lost or duplicate frames using ACK, timers and sequence numbers
Flow control: stopping a fast sender from overwhelming a slow receiver
2M2026-27
Q2. Recognize the Parity bit if data word 1101011 is transmitted using even parity. [CO3]▼
Answer:
Solution
Count the 1s in 1101011 = 5 (odd)
Even parity needs an even number of 1s, so add parity bit 1
Transmitted word = 11010111 (six 1s)
✅ Parity bit = 1
2M2026-27
Q3. State the meaning of Go-back-n with reference to Data Link Layer. [CO3]▼
Answer:
Go-Back-N (GBN) is a sliding window ARQ protocol of the Data Link Layer. The sender transmits up to N frames without waiting for ACK, but the receiver accepts frames only in correct order (receiver window = 1). If a frame is lost or corrupted, the receiver discards it and all later frames, and the sender goes back and retransmits from the lost frame onward.
Example: Sender sends 0,1,2,3. Frame 2 is lost → 3 is discarded → timer of 2 expires → sender resends 2, 3. Sender window = 2m − 1, ACKs are cumulative.
2M2026-27
Q4. Identify class and default mask for IP address given as 172.25.14.8. [CO4]▼
Answer:
Step
Working
First octet
172 = 10101100 (starts with bits 10)
Range check
128 – 191 → Class B
Default mask
255.255.0.0 (/16)
Network / Host
Network ID 172.25.0.0, host part 14.8
172.16.0.0 – 172.31.255.255 is the private address range.
2M2026-27
Q5. Illustrate the sketch of IPv4 packet header. [CO4]▼
Answer:
Each row is 32 bits. Min header = 20 bytes (5 words), max = 60 bytes.
Version (4)
IHL (4)
Type of Service (8)
Total Length (16)
Identification (16)
Flags (3) | Fragment Offset (13)
Time To Live (8)
Protocol (8)
Header Checksum (16)
Source IP Address (32)
Destination IP Address (32)
Options + Padding (0 to 40 bytes, optional)
Field
Size
Purpose
Version
4 bits
IP version. 4 for IPv4
IHL
4 bits
Header length in 32-bit words (min 5 = 20 bytes, max 15 = 60 bytes)
Type of Service
8 bits
Priority / quality of service (DSCP)
Total Length
16 bits
Header + data in bytes (max 65,535)
Identification
16 bits
Same ID for all fragments of one packet, used to reassemble
Hop limit; each router subtracts 1; at 0 the packet is dropped (stops endless loops)
Protocol
8 bits
Which upper layer gets the data: 6 = TCP, 17 = UDP, 1 = ICMP
Header Checksum
16 bits
Error check on the header only (recalculated at every router)
Source / Destination IP
32 + 32 bits
Sender and receiver IPv4 addresses
Options + Padding
0–40 bytes
Rarely used extras; padding makes header a multiple of 32 bits
Section B — 5 Marks Questions
5M2026-27
Q6. A sender wants to transmit the data word 10110101 using the CRC error detection technique. The generator polynomial is G(x) = x³ + x + 1. Calculate i) The CRC bits to be appended ii) The transmitted codeword. [CO3]▼
Answer:
Setup
G(x) = x³ + x + 1 → generator = 1011 (degree 3, so append 3 zeros)
Dividend = 10110101 + 000 = 10110101000
Rule: leading bit 1 → XOR with 1011, leading bit 0 → XOR with 0000
Check at receiver: 10110101100 ÷ 1011 gives remainder 000 → no error
5M2026-27
Q7. Analyze the working principle of Distance Vector Multicast Routing Protocol (DVMRP) and how does it work with managed switches. [CO4]▼
Answer:
📖 DVMRP (Distance Vector Multicast Routing Protocol): A multicast routing protocol based on the distance vector idea (like RIP). It builds a source-based shortest-path tree for each (source, group) and delivers one multicast stream to all group members by flood and prune.
⚙️ Working Principle — 5 Steps
Neighbour & route exchange: routers find neighbours and exchange distance-vector route tables (metric = hop count, 32 means unreachable). This gives each router the shortest path back to every source
Flood with RPF: the first multicast packet is flooded. Each router applies Reverse Path Forwarding: accept the packet only if it arrived on the interface used to reach the source, else drop (stops loops)
Prune: a router with no group members downstream sends a Prune message upstream, so the branch stops receiving that group for some time
Graft: when a new member joins later (IGMP join), the router sends a Graft message upstream to restore the pruned branch quickly
Result: data flows only along the pruned shortest-path tree to routers that have members
Device
Role
Host
Tells local router which group it wants using IGMP join
Router
Runs DVMRP: builds tree, floods, prunes, grafts
Managed switch (Layer 2)
Does not run DVMRP. Uses IGMP snooping (and IGMP querier, VLANs) to limit multicast inside the LAN. A Layer-3 managed switch can also run a multicast routing protocol
Switch WITHOUT IGMP snooping
Managed switch WITH IGMP snooping
Multicast frame
Treated like broadcast: sent out of all ports
Sent only to ports that have joined the group
How it learns
Does not learn
Listens to IGMP join/leave between hosts and router, keeps a group → port table
Section A: 5 × 2 = 10 marks · Section B: 2 × 5 = 10 marks
Attempt all questions
Section A — 2 Marks Questions (Short Answer)
2M2025-26
Q1. State the meaning of Go-back-n with reference to Data Link Layer. [CO3 | BT1]▼
Answer:
Go-Back-N (GBN) is a sliding window ARQ protocol of the Data Link Layer. The sender transmits up to N frames without waiting for ACK, but the receiver accepts frames only in correct order (receiver window = 1). If a frame is lost or corrupted, the receiver discards it and all later frames, and the sender goes back and retransmits from the lost frame onward.
Example: Sender sends 0,1,2,3. Frame 2 is lost → 3 is discarded → timer of 2 expires → sender resends 2, 3. Sender window = 2m − 1, ACKs are cumulative.
2M2025-26
Q2. Identify the difference between MAC address and IP address? [CO4 | BT1]▼
Answer:
Point
MAC Address
IP Address
Layer
Data Link (Layer 2)
Network (Layer 3)
Size
48 bits, hexadecimal
32 bits (IPv4), dotted decimal
Type
Physical, permanent, set by manufacturer
Logical, changes with network, set by admin/DHCP
Use
Hop-to-hop delivery in same LAN
End-to-end delivery across networks
Analogy: MAC = person's name, IP = home address.
2M2025-26
Q3. Compare ALOHA with Slotted ALOHA. [CO3 | BT2]▼
Answer:
Point
Pure ALOHA
Slotted ALOHA
Time
Continuous, send any time
Divided into slots, send only at slot start
Synchronization
Not needed
Needed (common clock)
Vulnerable time
2 × Tfr
Tfr
Throughput
S = G·e−2G
S = G·e−G
Max efficiency
18.4% at G = 0.5
36.8% at G = 1
Collisions
More
Half of Pure ALOHA
Complexity
Simple
Slightly complex
Slotted ALOHA doubles the efficiency because frames can collide only if sent in the same slot.
Flooding is a static routing technique where a router sends every incoming packet on all outgoing lines except the one it came from. It needs no routing table or topology knowledge.
Analogy: Spreading news by telling every friend, and each friend tells all their friends.
Aspect
Detail
Working
Packet arrives → copy sent on all other links → every neighbour repeats this
Problem
Huge number of duplicate packets, can loop forever
Controls
Hop counter (drop at 0) | Sequence numbers (drop already-seen packets) | Selective flooding (only toward the destination direction)
Advantages
Very reliable, finds shortest path automatically, simple, works even if many routers fail
Disadvantages
Wastes bandwidth, duplicates, congestion
Uses
Military networks, broadcasting, Link State routing (LSP distribution), wireless sensor networks
2M2025-26
Q5. Illustrate & explain the sketch of IPv4 packet header. [CO4 | BT2]▼
Answer:
Each row is 32 bits. Min header = 20 bytes (5 words), max = 60 bytes.
Version (4)
IHL (4)
Type of Service (8)
Total Length (16)
Identification (16)
Flags (3) | Fragment Offset (13)
Time To Live (8)
Protocol (8)
Header Checksum (16)
Source IP Address (32)
Destination IP Address (32)
Options + Padding (0 to 40 bytes, optional)
Field
Size
Purpose
Version
4 bits
IP version. 4 for IPv4
IHL
4 bits
Header length in 32-bit words (min 5 = 20 bytes, max 15 = 60 bytes)
Type of Service
8 bits
Priority / quality of service (DSCP)
Total Length
16 bits
Header + data in bytes (max 65,535)
Identification
16 bits
Same ID for all fragments of one packet, used to reassemble
Hop limit; each router subtracts 1; at 0 the packet is dropped (stops endless loops)
Protocol
8 bits
Which upper layer gets the data: 6 = TCP, 17 = UDP, 1 = ICMP
Header Checksum
16 bits
Error check on the header only (recalculated at every router)
Source / Destination IP
32 + 32 bits
Sender and receiver IPv4 addresses
Options + Padding
0–40 bytes
Rarely used extras; padding makes header a multiple of 32 bits
Section B — 5 Marks Questions (Long Answer)
5M2025-26
Q6. List various Error Detection methods. Using Checksum method, evaluate & verify the bits at sender & receiver end having 4 frames of 8 bits: 11001100, 10101010, 11110000, 11000011. [CO3 | BT4]▼
✅ Result = 0 → no error, frames accepted. If any bit flips, the final complement is non-zero and the receiver discards the frames.
5M2025-26
Q7. Identify the need of Sub-netting. Given IP address 180.25.21.172, identify its class. If subnet mask is 255.255.192.0, evaluate its subnet address. [CO4 | BT4]▼
Answer:
Need of subnetting: Efficient use of IP addresses, reduces broadcast traffic, improves security and performance, simplifies management, lets one network be split for departments/floors.
Step
Working
Class
First octet 180 lies in 128–191 (binary starts 10) → Class B (default mask 255.255.0.0)