COMPUTER NETWORKS/Student Engineering Notebook
Page 07·notes
NETWORK LAYER, IPV4 ADDRESSING & CIDR SUBNETTING—~28 MIN READ

IPv4 Header, Packet Fragmentation & CIDR Subnetting

“Header fields, MTU fragmentation offsets, and VLSM network bit masks.”

1.IPv4 Header Fields: Crucial Exam Dimensions

The IPv4 header has a variable length: 20 bytes (minimum, when Options field is empty) up to 60 bytes (maximum, when Options field is 40 bytes).

Key Header Fields:

1. HLEN (Header Length, 4 bits): Expressed in 4-byte (32-bit) words. Minimum value is 5 (5 4 = 20 bytes). Maximum value is 15 (15 4 = 60 bytes).

2. Total Length (16 bits): Entire IP datagram size (Header + Data) in bytes. Maximum theoretical datagram size = 2^16 - 1 = 65,535 bytes.

3. TTL (Time to Live, 8 bits): Hop counter decremented by 1 at each router. When TTL reaches 0, router drops the packet and sends an ICMP Time Exceeded (Type 11) message back to the sender.

4. Protocol (8 bits): Multiplexing identifier for higher layer: 1 = ICMP, 2 = IGMP, 6 = TCP, 17 = UDP, 89 = OSPF.

5. Fragmentation Fields: Identification (16 bits), Flags (3 bits: Reserved, DF, MF), Fragment Offset (13 bits).

notice this:— The 8-Byte Offset Scale Factor

Because the Fragment Offset field is only 13 bits (range 0 to 8191) while the datagram can be 65,535 bytes long, the offset is measured in units of 8-BYTE BLOCKS! Every fragment data payload MUST be an exact multiple of 8 bytes (except the final fragment).

WORKED EXAM ANALYSIS · STEP-BY-STEP DERIVATION2 Marks (Compulsory in GATE CS)

2. GATE Step-by-Step Numerical: IP Datagram Fragmentation

⚠️ Pitfall Warning:

Remember to subtract the 20-byte IP header from the link MTU to determine maximum payload per fragment, and ensure payload is divisible by 8!

Problem: An IPv4 datagram of Total Length = 4000 bytes (with 20-byte IP header) arrives at a router whose output interface has an MTU (Maximum Transmission Unit) of 1500 bytes. Calculate the number of fragments, their sizes, DF/MF flags, and fragment offsets.

Step 1: Total Data Payload = 4000 - 20 = 3980 bytes.

Step 2: Maximum payload per fragment = MTU - Header = 1500 - 20 = 1480 bytes. Since 1480 / 8 = 185 (exact integer), 1480 is valid.

Step 3: Fragment generation:

Fragment 1: Payload = 1480 bytes (bytes 0 to 1479). Total Length = 1500 bytes. MF = 1. Offset = 0 / 8 = 0.

Fragment 2: Payload = 1480 bytes (bytes 1480 to 2959). Total Length = 1500 bytes. MF = 1. Offset = 1480 / 8 = 185.

Fragment 3: Remaining Payload = 3980 - (1480 + 1480) = 1020 bytes (bytes 2960 to 3979). Total Length = 1020 + 20 = 1040 bytes. MF = 0 (last fragment!). Offset = 2960 / 8 = 370.

Summary: 3 fragments with Offsets [0, 185, 370] and MF flags [1, 1, 0].

3.CIDR (Classless Inter-Domain Routing) & Subnet Mathematics

Classless addressing uses CIDR notation: a.b.c.d / n, where n is the prefix length (number of contiguous 1s in the subnet mask, 0 <= n <= 32).

Formulas for /n Block:

1. Subnet Mask: n bits of 1s followed by (32 - n) bits of 0s.

2. Host bits h = 32 - n.

3. Total IP addresses in block = 2^h = 2^(32 - n).

4. Usable Host addresses = 2^h - 2 (subtracting Network Address where host bits are all 0s, and Direct Broadcast Address where host bits are all 1s).

5. Network Address: IP address bitwise-AND Subnet Mask.

6. Broadcast Address: Network Address with all h host bits set to 1.

WORKED EXAM ANALYSIS · STEP-BY-STEP DERIVATION1-2 Marks

4. GATE Worked Numerical: Subnet Mask & Usable IP Range

⚠️ Pitfall Warning:

Always check which octet the prefix split falls into. For /26, 26 = 8 + 8 + 8 + 2, so the boundary is in the 4th octet with 2 subnet bits and 6 host bits.

Problem: An ISP assigns host IP 198.51.100.142 / 27. Find the Subnet Mask, Network ID, Broadcast ID, and the range of usable host addresses.

Step 1: Prefix /27 means 27 ones: 11111111.11111111.11111111.11100000 -> Subnet Mask = 255.255.255.224.

Step 2: Host bits h = 32 - 27 = 5 bits. Block size = 2^5 = 32 addresses.

Step 3: Analyze 4th octet (142 in binary = 10001110):

142 / 32 = 4 with remainder 14.

Block begins at 4 * 32 = 128 (10000000).

Network Address = 198.51.100.128.

Step 4: Block ends at 128 + 32 - 1 = 159 (10011111).

Direct Broadcast Address = 198.51.100.159.

Step 5: Usable Host IP Range = 198.51.100.129 to 198.51.100.158 (Total = 32 - 2 = 30 usable hosts).

SOURCE TRANSPARENCY & CITATIONS

Primary Academic References & Exam Sources

Every concept in Notes From a B.Tech Brain is synthesized from authoritative academic texts, seminal peer-reviewed research, verified exam archives, and renowned university lectures.

Curated University Lecture Series
Computer Networking: A Top-Down Approach (8th Edition) ·
LECTURE SERIES
RECOMMENDED YOUTUBE EDUCATORS & FULL-COURSE PLAYLISTS

Curated for clarity, rigorous numerical solving, and semester excellence:

Knowledge Gate · Computer Networks for GATE↗Instructor: Sanchit Jain · Covers: OSI/TCP-IP layers, sliding window, CRC, subnetting, TCP congestion control

GATE-level numerical drilling and PYQ analysis.

Open YouTube↗
Gate Smashers · Computer Networks Full Course↗Instructor: Varun Singla · Covers: Ethernet, IP addressing, routing algorithms, TCP/UDP, DNS & HTTP

Step-by-step conceptual walkthroughs with worked GATE numericals.

Open YouTube↗
Neso Academy · Computer Networks Series↗Instructor: Neso Academy · Covers: Data link layer, framing, error detection, medium access, TCP/IP

Clear whiteboard lectures for foundational and semester exam coverage.

Open YouTube↗