Kyūkei Master Hub
SCS2111 | Phase 5: IP Addressing & Subnetting Math (25-Mark Master Guide)
👁️ -- opens | 0%
SCS2111 Phase 5: IP & Subnetting
PHASE 05

IPv4 / IPv6 Addressing & VLSM Subnetting Mathematics

Exhaustive 25-mark university exam master guide: Conceptual foundations, binary conversions, bitwise AND operations, FLSM vs VLSM algorithms, Magic Number block size shortcuts, and IPv6 address parsing.

2. Conceptual Foundations: What is IP Addressing, What is Subnetting, and Why Do We Subnet?

Before diving into binary calculations and mask math, an engineer must understand the fundamental core concepts: what an IP address represents, what subnetting actually is, and why network engineers must subnet enterprise networks.

CONCEPT 1

What is an IP Address? (Logical Postal Address Analogy)

An Internet Protocol (IP) Address is a logical Layer-3 software address assigned to any network interface (PC, server, router port, printer) communicating over a TCP/IP network.

Real-World Postal Analogy: Think of a device's MAC Address as a person's National ID Number (permanent, hardware-burned identity that never changes regardless of where you move). In contrast, an IP Address is a person's Mailing / Postal Address (location-dependent; it changes whenever you connect to a different network, specifying your current city, street, and house number).

Every IP address is divided into two distinct components:
Network ID (Prefix): Identifies the specific network segment (like the City & Street name).
Host ID (Suffix): Identifies the specific device on that network segment (like the House number).

CONCEPT 2

What is Subnetting? (Sub-Networking)

Subnetting (Sub-Networking) is the process of partitioning a single large physical or logical network block into multiple smaller, independent sub-networks called Subnets.

Conceptually, subnetting is accomplished by "borrowing bits" from the Host portion of an IP address and reallocating them to the Network portion. This creates smaller, manageable network boundaries separated by Layer 3 routers or firewalls.

CONCEPT 3

Why Do We Subnet? (4 Essential Engineering Reasons)

In enterprise environments, flat un-subnetted networks lead to severe performance degradation. Engineers subnet for four core reasons:

1. Broadcast Storm Suppression

In a flat network with 2,000 PCs, any ARP request or broadcast packet (FF:FF:FF:FF:FF:FF) is processed by all 2,000 devices, causing massive CPU overhead and broadcast storms. Subnetting locks broadcast traffic inside small local segments (e.g. 50 devices per subnet).

2. Security & Departmental Isolation

On a flat network, any user can intercept or access other computers. Subnetting logically isolates departments (e.g. Finance vs Students vs Server Farm). Routers can enforce Access Control Lists (ACLs) and firewall policies between subnets.

3. IP Address Conservation

Without subnetting, assigning a Class C block (254 IPs) to a remote router link needing only 2 IPs wastes 252 IP addresses! Subnetting (VLSM) lets engineers allocate exact block sizes (e.g. a /30 prefix with exactly 2 usable IPs), preserving address space.

4. Hierarchical Routing & Management

Simplifies network administration and allows core routers to route to a single summary network address (Route Summarization) rather than maintaining thousands of individual host routes in memory.

3. Fundamentals of IPv4 Addressing (32-Bit Structure)

An Internet Protocol Version 4 (IPv4) address is a 32-bit binary number uniquely identifying a network interface on a TCP/IP network. For human readability, it is expressed in Dotted-Decimal Notation consisting of four 8-bit groupings called Octets separated by decimal points.

Binary Octet Positional Values

Each octet contains 8 bits, where each bit position represents a power of 2 ($2^7$ down to $2^0$):

Bit Position Bit 7 Bit 6 Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0
Exponent Power ($2^p$) $2^7$ $2^6$ $2^5$ $2^4$ $2^3$ $2^2$ $2^1$ $2^0$
Decimal Value 128 64 32 16 8 4 2 1

Example: Binary 11000000 $= 128 + 64 + 0 + 0 + 0 + 0 + 0 + 0 = \mathbf{192}$.

Special IP Address Types in Every Subnet

  • Network ID (Address): All host bits are set to 0. Identifies the network segment itself. Cannot be assigned to a device.
  • Broadcast Address: All host bits are set to 1. Sends data to all nodes on the subnet (Destination MAC: FF:FF:FF:FF:FF:FF). Cannot be assigned to a host.
  • First Usable Host IP: Network Address $+ 1$.
  • Last Usable Host IP: Broadcast Address $- 1$.
  • Usable Hosts Formula: $2^h - 2$ (where $h$ is the number of host bits; we subtract 2 for Network & Broadcast IDs).

4. Classful IPv4 Addressing Scheme

Historically (RFC 791), IPv4 addresses were divided into 5 distinct classes based on the high-order leading bits of the first octet:

Class Lead Bits First Octet Range Default Subnet Mask Net / Host Split Usable Hosts per Network
Class A 0... 1 – 126 255.0.0.0 (/8) 8 Net / 24 Host $2^{24} - 2 = 16,777,214$
Class B 10... 128 – 191 255.255.0.0 (/16) 16 Net / 16 Host $2^{16} - 2 = 65,534$
Class C 110... 192 – 223 255.255.255.0 (/24) 24 Net / 8 Host $2^{8} - 2 = 254$
Class D 1110... 224 – 239 N/A (Multicast) Reserved for Multicast Group Streams
Class E 1111... 240 – 255 N/A (Experimental) Reserved for Research & Development
⚠️ Note on 127.x.x.x: The first octet 127 (127.0.0.0 – 127.255.255.255) is omitted from Class A because it is reserved globally for local loopback testing (e.g. 127.0.0.1).

5. RFC 1918 Private IP Address Space

To prevent premature IPv4 depletion, RFC 1918 designated three non-routable private address blocks for internal LANs. Private IPs cannot be routed directly over the public Internet and require Network Address Translation (NAT) at the perimeter firewall:

  • Class A Private Block: 10.0.0.0 – 10.255.255.255 (10.0.0.0/8) $\rightarrow 16,777,216$ private IPs.
  • Class B Private Block: 172.16.0.0 – 172.31.255.255 (172.16.0.0/12) $\rightarrow 1,048,576$ private IPs.
  • Class C Private Block: 192.168.0.0 – 192.168.255.255 (192.168.0.0/16) $\rightarrow 65,536$ private IPs.

6. The Bitwise AND Operation & Magic Number Shortcut

How Routers Determine Network Address (Bitwise AND)

A router determines which subnet an incoming IP address belongs to by performing a bitwise logical AND operation between the IP address and the Subnet Mask:

IP Address:   192.168.10.75  --> 11000000.16810000.00001010.01001011
Subnet Mask:  255.255.255.192 --> 11111111.11111111.11111111.11000000
-----------------------------------------------------------------------
Bitwise AND:  192.168.10.64  --> 11000000.16810000.00001010.01000000

The "Magic Number" Block Size Shortcut Method

Instead of converting to binary during an exam, use the Magic Number (Block Size) Shortcut:

Magic Number (Block Size S) = 256 - (Subnet Mask in Interesting Octet)

Example: For a 255.255.255.224 mask (/27):
• The interesting octet is octet 4 (value = 224).
• Magic Number $S = 256 - 224 = \mathbf{32}$.
• Therefore, subnets increment in multiples of 32: .0, .32, .64, .96, .128, .160, .192, .224.

7. FLSM vs. VLSM Subnetting Architecture

FLSM (Fixed Length)

Fixed-Length Subnet Masking

All subnets are partitioned into identical equal-sized blocks using a single static subnet mask.

  • Formula for Subnets created: $2^s$ (where $s$ is borrowed bits).
  • Disadvantage: Wastes massive IP address space when smaller departments need only 2 or 5 hosts.
VLSM (Variable Length)

Variable-Length Subnet Masking

Subnets are partitioned into dynamically sized custom blocks tailored strictly to host requirements.

  • Allows subnets to use different subnet masks (e.g. /25, /27, /30).
  • Eliminates IP address waste; essential for enterprise and WAN point-to-point links.

8. Master 25-Mark VLSM Subnetting Exam Worked Problem

Full 25-Mark Exam Question

NUST Exam Problem Scenario

An IT network manager is assigned the base IPv4 network block 192.168.50.0/24. Using Variable Length Subnet Masking (VLSM), design an optimal IP addressing scheme for the following five enterprise network requirements:
Subnet A (Sales Dept): Requires 110 usable hosts
Subnet B (Engineering): Requires 50 usable hosts
Subnet C (Human Resources): Requires 22 usable hosts
Subnet D (IT Support): Requires 10 usable hosts
Subnet E (Router WAN Link): Requires 2 usable hosts

Step-by-Step Solution Derivation & Execution

Step 1: Sort Requirements from Largest to Smallest Host Count

Sorting order: Subnet A (110) $\rightarrow$ Subnet B (50) $\rightarrow$ Subnet C (22) $\rightarrow$ Subnet D (10) $\rightarrow$ Subnet E (2).

Step 2: Calculate Required Host Bits ($h$), CIDR ($32 - h$), and Block Size ($S = 2^h$)

  • Subnet A (110 hosts): Need $2^h - 2 \ge 110 \rightarrow 2^7 - 2 = 126$ hosts ($h=7$). CIDR $= 32 - 7 = \mathbf{/25}$. Block Size $S = 2^7 = \mathbf{128}$. Subnet Mask: 255.255.255.128.
  • Subnet B (50 hosts): Need $2^h - 2 \ge 50 \rightarrow 2^6 - 2 = 62$ hosts ($h=6$). CIDR $= 32 - 6 = \mathbf{/26}$. Block Size $S = 2^6 = \mathbf{64}$. Subnet Mask: 255.255.255.192.
  • Subnet C (22 hosts): Need $2^h - 2 \ge 22 \rightarrow 2^5 - 2 = 30$ hosts ($h=5$). CIDR $= 32 - 5 = \mathbf{/27}$. Block Size $S = 2^5 = \mathbf{32}$. Subnet Mask: 255.255.255.224.
  • Subnet D (10 hosts): Need $2^h - 2 \ge 10 \rightarrow 2^4 - 2 = 14$ hosts ($h=4$). CIDR $= 32 - 4 = \mathbf{/28}$. Block Size $S = 2^4 = \mathbf{16}$. Subnet Mask: 255.255.255.240.
  • Subnet E (2 hosts): Need $2^h - 2 \ge 2 \rightarrow 2^2 - 2 = 2$ hosts ($h=2$). CIDR $= 32 - 2 = \mathbf{/30}$. Block Size $S = 2^2 = \mathbf{4}$. Subnet Mask: 255.255.255.252.

Step 3: Complete Master VLSM Address Allocation Table (25 Marks)

Subnet Name Req. Hosts CIDR Prefix Subnet Mask Network IP First Usable IP Last Usable IP Broadcast IP
Subnet A (Sales) 110 /25 255.255.255.128 192.168.50.0 192.168.50.1 192.168.50.126 192.168.50.127
Subnet B (Eng) 50 /26 255.255.255.192 192.168.50.128 192.168.50.129 192.168.50.190 192.168.50.191
Subnet C (HR) 22 /27 255.255.255.224 192.168.50.192 192.168.50.193 192.168.50.222 192.168.50.223
Subnet D (IT) 10 /28 255.255.255.240 192.168.50.224 192.168.50.225 192.168.50.238 192.168.50.239
Subnet E (WAN Link) 2 /30 255.255.255.252 192.168.50.240 192.168.50.241 192.168.50.242 192.168.50.243

9. Cisco Wildcard Masks (Inverse Subnet Masking)

In Cisco IOS CLI configurations (such as Access Control Lists - ACLs and OSPF network statements), a Wildcard Mask is used instead of a standard subnet mask.

Wildcard Mask = 255.255.255.255 - (Subnet Mask)
CIDR Prefix Subnet Mask Cisco Wildcard Mask Cisco OSPF CLI Configuration Example
/24 255.255.255.0 0.0.0.255 network 192.168.10.0 0.0.0.255 area 0
/26 255.255.255.192 0.0.0.63 network 192.168.50.128 0.0.0.63 area 0
/27 255.255.255.224 0.0.0.31 network 192.168.50.192 0.0.0.31 area 0
/30 255.255.255.252 0.0.0.3 network 192.168.50.240 0.0.0.3 area 0

10. Next-Generation IPv6 Addressing Architecture

IPv6 128-Bit Structure & Abbreviation Rules

IPv6 addresses are 128 bits in length, represented as eight groups of four hexadecimal digits (hextets) separated by colons (e.g. 2001:0db8:85a3:0000:0000:8a2e:0370:7334).

Two Zero Abbreviation Rules:

  1. Rule 1: Omit Leading Zeros in any Hextet:
    0db8 becomes db8
    0000 becomes 0
  2. Rule 2: Double Colon (::) Compression:
    • Replaces any single contiguous sequence of all-zero hextets with a double colon (::).
    CRITICAL EXAM RULE: The double colon :: can ONLY be used ONCE per IPv6 address to prevent ambiguity!
IPv6 Compression Step-by-Step Example
Original Address:   2001:0db8:0000:0000:0000:0000:1428:57ab
Rule 1 (Leading 0s): 2001:db8:0:0:0:0:1428:57ab
Rule 2 (Double ::):  2001:db8::1428:57ab  (Compressed Final Form)

IPv6 Scope Types

  • Global Unicast Address (GUA): Begins with 2000::/3 (2000:: to 3FFF::). Globally unique and routable on the public Internet.
  • Link-Local Address: Begins with fe80::/10. Used exclusively for local link hop-by-hop communications (e.g. NDP, router discovery). Automatically generated on every IPv6 interface.
  • Unique Local Address (ULA): Begins with fc00::/7 (fc00:: to fdff::). Equivalent to IPv4 RFC 1918 private IP addresses.
  • Loopback Address: ::1/128 (Equivalent to IPv4 127.0.0.1).