CN
BCA-5003: Unit IV
Devices, Framing & IPv4
🏠
Subject: BCA-5003 ⭐ Hub vs Switch & IPv4 Classful Ranges Day 4 Priority

Unit IV: Network Devices, Framing & IPv4 Addressing

Hardware Devices (Hub, Switch, Router), Collision vs Broadcast Domains, Bit Stuffing, IPv4 Classful Addressing, and Subnetting Calculations.

1. Network Connecting Devices & Hardware Layers
⭐ CSJMU PYQs: 2024–25, 2022, 2020, 2017 (Explain Hub, Switch, Bridge, Router & Gateway — 10-Mark Core Theory)
🎯 Learning Objectives:
  • Identify the OSI operating layer and forwarding logic for all major network devices.
  • Contrast collision domains (Layer 1/2) with broadcast domains (Layer 2/3).
  • Understand transparent bridging algorithms (learning, filtering, forwarding, aging).
Device OSI Layer Primary Forwarding Logic Key Operational Characteristic
NIC (Network Interface Card) Layer 1 & 2 Hardware MAC address (48-bit hex) Gives host physical connection to medium; contains burned-in MAC address (e.g. 00:1A:2B:3C:4D:5E).
Repeater Layer 1 (Physical) Electrical signal regeneration Regenerates and amplifies weak electrical/optical signals to overcome cable attenuation; does NOT inspect bits.
Hub Layer 1 (Physical) Blind electrical broadcasting to all ports Multiport repeater; any bit received on one port is blindly repeated to all other ports. Half-duplex only.
Bridge Layer 2 (Data Link) Destination MAC address table Connects two LAN segments; filters and forwards frames using a dynamically learned MAC table to isolate traffic.
Switch Layer 2 (Data Link) Hardware-based MAC table (CAM table) Multiport bridge; creates dedicated, micro-segmented full-duplex links per port. Eliminates collisions!
Router Layer 3 (Network) Destination IP address routing table Connects different logical subnets and autonomous systems; finds optimal paths using routing protocols (RIP, OSPF, BGP).
Gateway Layers 4 to 7 Application payload & protocol translation Translates between fundamentally incompatible architectures (e.g. IBM SNA to TCP/IP, or email to SMS).
Firewall Layers 3, 4 & 7 Security rules (IP, Port, Protocol, State) Inspects incoming and outgoing traffic to permit or block packets based on organizational security policies.
2. Collision Domains vs Broadcast Domains
⭐ CSJMU PYQs: 2024–25, 2023–24, 2021, 2018 (Differentiate Collision Domain and Broadcast Domain — High Yield!)
ROUTER Breaks Broadcast Domains SWITCH 1 HUB 2 PC1 (CD 1) PC2 (CD 2) PC3 (CD 3) PC4 PC5 PC6 [Single Shared CD]
Collision Domains (CD) vs Broadcast Domains Across Network Hardware
Evaluation Parameter Collision Domain Broadcast Domain
Definition A network segment where simultaneous transmissions cause data signals to collide and corrupt. A network segment where a broadcast packet sent by one device is received by all other devices on the segment.
Operating Layer Layer 1 (Physical) & Layer 2 (Data Link). Layer 2 (Data Link) & Layer 3 (Network).
Behavior on a Hub 1 Single Shared Collision Domain across all connected ports. 1 Single Shared Broadcast Domain across all ports.
Behavior on a Switch $N$ Separate Collision Domains ($1$ dedicated collision domain per port). 1 Single Broadcast Domain; switches flood broadcast frames (MAC FF:FF:FF:FF:FF:FF) out all ports!
Device that Breaks It Bridges and Switches break and isolate collision domains. Routers break and isolate broadcast domains (preventing broadcast storms).
3. Data Link Layer Framing: Character Count, Byte & Bit Stuffing
⭐ CSJMU PYQs: 2025–26, 2023–24, 2021, 2018 (Explain Bit Stuffing algorithm and solve numerical problem — 10-Mark Question!)

The Physical layer transmits an unstructured raw stream of bits. The Data Link Layer must break this stream into discrete units called Frames so the receiver knows where each packet begins and ends.

Framing Method How It Operates Fatal Weakness / Limitation
1. Character Count First field in frame header is an integer specifying the total number of characters in the frame. Catastrophic Desynchronization: If a single transmission bit error corrupts the count field, the receiver cannot find the boundary of any subsequent frame!
2. Byte Stuffing Frames are framed by special flag bytes (e.g. DLE STX and DLE ETX). An escape byte (DLE) is inserted before any data byte that happens to match a flag byte. Tied strictly to 8-bit character encodings (ASCII); not bit-oriented.
3. Bit Stuffing (HDLC) Each frame starts and ends with the 8-bit flag 01111110. Whenever the sender's hardware detects five consecutive 1s in user payload, it automatically injects a 0. Universal & Bit-Oriented: Works with any arbitrary sequence of bits regardless of character encoding.
The Golden Rules of Bit Stuffing (HDLC / SDLC Protocols):
• Transmitter Rule: Begin with flag 01111110. Scan the payload data stream. Whenever you see five consecutive 1s ($11111$), immediately insert a 0 after the fifth 1. End with flag 01111110.
• Receiver Rule: When five consecutive 1s are encountered:
  • If the 6th bit is 0 $\implies$ It is a stuffed bit! Discard the 0 and keep reading payload data.
  • If the 6th bit is 1 and 7th bit is 0 ($01111110$) $\implies$ End of Frame flag detected!
  • If the 6th bit is 1 and 7th bit is 1 ($01111111$) $\implies$ Transmission error / abort flag!
📝 Master Solved Numerical 1 (2023–24 Exam):
Bit-stuff the following binary payload bitstream: 011011111110111110010
Step 1: Scan bitstream for groups of five consecutive 1s:
0 1 1 0 1 1 1 1 1 [stuff 0] 1 1 0 1 1 1 1 1 [stuff 0] 0 0 1 0
Step 2: Stuffed payload: 01101111101101111100010
Step 3: Final Transmitted Frame (enclosed between flags):
01111110 01101111101101111100010 01111110
📝 Master Solved Numerical 2 (2021 Exam):
Receiver receives the stuffed frame: 01111110 1111100111110101111100 01111110. Recover the original user data.
Step 1: Strip the starting and ending flags 01111110.
Step 2: Scan for five consecutive 1s followed by 0, and remove the zero:
• 11111[0]0 $\to$ remove 0 $\implies 111110$
• 11111[0]1 $\to$ remove 0 $\implies 111111$
• 011111[0]0 $\to$ remove 0 $\implies 0111110$
Recovered Original Data: 111110 111111 0111110
4. IPv4 Classful Addressing & Subnetting Calculations
⭐ CSJMU PYQs: 2024–25, 2021, 2019 (Address classes, default subnet masks, and subnet calculations — 15 Marks!)

An IPv4 address consists of 32 bits grouped into four 8-bit octets, represented in dotted-decimal format (e.g. 192.168.1.1).

Class Leading Bits 1st Octet Range Default Subnet Mask Net ID / Host ID Split Max Usable Hosts / Network
Class A 0 $1 - 126$ ($127$ reserved for loopback) $255.0.0.0$ (/8) $8 \text{ bits Net} \mid 24 \text{ bits Host}$ $2^{24} - 2 = \mathbf{16,777,214}$
Class B 10 $128 - 191$ $255.255.0.0$ (/16) $16 \text{ bits Net} \mid 16 \text{ bits Host}$ $2^{16} - 2 = \mathbf{65,534}$
Class C 110 $192 - 223$ $255.255.255.0$ (/24) $24 \text{ bits Net} \mid 8 \text{ bits Host}$ $2^8 - 2 = \mathbf{254}$
Class D 1110 $224 - 239$ None Multicast Groups N/A
Class E 1111 $240 - 255$ None Experimental / Research N/A
Special & Private IP Addresses (Must Know for 2-Mark Questions):
  • Loopback Address (127.0.0.1 / 127.0.0.0/8): Used for testing the internal software network stack on the local host without sending packets to any network card.
  • Private RFC 1918 Ranges:
    • Class A Private: 10.0.0.0 to 10.255.255.255 (1 single /8 network)
    • Class B Private: 172.16.0.0 to 172.31.255.255 (16 contiguous /16 networks)
    • Class C Private: 192.168.0.0 to 192.168.255.255 (256 contiguous /24 networks)
📝 Master Solved University Subnetting Numerical 1 (Class C):
An organization is assigned the network block $192.168.10.0/26$. Determine:
  1. Subnet Mask in dotted decimal format
  2. Total number of subnets created
  3. Number of usable hosts per subnet
  4. The complete subnet breakdown (Network ID, Host Range, Broadcast Address)
1. Subnet Mask (/26 prefix):
$26$ consecutive binary 1s: $11111111.11111111.11111111.11000000_2$
Fourth octet: $128 + 64 = 192 \implies \mathbf{255.255.255.192}$.
2. Number of Subnets:
Default Class C uses 24 network bits. Here 2 additional bits are borrowed ($26 - 24 = 2$ bits):
$$\text{Number of Subnets} = 2^2 = \mathbf{4 \text{ Subnets}}$$
3. Number of Usable Hosts per Subnet:
Remaining host bits = $32 - 26 = 6$ bits.
Subtract 2 addresses (Network ID and Directed Broadcast ID):
$$\text{Usable Hosts} = 2^6 - 2 = 64 - 2 = \mathbf{62 \text{ Hosts / Subnet}}$$
4. Complete Subnet Range Breakdown Table (Block Size = $256 - 192 = 64$):
Subnet # Network ID First Usable Host Last Usable Host Broadcast Address
Subnet 0 192.168.10.0 192.168.10.1 192.168.10.62 192.168.10.63
Subnet 1 192.168.10.64 192.168.10.65 192.168.10.126 192.168.10.127
Subnet 2 192.168.10.128 192.168.10.129 192.168.10.190 192.168.10.191
Subnet 3 192.168.10.192 192.168.10.193 192.168.10.254 192.168.10.255
📝 Master Solved University Subnetting Numerical 2 (Class B):
A university campus is assigned $172.16.0.0/19$. Calculate:
  • Subnet Mask: $/19$ prefix $\implies 11111111.11111111.11100000.00000000_2 = \mathbf{255.255.224.0}$.
  • Subnet Bits borrowed from Class B default (/16): $19 - 16 = 3$ bits $\implies 2^3 = \mathbf{8 \text{ Subnets}}$.
  • Usable hosts per subnet: $32 - 19 = 13$ host bits $\implies 2^{13} - 2 = 8192 - 2 = \mathbf{8,190 \text{ Usable Hosts}}$.
  • Block size in 3rd octet = $256 - 224 = 32$. First subnet: 172.16.0.0 to 172.16.31.255.
5. Routing Algorithms: Distance Vector vs. Link State Routing
⭐ CSJMU PYQs: 2025–26, 2024–25, 2022–23, 2021 (Compare Distance Vector & Link State, Bellman-Ford, Count-to-Infinity)

Routing is the process by which routers dynamically discover paths across interconnected networks and construct optimal forwarding tables.

Evaluation Parameter Distance Vector Routing (Bellman-Ford) Link State Routing (Dijkstra's SPF)
Information Exchanged Sends its entire routing table (vector of distances to all known destinations). Sends only the status of its directly connected links (Link State Packet / LSP).
Recipient of Updates Sends updates strictly to immediate directly connected neighbors only. Floods Link State Packets to every router in the entire network.
Network Knowledge "Routing by rumor": Each node trusts its neighbors' reports without global topology knowledge. Every router builds a complete, identical mathematical map of the entire network topology graph.
Shortest Path Calculation Bellman-Ford equation: $D_x(y) = \min_v \{c(x,v) + D_v(y)\}$. Dijkstra's Shortest Path First (SPF) algorithm executed locally.
Convergence Speed Slow convergence; vulnerable to routing loops and Count-to-Infinity. Fast convergence; zero routing loops.
Standard Protocols Routing Information Protocol (RIP, max 15 hops), IGRP. Open Shortest Path First (OSPF), IS-IS.
The Count-to-Infinity Problem & Solutions:
When a link breaks in Distance Vector routing, two adjacent routers can update each other iteratively, incrementing hop count indefinitely ($2 \to 3 \to 4 \dots \to \infty$) until reaching infinity ($16$ in RIP).
• Split Horizon: A router never advertises a route back out the same interface through which it learned it.
• Poison Reverse: When advertising a route back to the neighbor it was learned from, mark its metric as $\infty$ (poisoned) to prevent loops!
6. Congestion Control: Leaky Bucket vs. Token Bucket Algorithms
⭐ CSJMU PYQs: 2024–25, 2023–24, 2020 (Traffic shaping: Leaky Bucket vs Token Bucket with diagrams)

Congestion occurs when the number of packets entering a network exceeds the handling capacity of intermediate links and buffers. Traffic Shaping regulates packet transmission rates to prevent router buffer overflow.

Evaluation Parameter Leaky Bucket Algorithm Token Bucket Algorithm
Output Transmission Rate Strictly constant, smooth rate regardless of how bursty the incoming traffic is. Allows controlled bursts of high-speed traffic as long as tokens are available in the bucket.
Handling Bursty Traffic Bursts are smoothed out; if the bucket fills, incoming excess packets are discarded immediately. Bursts are transmitted instantly up to token capacity without packet loss.
Token Accumulation No token concept; operates like a physical bucket with a constant hole at the bottom. Tokens are deposited into the bucket at a constant rate $r$ up to capacity $C$. Each packet consumes 1 token.
Primary Application ATM networks, traffic policing. Modern IP QoS, DiffServ, video streaming over Internet.
Mathematical Maximum Burst Duration in Token Bucket:
Let token generation rate be $r$ bytes/sec, bucket capacity be $C$ bytes, and maximum physical burst transmission rate be $M$ bytes/sec (where $M > r$). The maximum burst duration $S$ is: $$\mathbf{S = \frac{C}{M - r}} \quad \text{seconds}$$
7. IPv4 Header Format & IPv6 Transition Mechanisms
⭐ CSJMU PYQs: 2025–26, 2022–23, 2019 (Draw and explain IPv4 header fields, compare IPv4 vs IPv6)

IPv4 20-Byte Base Header Format:

 0                   1                   2                   3
 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version|  IHL  |Type of Service|          Total Length         |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|         Identification        |Flags|     Fragment Offset     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|  Time to Live |    Protocol   |        Header Checksum        |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                       Source IP Address                       |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|                    Destination IP Address                     |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
Header FieldSizeTechnical Function
Version4 bitsIdentifies IP version (0100 for IPv4, 0110 for IPv6).
IHL (Header Length)4 bitsHeader length in 32-bit (4-byte) words. Minimum value is 5 ($5 \times 4 = 20$ bytes).
Total Length16 bitsTotal size of packet (header + payload) in bytes. Maximum is $2^{16}-1 = 65,535$ bytes.
TTL (Time to Live)8 bitsHop counter decremented by 1 at every router. When TTL reaches 0, router drops packet and sends ICMP Time Exceeded (prevents infinite packet loops!).
Protocol8 bitsIdentifies higher transport protocol: 6 for TCP, 17 for UDP, 1 for ICMP.
IPv4 to IPv6 Transition Strategies (CSJMU 2022–23):
1. Dual Stack: Routers and hosts run both IPv4 and IPv6 protocol stacks concurrently.
2. Tunneling: IPv6 packets are encapsulated inside IPv4 packets to traverse legacy IPv4 networks (e.g. 6to4).
3. Network Address Translation - Protocol Translation (NAT-PT): Translates IPv6 packet headers directly into IPv4 headers.
8. Exam Answer Blueprint & Pitfalls to Avoid
How to Score Full 10 Marks on "Network Connecting Devices":
  1. OSI Layer Mapping (2 Marks): State the exact OSI layer for each device (Repeater/Hub: Layer 1, Bridge/Switch: Layer 2, Router: Layer 3, Gateway: Layer 4-7).
  2. Domain Analysis (3 Marks): Clearly explain how Hubs share collision domains, Switches break collision domains, and Routers break broadcast domains.
  3. Working Mechanism (3 Marks): Mention that Switches forward frames using MAC addresses, while Routers forward packets using IP routing tables.
  4. Summary Table (2 Marks): Draw a clean comparison table summarizing all 5 devices.
⚠️ Common Exam Mistakes:
• Forgetting to subtract 2 for usable hosts: Total hosts is $2^h$, but usable hosts is ALWAYS $2^h - 2$ because the all-zeros host address is the Network ID and the all-ones host address is the Directed Broadcast Address!
• Confusing Collision Domains and Broadcast Domains on a Switch: A switch creates separate collision domains for every port, but all ports still belong to a SINGLE broadcast domain!
📝 Unit IV Exam Mastery MCQ Quiz (10 Questions)

Answer all 10 questions covering network hardware layers, collision domains, bit stuffing, and IPv4 subnetting.