Computer Networks: Layer 3 Network Layer Comprehensive Study Guide

Network Layer Overview and Core Services

  • Architectural Position and Responsibility:

    • The network layer corresponds to Layer 3 of the Open Systems Interconnection (OSI) reference model and maps directly to the Internet Protocol (IP) layer in the TCP/IP protocol suite.

    • It is responsible for the end-to-end delivery of packets (datagrams) from the source host to the destination host across multiple heterogeneous, interconnected networks.

    • It contrasts fundamentally with the data-link layer (Layer 2), which is strictly confined to hop-by-hop frame delivery across a single physical or logical link.

    • The network layer steers datagrams across an arbitrary number of intermediate routers and diverse link-layer technologies (such as Ethernet, Point-to-Point Protocol, or Wi-Fi) along the end-to-end path.

  • Core Services Provided by the Network Layer:

    • Packetizing: Encapsulates transport-layer segments into network-layer datagrams at the source system by appending an IP header, and decapsulates the datagram at the destination system before passing the payload upward to the transport layer.

    • Routing: Determines the optimal, least-cost path from source to destination across multiple router hops by executing routing algorithms and building and maintaining routing and forwarding tables.

    • Forwarding: Executes the local transfer of a packet from a router's input port to the appropriate output port based on matching criteria in the local forwarding table.

    • Error Control: Strictly limited within IPv4 to verifying the integrity of the datagram header via the Header Checksum field. Payload error control is omitted at Layer 3 and delegated to transport or application layers.

    • Flow Control: Completely absent at the IPv4 network layer; end-to-end flow regulation is handled exclusively by transport-layer protocols such as TCP.

    • Congestion Control: Managed indirectly; the network layer operates on a best-effort delivery paradigm, relying on upper-layer transport protocols (e.g., TCP window management and congestion avoidance algorithms) to detect and react to network congestion.

    • Quality of Service (QoS): Facilitated through the Differentiated Services (DiffServ / DSCP) and Explicit Congestion Notification (ECN) fields in the IPv4 header to support service classification and traffic prioritization.

    • Security: Provided via the IP Security (IPsec) protocol suite, enabling network-layer encryption, integrity verification, and sender authentication.

  • Data Plane vs. Control Plane Architecture:

    • Data Plane (Forwarding Plane):

      • Performs a local, per-router function operating on a nanosecond timescale.

      • Inspects arrival datagram headers, queries the hardware forwarding table (often maintained in Ternary Content-Addressable Memory / TCAM), and switches the datagram from an input interface to the designated output interface.

      • Implemented predominantly in high-speed hardware in modern routing hardware.

    • Control Plane (Routing Plane):

      • Encompasses network-wide distributed logic that determines how datagrams are routed end-to-end across routers.

      • Operates on a millisecond-to-second timescale.

      • Computes and installs entries into local forwarding tables through distributed routing protocols (e.g., RIP, OSPF, BGP) or via centralized Software-Defined Networking (SDN) controllers.

      • Core Distinction: The control plane computes the routing decisions, whereas the data plane executes the forwarding action.

Packet Switching Architectures: Datagram vs. Virtual Circuit

  • Datagram (Connectionless) Approach:

    • Adopted by the Internet Protocol (both IPv4 and IPv6).

    • Packets are treated as independent units of data called datagrams.

    • Every datagram carries full source and destination IP addresses in its header.

    • Routers evaluate each datagram independently against forwarding tables; successive datagrams belonging to the exact same application-layer session may traverse completely different physical paths.

    • Requires no preliminary connection setup phase prior to data transmission.

    • Highly fault-tolerant: intermediate link or node failures trigger automatic local or global recalculation of paths, allowing packets to bypass failed equipment.

    • Does not guarantee in-order delivery; out-of-order packets must be reordered by the receiving host's transport layer (e.g., TCP).

    • Analogy: Sending individual letters through a postal service where each envelope is addressed independently and travels via available postal sorting routes.

  • Virtual-Circuit (Connection-Oriented) Approach:

    • Utilized in legacy and specialized telecommunication frameworks such as Asynchronous Transfer Mode (ATM), Frame Relay, and Multi-Protocol Label Switching (MPLS).

    • Requires an explicit three-phase communication lifecycle: connection setup (establishing the virtual circuit), data transfer, and connection teardown.

    • A single, fixed logical path is established across intermediate switches during the setup phase.

    • Datagrams do not carry full network addresses during data transfer; instead, they carry a short, locally significant Virtual Circuit Identifier (VCI) or label in their headers.

    • Switches maintain internal translation tables that map an incoming interface and incoming VCI to an outgoing interface and outgoing VCI.

    • Vulnerable to intermediate failures: if a switch or link along the virtual path fails, the entire virtual circuit terminates and must be renegotiated from scratch.

    • Analogy: Reserving a dedicated railway track where the entire train route is scheduled and locked prior to departure, forcing every carriage to travel over the identical path.

  • Systematic Comparison of Packet-Switching Approaches:

    • Connection Setup: Datagram requires no setup; Virtual Circuit mandates pre-established setup.

    • Routing Decision: Datagram evaluates routing per packet; Virtual Circuit evaluates routing per connection during setup.

    • End-to-End Path: Datagram paths may vary dynamically; Virtual Circuit paths remain strictly fixed for the connection duration.

    • Header Overhead: Datagram headers require complete source and destination global addresses (32 bits32\,\text{bits} each in IPv4); Virtual Circuit headers use small VCI labels.

    • Failure Recovery: Datagram handles failures easily via dynamic re-routing; Virtual Circuit recovery is difficult, requiring connection re-establishment.

    • Representative Protocols: Datagram is exemplified by IPv4 and IPv6; Virtual Circuit is exemplified by ATM, MPLS, and Frame Relay.

IPv4 Addressing: Foundations and Structure

  • Addressing Rationale and Hierarchy:

    • In a planetary-scale internetwork, every active network interface requires an unambiguous, globally unique, routable identifier.

    • A flat 32-bit addressing scheme (e.g., assigning random flat numbers to interfaces) would require every core router to store entries for all 232≈4.3×1092^{32} \approx 4.3 \times 10^9 interfaces, resulting in immediate forwarding table exhaustion and memory failure.

    • Hierarchical addressing solves this scalability bottleneck by splitting the address into two distinct administrative segments:

      • Network Prefix (Network ID): Identifies the specific organization, network domain, or geographical neighborhood. Core routers need only inspect the prefix to forward packets toward the destination network.

      • Host Suffix (Host ID): Identifies the specific physical or virtual network interface on that local network. Only routers directly attached to the destination network inspect the host suffix.

    • Analogy: A postal address where sorting offices only examine the state and postal code (network prefix) to route letters across cities, while the local mail carrier evaluates the specific street and house number (host ID) on the final delivery leg.

    • An IPv4 address uniquely identifies an interface rather than a device; a router or multi-homed computer possessing multiple network interfaces requires a unique IP address for each respective interface.

  • IPv4 Address Structure and Notation:

    • Total Length: Exactly 32 bits32\,\text{bits} (4 bytes4\,\text{bytes}).

    • Total Theoretical Address Space: 232=4,294,967,296 addresses2^{32} = 4,294,967,296\,\text{addresses}.

    • Binary Representation: 32 bits32\,\text{bits} grouped into four 8 bit8\,\text{bit} octets, for example: 10000000 00001011 00000011 00011111.

    • Dotted-Decimal Representation: Each octet is independently converted to a base-10 integer (ranging from 00 to 255255) and separated by periods, for example: 128.11.3.31.

    • Hexadecimal Representation: Four bytes represented as eight hexadecimal characters, for example: 800B031F.

Classful IPv4 Addressing Architecture

  • Classful Partitioning Overview:

    • Designed in the early 1980s to accommodate organizations of vastly disparate scales by establishing three primary fixed-boundary classes (A, B, and C) alongside two specialized classes (D and E).

    • The address class is uniquely identified by the leading bits of the first octet.

  • Class Characteristics and Boundaries:

    • Class A:

      • Leading Bits: 0...

      • First Octet Range: 0 to 1270\text{ to }127 (Binary: 00000000 to 01111111).

      • Network Prefix: /8/8 (8 network bits8\,\text{network bits}, 24 host bits24\,\text{host bits}).

      • Default Subnet Mask: 255.0.0.0.

      • Maximum Usable Hosts per Network: 224−2=16,777,214 hosts2^{24} - 2 = 16,777,214\,\text{hosts}.

    • Class B:

      • Leading Bits: 10...

      • First Octet Range: 128 to 191128\text{ to }191 (Binary: 10000000 to 10111111).

      • Network Prefix: /16/16 (16 network bits16\,\text{network bits}, 16 host bits16\,\text{host bits}).

      • Default Subnet Mask: 255.255.0.0.

      • Maximum Usable Hosts per Network: 216−2=65,534 hosts2^{16} - 2 = 65,534\,\text{hosts}.

    • Class C:

      • Leading Bits: 110...

      • First Octet Range: 192 to 223192\text{ to }223 (Binary: 11000000 to 11011111).

      • Network Prefix: /24/24 (24 network bits24\,\text{network bits}, 8 host bits8\,\text{host bits}).

      • Default Subnet Mask: 255.255.255.0.

      • Maximum Usable Hosts per Network: 28−2=254 hosts2^8 - 2 = 254\,\text{hosts}.

    • Class D:

      • Leading Bits: 1110...

      • First Octet Range: 224 to 239224\text{ to }239 (Binary: 11100000 to 11101111).

      • Purpose: Multicast addressing. No network/host bit division exists; addresses identify logical multicast groups.

    • Class E:

      • Leading Bits: 1111...

      • First Octet Range: 240 to 255240\text{ to }255 (Binary: 11110000 to 11111111).

      • Purpose: Reserved for experimental, research, and future use.

  • Mathematical Rationale for Reserved Addresses (2h−22^h - 2):

    • For any subnet or network block containing hh host bits, total theoretical combinations equal 2h2^h, but usable assignable addresses equal 2h−22^h - 2.

    • Network Address (Host Bits All 0): Uniquely identifies the network itself. Appears exclusively in routing tables and internal forwarding entries. It cannot be bound to a network interface card.

    • Directed Broadcast Address (Host Bits All 1): Serves as a broadcast transmission destination directed to every host residing on that specific network. Consumed by the network infrastructure, it cannot be assigned to an interface.

  • Special Purpose IPv4 Addresses:

    • 0.0.0.0: Represents "this host on this network"; utilized by hosts as a source address during bootstrap configuration procedures (e.g., DHCP DISCOVER).

    • 255.255.255.255: Limited broadcast address; delivers frames to every host on the local physical network segment. Routers do not forward this packet across subnet boundaries.

    • 127.0.0.1 (and the entire 127.0.0.0/8 block): Loopback address; used by a host to send network traffic to itself for local software diagnostics without transmitting data onto any physical link.

  • Private Address Allocations (RFC 1918):

    • Reserved exclusively for non-routable private organizational use; packets bearing these addresses are discarded by default by public Internet core routers:

      • Class A Range: 10.0.0.0 to 10.255.255.255 (/8/8 prefix, 1 block1\,\text{block} of 16,777,216 addresses16,777,216\,\text{addresses}).

      • Class B Range: 172.16.0.0 to 172.31.255.255 (/12/12 prefix, 16 contiguous Class B blocks16\,\text{contiguous Class B blocks}, 1,048,576 addresses1,048,576\,\text{addresses}).

      • Class C Range: 192.168.0.0 to 192.168.255.255 (/16/16 prefix, 256 contiguous Class C blocks256\,\text{contiguous Class C blocks}, 65,536 addresses65,536\,\text{addresses}).

  • Failure of the Classful Addressing Paradigm:

    • Coarse Granularity: Pre-defined allocation sizes lacked flexibility. An enterprise requiring 300 hosts300\,\text{hosts} could not fit within a Class C network (254 hosts254\,\text{hosts}) and was assigned a full Class B block (65,534 hosts65,534\,\text{hosts}), wasting over 65,000 addresses65,000\,\text{addresses}.

    • Address Exhaustion: By the early 1990s, Class B address spaces neared complete exhaustion, precipitating the urgent introduction of CIDR and VLSM.

Classless Inter-Domain Routing (CIDR)

  • CIDR Architectural Concepts:

    • Formally established in 1993 to eliminate fixed class boundaries (/8/8, /16/16, /24/24).

    • Allows the network prefix length nn to span any arbitrary integer value from 0 to 320\text{ to }32, denoted using slash notation: a.b.c.d/n.

    • Empowers Internet Service Providers (ISPs) to allocate right-sized blocks matched to organizational host counts (e.g., assigning a /23/23 block containing 512 addresses512\,\text{addresses} to an organization needing 300 hosts300\,\text{hosts}).

  • Mathematical Properties of a CIDR Block a.b.c.d/n:

    • Total Address Capacity: N=232−nN = 2^{32 - n}.

    • Number of Usable Host Interfaces: Nusable=232−n−2N_{\text{usable}} = 2^{32 - n} - 2.

    • Prefix Length: nn defines the number of leading binary ones in the subnet mask.

    • Host Bits: h=32−nh = 32 - n.

    • Network Address (First Address): Evaluated mathematically by applying a bitwise AND between the 32-bit IP address and the 32-bit subnet mask (setting the last 32−n32 - n bits to 0).

    • Directed Broadcast Address (Last Address): Evaluated mathematically by applying a bitwise OR between the 32-bit IP address and the bitwise NOT of the subnet mask (setting the last 32−n32 - n bits to 1).

  • Worked Analysis: Evaluating Block 167.199.170.82/27:

    • Step 1: Determine Address Count:

      • n=27n = 27, so remaining host bits h=32−27=5h = 32 - 27 = 5.

      • Total addresses N=25=32N = 2^5 = 32.

      • Usable host addresses = 32−2=3032 - 2 = 30.

    • Step 2: Binary Decomposition:

      • Address 167.199.170.82 in binary:             Octet 1: 167=101001112\text{Octet 1: } 167 = 10100111_2             Octet 2: 199=110001112\text{Octet 2: } 199 = 11000111_2             Octet 3: 170=101010102\text{Octet 3: } 170 = 10101010_2             Octet 4: 82=010100102\text{Octet 4: } 82 = 01010010_2

      • Subnet mask /27/27 in binary (27 ones followed by 5 zeros):             Mask: 11111111.11111111.11111111.111000002=255.255.255.224\text{Mask: } 11111111.11111111.11111111.11100000_2 = 255.255.255.224

    • Step 3: Network Address Computation:

      • Evaluate fourth octet: 82 & 22482\,\&\,224             010100102 & 111000002=010000002=6401010010_2 \,\&\, 11100000_2 = 01000000_2 = 64

      • Network Address = 167.199.170.64/27.

    • Step 4: Broadcast Address Computation:

      • Evaluate fourth octet: 82 ∣ (∼224)82\,|\,(\sim 224)             ∼111000002=000111112\sim 11100000_2 = 00011111_2             010100102 ∣ 000111112=010111112=9501010010_2 \,|\, 00011111_2 = 01011111_2 = 95

      • Broadcast Address = 167.199.170.95/27.

    • Step 5: Usable Host Range:

      • From Network Address +1+ 1 to Broadcast Address −1- 1: 167.199.170.65 through 167.199.170.94.

  • Worked Analysis: Same-Subnet Determination:

    • Query: Determine if hosts 192.168.10.45 and 192.168.10.70 reside in the same /27/27 subnet.

    • Mask for /27/27 is 255.255.255.224.

    • Evaluate Host 1: 45=00101101245 = 00101101_2. 45 & 224=001011012 & 111000002=001000002=3245\,\&\,224 = 00101101_2 \,\&\, 11100000_2 = 00100000_2 = 32. Subnet ID = 192.168.10.32.

    • Evaluate Host 2: 70=01000110270 = 01000110_2. 70 & 224=010001102 & 111000002=010000002=6470\,\&\,224 = 01000110_2 \,\&\, 11100000_2 = 01000000_2 = 64. Subnet ID = 192.168.10.64.

    • Conclusion: Because 192.168.10.32 ≠\neq 192.168.10.64, the hosts occupy distinct subnets.

Subnetting Principles, Mechanics, and Design

  • Motivation for Subnetting:

    • Subnetting is the practice of dividing a single large network block into multiple smaller, logically distinct sub-networks (subnets).

    • Facilitates internal departmental isolation (e.g., separating university administration, engineering laboratories, and libraries).

    • Limits local broadcast domains, containing broadcast traffic to individual subnets rather than flooding an entire organizational campus.

    • Enhances network security and simplifies troubleshooting without requiring additional public IPv4 address blocks from external registries.

  • Bit-Borrowing Mechanics:

    • Subnetting introduces a third layer to the address hierarchy: Network Prefix | Subnet Bits | Host Bits.

    • An organization borrows nsn_s bits from the available host portion, converting them into subnet identifier bits.

    • Core Subnetting Formulas:

      • Number of Resulting Subnets: Nsubnets=2nsN_{\text{subnets}} = 2^{n_s}.

      • Host Bits Remaining: hremaining=horiginal−nsh_{\text{remaining}} = h_{\text{original}} - n_s.

      • Total Addresses per Subnet: 2hremaining2^{h_{\text{remaining}}}.

      • Usable Hosts per Subnet: Nusable=2horiginal−ns−2N_{\text{usable}} = 2^{h_{\text{original}} - n_s} - 2.

      • New Extended Prefix: nnew=noriginal+nsn_{\text{new}} = n_{\text{original}} + n_s.

  • Step-by-Step Subnetting Derivation: Carving 192.168.1.0/24 into Four Subnets:

    • Initial Conditions: Original block is 192.168.1.0/24. Host bits h=32−24=8h = 32 - 24 = 8. Total addresses = 28=2562^8 = 256.

    • Step 1: Compute Borrowed Bits (nsn_s):

      • Target: 4 subnets4\,\text{subnets}. Equation: 2ns≥4  ⟹  ns=22^{n_s} \ge 4 \implies n_s = 2.

    • Step 2: Determine New Prefix and Mask:

      • New Prefix: 24+2=2624 + 2 = 26 (/26/26).

      • Binary Mask: 11111111.11111111.11111111.11000000.

      • Dotted-Decimal Mask: 255.255.255.192.

    • Step 3: Calculate Subnet Stride (Block Size):

      • Remaining host bits: 8−2=68 - 2 = 6.

      • Addresses per subnet: 26=642^6 = 64.

      • Usable hosts per subnet: 64−2=6264 - 2 = 62.

    • Step 4: Enumerate Subnet Ranges:

      • Subnet 0 (Borrowed bits = 00): Network ID = 192.168.1.0/26; Usable Host Range = 192.168.1.1 to 192.168.1.62; Broadcast = 192.168.1.63.

      • Subnet 1 (Borrowed bits = 01): Network ID = 192.168.1.64/26; Usable Host Range = 192.168.1.65 to 192.168.1.126; Broadcast = 192.168.1.127.

      • Subnet 2 (Borrowed bits = 10): Network ID = 192.168.1.128/26; Usable Host Range = 192.168.1.129 to 192.168.1.190; Broadcast = 192.168.1.191.

      • Subnet 3 (Borrowed bits = 11): Network ID = 192.168.1.192/26; Usable Host Range = 192.168.1.193 to 192.168.1.254; Broadcast = 192.168.1.255.

Variable-Length Subnet Masking (VLSM)

  • VLSM Architecture and Purpose:

    • Standard subnetting forces every sub-network to maintain an identical prefix length, causing significant address waste when departmental sizes diverge.

    • VLSM enables a single autonomous network space to be partitioned into subnets with distinct prefix lengths tailored to exact departmental demands.

    • The Golden Allocation Rule: Subnets must strictly be allocated in descending order of size, satisfying the largest host requirements first.

    • Mathematical Reason for Largest-First Allocation: Subnet blocks in binary must align on boundaries that are integer multiples of their block size (e.g., a /25/25 block of 128 addresses128\,\text{addresses} must start at an address divisible by 128128; a /26/26 block must start at a multiple of 6464). Allocating small subnets first fragments the address space, preventing proper mathematical alignment for subsequent large blocks.

  • Detailed VLSM Design Walkthrough (Forouzan Example 7.5):

    • Given Allocation Block: 14.24.74.0/24 (Total addresses = 256256).

    • Department Requirements: Department A (120 hosts120\,\text{hosts}), Department B (60 hosts60\,\text{hosts}), Department C (10 hosts10\,\text{hosts}).

    • Subnet A Allocation (120 hosts):

      • Address demand: 120+2=122 addresses120 + 2 = 122\,\text{addresses}.

      • Smallest power of 2: 27=1282^7 = 128.

      • Host bits required: h=7  ⟹  n=32−7=25h = 7 \implies n = 32 - 7 = 25 (/25/25).

      • Subnet ID: 14.24.74.0/25.

      • Subnet Mask: 255.255.255.128.

      • Usable Range: 14.24.74.1 through 14.24.74.126 (126 usable hosts126\,\text{usable hosts}).

      • Broadcast Address: 14.24.74.127.

    • Subnet B Allocation (60 hosts):

      • Address demand: 60+2=62 addresses60 + 2 = 62\,\text{addresses}.

      • Smallest power of 2: 26=642^6 = 64.

      • Host bits required: h=6  ⟹  n=32−6=26h = 6 \implies n = 32 - 6 = 26 (/26/26).

      • Starting address must align on a multiple of 6464: 14.24.74.128 satisfies this condition.

      • Subnet ID: 14.24.74.128/26.

      • Subnet Mask: 255.255.255.192.

      • Usable Range: 14.24.74.129 through 14.24.74.190 (62 usable hosts62\,\text{usable hosts}).

      • Broadcast Address: 14.24.74.191.

    • Subnet C Allocation (10 hosts):

      • Address demand: 10+2=12 addresses10 + 2 = 12\,\text{addresses}.

      • Smallest power of 2: 24=162^4 = 16.

      • Host bits required: h=4  ⟹  n=32−4=28h = 4 \implies n = 32 - 4 = 28 (/28/28).

      • Starting address must align on a multiple of 1616: 14.24.74.192 satisfies this condition (192=12×16192 = 12 \times 16).

      • Subnet ID: 14.24.74.192/28.

      • Subnet Mask: 255.255.255.240.

      • Usable Range: 14.24.74.193 through 14.24.74.206 (14 usable hosts14\,\text{usable hosts}).

      • Broadcast Address: 14.24.74.207.

    • Unallocated Reserve Pool:

      • Spans 14.24.74.208 through 14.24.74.255 (48 unallocated addresses48\,\text{unallocated addresses} available for future growth).

Supernetting and Route Aggregation

  • Motivation and Principles:

    • By 1994, routing tables in core Internet routers faced exponential growth, exceeding 70,000 routes70,000\,\text{routes}.

    • Supernetting (CIDR route aggregation) combines multiple contiguous, equal-sized classless or Class C blocks into a single routing advertisement with a shorter prefix length.

    • Permits hierarchical routing: an upstream ISP advertises a single aggregated prefix to the global Internet backbone, routing traffic internally to specific customer sub-blocks.

  • Mandatory Mathematical Rules for Valid CIDR Aggregation:

    • Power-of-Two Count: The number of individual blocks to aggregate must strictly equal 2k2^k, where kk is an integer (2,4,8,16,…2, 4, 8, 16, \dots).

    • Contiguity: The address blocks must be strictly contiguous without omissions.

    • Equal Capacity: Every block being combined must possess the exact same prefix length and address size.

    • Boundary Alignment: The base IP address of the first block in the set must align mathematically on an integer multiple of the combined supernet capacity.

  • Supernetting Derivations:

    • Aggregating Four Contiguous /24 Blocks:

      • Given blocks: 200.1.0.0/24, 200.1.1.0/24, 200.1.2.0/24, 200.1.3.0/24.

      • Number of blocks: 4=22  ⟹  k=24 = 2^2 \implies k = 2.

      • New prefix length: 24−2=/2224 - 2 = /22.

      • Total addresses: 4×256=1024 addresses4 \times 256 = 1024\,\text{addresses}.

      • Binary examination of third octets:             0=0000000020 = 00000000_2             1=0000000121 = 00000001_2             2=0000001022 = 00000010_2             3=0000001123 = 00000011_2

      • The first 6 bits of the third octet are identical (000000). Adding these 6 bits to the 16 bits of the first two octets yields a 22-bit common prefix.

      • Resulting Supernet: 200.1.0.0/22.

    • Why Three Blocks Cannot Form a Supernet:

      • Given blocks: 205.16.37.0/24, 205.16.38.0/24, 205.16.39.0/24.

      • Evaluation: Three blocks cannot be aggregated into a single prefix because 33 is not a power of 22.

      • Correction: Add 205.16.36.0/24 to yield four contiguous blocks starting at third octet 3636. Since 36=9×436 = 9 \times 4, it satisfies alignment on a multiple of 44.

      • Binary evaluation of octets 36 to 3936\text{ to }39:             36=00100100236 = 00100100_2             39=00100111239 = 00100111_2

      • Common leading bits in third octet = 001001 (6 bits6\,\text{bits}). Aggregated prefix: 16+6=/2216 + 6 = /22.

      • Resulting Supernet: 205.16.36.0/22 (1024 addresses1024\,\text{addresses}).

IPv6 Addressing and Architecture

  • Motivation for IPv6 Deployment:

    • Complete exhaustion of the 32-bit IPv4 address pool (official IANA exhaustion occurred in 2011).

    • Eliminates complex NAT workarounds, restoring end-to-end network communication models.

    • Streamlines router processing by redesigning the base packet header.

  • Key Architectural Characteristics of IPv6:

    • Address Length: Exactly 128 bits128\,\text{bits} (16 bytes16\,\text{bytes}, 4 times4\,\text{times} the length of IPv4).

    • Total Address Space: 2128≈3.4028×1038 addresses2^{128} \approx 3.4028 \times 10^{38}\,\text{addresses}.

    • Notation: Eight groups of four hexadecimal digits (hextets) separated by colons: 2001:0db8:0000:0000:0000:0000:0000:0001.

    • Compression Rules:

      • Leading zeros within any 16-bit hextet can be dropped (:0db8: becomes :db8:).

      • A contiguous sequence of multiple all-zero hextets can be replaced with a single double-colon (::).

      • The :: symbol can appear only once per IPv6 address to prevent mathematical ambiguity during decompression.

      • Compressed Example: 2001:0db8:0000:0000:0000:0000:0000:0001 becomes 2001:db8::1.

    • Structural Header Enhancements:

      • Fixed Base Header Size: Standardized at exactly 40 bytes40\,\text{bytes}. Variable-length options are removed from the base header and implemented via chained Next Header extension headers.

      • No Header Checksum: Checksum verification is omitted at the IPv6 layer to eliminate recalculation overhead at each router hop; integrity verification is handled by Layer 2 and Layer 4.

      • Router Fragmentation Eliminated: Routers do not fragment IPv6 packets. If a packet exceeds the link MTU, it is dropped, and an ICMPv6 Packet Too Big message is returned. Path MTU Discovery (PMTUD) must be performed by the source host.

  • Special IPv6 Addresses:

    • ::1/128: Loopback address (equivalent to IPv4 127.0.0.1).

    • fe80::/10: Link-local unicast address range (used strictly within a single local link segment).

    • ff00::/8: Multicast address prefix (IPv6 replaces broadcast with multicast).

  • Systematic Comparison of IPv4 and IPv6:

    • Address Size: IPv4 uses 32 bits32\,\text{bits}; IPv6 uses 128 bits128\,\text{bits}.

    • Base Header Size: IPv4 uses variable 20–60 bytes20\text{--}60\,\text{bytes}; IPv6 uses fixed 40 bytes40\,\text{bytes}.

    • Fragmentation Responsibility: IPv4 fragments at intermediate routers and source; IPv6 fragments at source host only.

    • Header Checksum: Present in IPv4 (recomputed at every hop); completely eliminated in IPv6.

    • NAT Dependency: Necessary in IPv4; unnecessary in IPv6.

    • Notation: IPv4 uses dotted-decimal; IPv6 uses colon-hexadecimal.

IPv4 Datagram Header Architecture

  • Header Layout and Bit Specifications:

    • Base header consists of five mandatory 32-bit words (20 bytes20\,\text{bytes}).

    • With optional IP fields, total header size can expand up to 60 bytes60\,\text{bytes}.

  • Field-by-Field Breakdown:

    • Version (4 bits): Identifies the IP protocol version. Holds the binary value 0100 (44) for IPv4 or 0110 (66) for IPv6.

    • Header Length / HLEN (4 bits): Specifies the total header length in 32-bit (4-byte) words. Minimum value is 55 (5×4=20 bytes5 \times 4 = 20\,\text{bytes}); maximum value is 1515 (15×4=60 bytes15 \times 4 = 60\,\text{bytes}).

    • Service Type / DSCP & ECN (8 bits): Defines packet handling priority, quality of service (DiffServ Code Point), and Explicit Congestion Notification.

    • Total Length (16 bits): Defines the entire datagram size (header plus encapsulated data) measured in bytes. Maximum theoretical length is 216−1=65,535 bytes2^{16} - 1 = 65,535\,\text{bytes}.

    • Identification (16 bits): An integer identifier assigned by the sending host to uniquely identify a datagram. All fragments derived from the same parent datagram retain the identical Identification number.

    • Flags (3 bits):

      • Bit 0: Reserved; must be set to 0.

      • Bit 1 (DF - Don't Fragment): If set to 1, intermediate routers are forbidden from fragmenting the datagram. If the datagram exceeds a link MTU, it is dropped and an ICMP error is emitted.

      • Bit 2 (MF - More Fragments): Set to 1 on all fragments except the final fragment, where it is set to 0. On unfragmented datagrams, it is set to 0.

    • Fragment Offset (13 bits): Indicates the relative position of the fragment's payload data in the original unfragmented datagram, measured in units of 8-byte blocks.

    • Time To Live / TTL (8 bits): Decremented by at least 11 at each intermediate router hop. When TTL reaches 00, the datagram is discarded and an ICMP Time Exceeded message is returned to the source, preventing persistent routing loops.

    • Protocol (8 bits): Specifies the encapsulated transport-layer or network-support protocol:

      • 1=ICMP1 = \text{ICMP}

      • 2=IGMP2 = \text{IGMP}

      • 6=TCP6 = \text{TCP}

      • 17=UDP17 = \text{UDP}

      • 89=OSPF89 = \text{OSPF}

    • Header Checksum (16 bits): One's complement sum of all 16-bit half-words in the IP header. Must be recomputed at every router hop due to TTL decrementing.

    • Source IP Address (32 bits): Global IPv4 address of the originating interface.

    • Destination IP Address (32 bits): Global IPv4 address of the intended receiving interface.

    • Options and Padding (0 to 40 bytes): Optional configuration fields; padded with trailing zeros to guarantee alignment on a 32-bit boundary.

  • IP Options Details:

    • Record Route: Routers append their outgoing interface IP addresses into the options payload. Limited to a maximum of 9 router addresses (40 bytes total options space−3 bytes control overhead=37 bytes  ⟹  ⌊37/4⌋=9 addresses40\,\text{bytes total options space} - 3\,\text{bytes control overhead} = 37\,\text{bytes} \implies \lfloor 37 / 4 \rfloor = 9\,\text{addresses}).

    • Strict Source Routing: The sending host explicitly specifies the exact sequence of intermediate router IPs that the packet must traverse. If a router cannot reach the next hop directly, the datagram is dropped.

    • Loose Source Routing: The sending host defines a list of mandatory routers to visit, but the packet may traverse other intermediate routers between them.

    • Timestamp: Routers record their current local timestamp alongside their IP address.

  • Calculating Data Payload Size from Header Fields:     Header Size in Bytes=HLEN×4\text{Header Size in Bytes} = \text{HLEN} \times 4     Data Payload Size in Bytes=Total Length−(HLEN×4)\text{Data Payload Size in Bytes} = \text{Total Length} - (\text{HLEN} \times 4)

IPv4 Fragmentation and Reassembly Mechanics

  • The MTU Mismatch Problem:

    • Different physical and data-link technologies enforce different Maximum Transmission Units (MTU)—the largest payload size allowed in a single Layer 2 frame (e.g., Standard Ethernet = 1500 bytes1500\,\text{bytes}, PPPoE = 1492 bytes1492\,\text{bytes}, legacy WAN = 576 bytes576\,\text{bytes}).

    • When a router receives a datagram whose total size exceeds the MTU of the outgoing link, it must split the packet into fragments, unless the DF bit is asserted.

    • Destination-Only Reassembly: In IPv4, routers fragment datagrams, but only the final destination host reassembles them. This occurs because independent datagram fragments may take disparate paths through the network and may never meet at the same intermediate router.

  • Mathematical Necessity for the 8-Byte Offset Scale:

    • The Fragment Offset field is only 13 bits13\,\text{bits} wide, representing values from 0 to 81910\text{ to }8191.

    • If offsets were measured in single bytes, the maximum addressable position would be 8191 bytes8191\,\text{bytes}, rendering the field unable to handle IPv4 datagrams up to 65,535 bytes65,535\,\text{bytes}.

    • By scaling offsets in units of 8 bytes8\,\text{bytes}, the maximum addressable data position becomes 8191×8=65,528 bytes8191 \times 8 = 65,528\,\text{bytes}.

    • Consequence: The data payload of every intermediate fragment (all except the last) must strictly be an integer multiple of 8 bytes8\,\text{bytes}.

  • Router Decision Logic:

    • Condition 1: Total Size ≤\le MTU: Forward directly without fragmentation.

    • Condition 2: Total Size >> MTU and DF = 1: Discard datagram; emit ICMP Destination Unreachable (Type 3, Code 4: Fragmentation Needed and DF Set) to sender.

    • Condition 3: Total Size >> MTU and DF = 0: Fragment datagram and forward all pieces.

  • Fragment Identification Matrix (MF and Offset):

    • MF=1,Offset=0\text{MF} = 1, \text{Offset} = 0: First fragment of a fragmented datagram.

    • MF=1,Offset>0\text{MF} = 1, \text{Offset} > 0: Middle fragment of a fragmented datagram.

    • MF=0,Offset>0\text{MF} = 0, \text{Offset} > 0: Final fragment of a fragmented datagram.

    • MF=0,Offset=0\text{MF} = 0, \text{Offset} = 0: Completely unfragmented original datagram.

  • Fragmentation Equations and Efficiency:

    • Let D=Original Data PayloadD = \text{Original Data Payload}, H=IP Header SizeH = \text{IP Header Size}, M=Outgoing Link MTUM = \text{Outgoing Link MTU}.

    • Maximum allowable data per fragment (must be divisible by 8):         Dfrag=⌊M−H8⌋×8D_{\text{frag}} = \left\lfloor \frac{M - H}{8} \right\rfloor \times 8

    • Number of fragments generated:         n=⌈DDfrag⌉n = \left\lceil \frac{D}{D_{\text{frag}}} \right\rceil

    • Fragment Offset for fragment ii (where i=0,1,…,n−1i = 0, 1, \dots, n - 1):         Offseti=i×Dfrag8\text{Offset}_i = \frac{i \times D_{\text{frag}}}{8}

    • Total Header Overhead Introduced:         Overhead=(n−1)×H\text{Overhead} = (n - 1) \times H

    • Transmission Efficiency on Wire:         Efficiency=DD+(n×H)\text{Efficiency} = \frac{D}{D + (n \times H)}

  • Comprehensive Fragmentation Walkthrough:

    • Input: Original datagram = 4000 bytes4000\,\text{bytes} total (20 byte20\,\text{byte} header, 3980 bytes3980\,\text{bytes} payload), Identification = 14567, MTU=1500 bytes\text{MTU} = 1500\,\text{bytes}.

    • Step 1: Compute maximum payload: 1500−20=1480 bytes1500 - 20 = 1480\,\text{bytes}. Since 1480/8=1851480 / 8 = 185 (integer), Dfrag=1480D_{\text{frag}} = 1480.

    • Step 2: Fragment count: n=⌈3980/1480⌉=⌈2.689⌉=3 fragmentsn = \lceil 3980 / 1480 \rceil = \lceil 2.689 \rceil = 3\,\text{fragments}.

    • Fragment 1: Data = 1480 bytes1480\,\text{bytes} (Bytes 0 to 1479); Total Size = 1500 bytes1500\,\text{bytes}; Offset = 0/8=00 / 8 = 0; MF = 1; ID = 14567.

    • Fragment 2: Data = 1480 bytes1480\,\text{bytes} (Bytes 1480 to 2959); Total Size = 1500 bytes1500\,\text{bytes}; Offset = 1480/8=1851480 / 8 = 185; MF = 1; ID = 14567.

    • Fragment 3: Data = 3980−(2×1480)=1020 bytes3980 - (2 \times 1480) = 1020\,\text{bytes} (Bytes 2960 to 3979); Total Size = 1040 bytes1040\,\text{bytes}; Offset = 2960/8=3702960 / 8 = 370; MF = 0; ID = 14567.

Internet Control Message Protocol (ICMPv4)

  • Role and Encapsulation:

    • Provides network-layer diagnostic, flow-control, and error-reporting facilities to compensate for IPv4's best-effort delivery model.

    • ICMP messages do not rectify errors; they report anomalous network conditions back to the originating source IP address.

    • Encapsulated directly within IPv4 datagrams with the Protocol field set to 11. It does not operate at Layer 4 and does not utilize TCP or UDP.

  • Standard 8-Byte Message Header:

    • Type (8 bits): Defines the high-level category of the ICMP message.

    • Code (8 bits): Sub-classifies the condition, identifying the precise error cause.

    • Checksum (16 bits): Algorithmic one's complement checksum covering the entire ICMP message (header and payload).

    • Rest of Header (32 bits): Contents vary based on Type and Code. Contains Identifier and Sequence Number for Echo messages; unused (all zeros) for error messages.

    • Data Payload Section: For error messages, includes the original IPv4 header plus the first 8 bytes of the datagram's original payload (which reveals the transport-layer TCP/UDP source and destination port numbers).

  • Taxonomy of Common ICMP Messages:

    • Error-Reporting Messages:

      • Type 3: Destination Unreachable:

        • Code 0: Network Unreachable.

        • Code 1: Host Unreachable.

        • Code 2: Protocol Unreachable (destination transport protocol inactive).

        • Code 3: Port Unreachable (destination port closed).

        • Code 4: Fragmentation Needed and DF Set.

      • Type 4: Source Quench: Flow control mechanism requesting sender to throttle transmission rate (now deprecated).

      • Type 5: Redirect: Informs a host to direct traffic to an alternate gateway on the local link.

      • Type 11: Time Exceeded:

        • Code 0: Time-to-Live (TTL) decremented to 0 in transit.

        • Code 1: Fragment reassembly timer expired at destination.

      • Type 12: Parameter Problem: Incorrect or corrupted header field.

    • Query / Informational Messages:

      • Type 8: Echo Request (used by ping).

      • Type 0: Echo Reply (response to ping).

      • Type 13 / 14: Timestamp Request and Timestamp Reply.

  • Mechanics of Network Diagnostic Tools:

    • Ping Utility: Emits ICMP Type 8 (Echo Request) packets to a target IP and listens for ICMP Type 0 (Echo Reply) packets, computing round-trip latency and packet loss metrics.

    • Traceroute Mechanism:

      1. Sends a datagram with TTL=1\text{TTL} = 1. The first hop router decrements TTL to 00, drops the datagram, and returns an ICMP Type 11, Code 0 (Time Exceeded) message, exposing its IP address.

      2. Increments TTL to 2,3,4,…2, 3, 4, \dots, successively discovering each intermediate router IP along the path.

      3. Upon reaching the target destination, a packet directed to an invalid high-numbered UDP port produces an ICMP Type 3, Code 3 (Port Unreachable) reply, terminating the trace.

Network Address Translation (NAT) and Port Address Translation (PAT)

  • Operational Context:

    • Developed under RFC 1631/3022 to mitigate global IPv4 address exhaustion.

    • Allows an entire internal organizational network utilizing RFC 1918 private addressing to interface with the global Internet using one or a small pool of globally routable public IP addresses.

  • Translation Mechanisms:

    • Basic NAT (1-to-1): Maps a single private IP address to a single public IP address. Does not conserve address capacity.

    • Port Address Translation (PAT / NAT Overload / Many-to-1): Maps multiple private IP addresses to a single public IP address by assigning unique Layer 4 source port numbers to each outbound communication session.

    • Theoretical Capacity: Can support up to 65,53565,535 concurrent communication flows per public IP address based on the 16-bit port address field.

  • Translation Mechanics:

    • Outbound Flow (LAN to WAN):

      • Host on LAN (10.0.0.1:1024) transmits a packet to an external server (198.51.100.10:80).

      • The NAT border router intercepts the datagram, modifies the Source IP from 10.0.0.1 to its public IP 203.0.113.5, and allocates an ephemeral Source Port (e.g., 5000).

      • The router logs this state in its internal NAT translation table: 203.0.113.5:5000 <-> 10.0.0.1:1024.

    • Inbound Flow (WAN to LAN):

      • The external server replies to 203.0.113.5:5000.

      • The NAT router inspects destination port 5000, checks its table, replaces the destination IP and port with 10.0.0.1:1024, and forwards the packet onto the local segment.

  • Architectural Limitations:

    • Violates the end-to-end connectivity principle of the original Internet architecture.

    • Breaks incoming peer-to-peer applications, VoIP (SIP), and multi-port protocols such as FTP unless application-level gateways (ALGs) or STUN/TURN techniques are deployed.

    • NAT routers maintain connection state; an unexpected router reboot drops all active sessions across the network boundary.

Address Resolution Protocols: ARP, RARP, and DHCP

  • The Layer-2 / Layer-3 Addressing Dilemma:

    • Network-layer protocols address packets using logical 32-bit IP addresses.

    • Data-link layer hardware (e.g., Ethernet adapters) deliver frames across physical media using 48-bit MAC addresses burned into network interface cards.

    • A host preparing an IP datagram for local delivery cannot transmit the frame without mapping the target IP address to its corresponding physical MAC address.

  • Address Resolution Protocol (ARP):

    • Function: Dynamically resolves a known Layer 3 IPv4 address to an unknown Layer 2 MAC address on the local link.

    • Scope: Operates strictly within the boundaries of a single local broadcast domain (subnet). ARP packets do not traverse routers.

    • Operation: Broadcast Request (Target MAC = FF:FF:FF:FF:FF:FF) asking "Who owns IP X?", followed by a Unicast Reply from the owner providing its physical MAC.

    • Caching: Resolved entries are saved in an internal ARP cache for approximately 20 minutes20\,\text{minutes} to prevent broadcast flooding on subsequent transmissions.

    • Ethernet Framing: ARP packets carry an Ethernet Type field of 0x0806 (differentiating them from IPv4 datagrams, which carry 0x0800).

    • ARP Packet Fields (28 bytes total):

      • Hardware Type (16 bits16\,\text{bits}): 1 for Ethernet.

      • Protocol Type (16 bits16\,\text{bits}): 0x0800 for IPv4.

      • Hardware Length (8 bits8\,\text{bits}): 6 (bytes in a MAC).

      • Protocol Length (8 bits8\,\text{bits}): 4 (bytes in an IPv4 address).

      • Operation Code (16 bits16\,\text{bits}): 1 for ARP Request, 2 for ARP Reply.

      • Sender Hardware Address (48 bits48\,\text{bits}): MAC of sender.

      • Sender Protocol Address (32 bits32\,\text{bits}): IP of sender.

      • Target Hardware Address (48 bits48\,\text{bits}): All zeros in Request; filled with recipient MAC in Reply.

      • Target Protocol Address (32 bits32\,\text{bits}): IP of host being queried.

  • Same-Subnet vs. Cross-Subnet ARP Operations:

    • Case 1: Destination on Same Subnet:

      • Host A checks destination IP against its local mask; confirms destination is local.

      • Host A broadcasts ARP Request directly for the destination host's IP.

      • Destination host replies directly with its MAC.

    • Case 2: Destination on Remote Subnet:

      • Host A performs bitwise AND; determines destination is outside the local subnet.

      • Host A cannot query the remote host directly because routers drop Layer 2 broadcasts.

      • Host A issues an ARP Request targeting its configured Default Gateway IP.

      • The default gateway replies with its local MAC address.

      • Host A frames the packet using the Gateway's MAC as the destination hardware address, while the destination IP remains set to the remote host's IP throughout the transmission.

  • Reverse Address Resolution Protocol (RARP):

    • Function: Resolves a known MAC address to an unknown IP address (the inverse of ARP).

    • Historical Context: Designed under RFC 903 for diskless workstations booting from ROM that lacked persistent secondary storage to store their assigned IP address.

    • Packet Type: Identical 28-byte layout as ARP, carrying Ethernet Type 0x8035 and Operation Codes: 3 (RARP Request) and 4 (RARP Reply).

    • Limitations and Obsolescence: RARP operates via link-layer broadcasts and cannot cross routers, requiring a dedicated RARP server on every subnet. It returns only an IP address, omitting the subnet mask, default gateway, and DNS servers. Superseded by BOOTP and DHCP.

  • Dynamic Host Configuration Protocol (DHCP):

    • Function: Client-server protocol providing automated distribution of complete IP configuration parameters: client IP address, subnet mask, default gateway, DNS server IPs, and lease duration.

    • Transport Details: Encapsulated in UDP datagrams. Client transmits from UDP Port 6868; Server listens on UDP Port 6767.

    • Relay Capability: Operates across subnets through DHCP Relay Agents running on routers (tracking the agent IP in the giaddr field).

    • The 4-Step DORA Handshake:

      1. DHCP DISCOVER: Client broadcasts (Source IP = 0.0.0.0, Dest IP = 255.255.255.255) to locate reachable DHCP servers.

      2. DHCP OFFER: DHCP server reserves an unassigned IP from its pool and sends an offer specifying lease duration and network parameters.

      3. DHCP REQUEST: Client broadcasts its selection of the offered IP. The broadcast notifies other DHCP servers whose offers were declined so they can return their tentative leases to the pool.

      4. DHCP ACK: Server confirms the binding, officially starting the lease timer; the client configures its network interface.

Fundamental Routing Algorithms

  • Routing Classifications:

    • Routing algorithms compute the least-cost path across a weighted graph where vertices represent routers and edges represent physical communication links.

    • Link weights represent operational metrics such as physical distance, hop count, transmission delay, financial cost, or available bandwidth.

  • Distance-Vector (DV) Routing:

    • Operational Model: Distributed, iterative, asynchronous algorithm based on the Bellman-Ford shortest-path formulation.

    • Knowledge Distribution: Each router maintains a vector containing its best-known distance estimates to every destination network. Routers exchange their distance vectors only with directly connected immediate neighbors.

    • The Bellman-Ford Equation:         Dx[y]=min⁡w∈neighbors(x){c[x][w]+Dw[y]}D_x[y] = \min_{w \in \text{neighbors}(x)} \{ c[x][w] + D_w[y] \}         Where Dx[y]D_x[y] is the estimated cost from node xx to destination yy, c[x][w]c[x][w] is the cost of the direct link from xx to neighbor ww, and Dw[y]D_w[y] is neighbor ww's reported shortest distance to yy.

    • Algorithmic Execution:

      1. Initialize: Dx[x]=0D_x[x] = 0; for direct neighbors yy, set Dx[y]=c[x][y]D_x[y] = c[x][y]; for non-neighbors, set Dx[y]=∞D_x[y] = \infty.

      2. Transmit local vector to all neighbors.

      3. Upon receiving an update from neighbor ww, re-evaluate Bellman-Ford. If an entry changes, transmit the updated vector to all neighbors.

      4. Iterate until the system reaches convergence (no further updates generated).

  • The Count-to-Infinity Problem:

    • Mechanism: Good news (cost reductions) propagates rapidly across DV networks, but bad news (link failures or cost increases) propagates slowly.

    • Failure Scenario: Consider a topology A --(1)-- B --(1)-- X. Initially, DB[X]=1D_B[X] = 1 and DA[X]=2D_A[X] = 2 (via BB).

    • If link B–XB\text{--}X breaks, BB sets its local cost to XX to ∞\infty.

    • Before BB can broadcast this failure, AA sends its periodic update stating DA[X]=2D_A[X] = 2.

    • BB receives this and computes: "I can reach XX via AA at cost c[B][A]+DA[X]=1+2=3c[B][A] + D_A[X] = 1 + 2 = 3". BB updates its table to 33 and advertises it.

    • AA receives BB's update, recomputes DA[X]=1+3=4D_A[X] = 1 + 3 = 4, and advertises it back to BB.

    • Nodes AA and BB loop, incrementing costs indefinitely ("counting to infinity") while packets bounce between them until their TTL expires.

    • Remedies:

      • Split Horizon: A router never advertises a route back out the same interface it learned it from.

      • Poison Reverse: A router advertises a route back out the interface it learned it from, but explicitly sets the metric to ∞\infty (e.g., metric = 1616 in RIP), actively breaking two-node loops.

      • Hop Limit Ceiling: Defining an absolute low value as infinity (e.g., RIP sets ∞=16\infty = 16) bounds the maximum number of loop iterations.

      • Hold-Down Timers: Routers ignore updates advertising alternate paths to a recently failed destination for a fixed period to allow updates to settle.

  • Link-State (LS) Routing:

    • Operational Model: Global routing algorithm based on Dijkstra's Shortest Path First (SPF) algorithm.

    • Knowledge Distribution: Every router discovers its immediate neighbors and link costs, packs this local data into a Link-State Packet (LSP), and floods the LSP to every router in the network.

    • Link-State Database (LSDB): Through flooding, every router constructs an identical graph representation of the entire network topology.

    • Dijkstra's Algorithm Execution:

      • Notation: N=set of all nodesN = \text{set of all nodes}, T=set of settled nodes in shortest path treeT = \text{set of settled nodes in shortest path tree}, D[v]=current cost from root to vD[v] = \text{current cost from root to } v.

      1. Initialize: T={root}T = \{\text{root}\}, D[root]=0D[\text{root}] = 0. For all direct neighbors vv, D[v]=c[root][v]D[v] = c[\text{root}][v]; for non-neighbors, D[v]=∞D[v] = \infty.

      2. Find node w∉Tw \notin T with the minimum cost D[w]D[w]. Add ww to TT.

  1. Update distances for all neighbors v∉Tv \notin T of node ww:             D[v]=min⁡{D[v],D[w]+c[w][v]}D[v] = \min \{ D[v], D[w] + c[w][v] \} 4. Repeat Steps 2 and 3 until all nodes are placed in set TT.

  • Path-Vector Routing:

    • Operational Model: Used for inter-domain routing between distinct administrative entities (Autonomous Systems).

    • Mechanism: Instead of exchanging link costs or hop counts, routers exchange reachability announcements that include the complete ordered sequence of Autonomous System Numbers (ASNs) traversed along the path (the AS-PATH attribute).

    • Loop Detection: If a router receives an update containing its own ASN anywhere within the AS-PATH attribute, it immediately discards the route, providing loop-free inter-domain routing.

    • Policy Enforcement: Permits organizations to apply non-technical administrative, commercial, and political routing policies (e.g., refusing to transit traffic through a competitor's network).

Routing Protocols: RIP, OSPF, and BGP

  • Internet Routing Structure and Autonomous Systems (AS):

    • The global Internet is partitioned into thousands of Autonomous Systems—networks controlled by a single administrative domain sharing a uniform routing strategy.

    • Interior Gateway Protocols (IGP): Handle routing within a single Autonomous System (e.g., RIP, OSPF).

    • Exterior Gateway Protocols (EGP): Handle routing between separate Autonomous Systems (e.g., BGP).

  • Routing Information Protocol (RIP):

    • Type: Distance-Vector IGP.

    • Metric: Hop count exclusively (every link has a static cost of 11).

    • Maximum Diameter: Hop count ranges from 1 to 151\text{ to }15. A metric of 1616 represents infinity (unreachable).

    • Update Cycle: Periodically transmits its complete routing table to all direct neighbors every 30 seconds30\,\text{seconds}.

    • Transport: Encapsulated in UDP datagrams on Port 520520.

    • Protocol Versions: RIPv1 (classful, broadcasts updates to 255.255.255.255, no subnet mask support); RIPv2 (classless, supports CIDR/VLSM, multicasts to 224.0.0.9, includes authentication); RIPng (adapted for IPv6).

  • Open Shortest Path First (OSPF):

    • Type: Link-State IGP.

    • Metric: Configurable cost metric inversely proportional to interface bandwidth:         Cost=Reference BandwidthInterface Bandwidth\text{Cost} = \frac{\text{Reference Bandwidth}}{\text{Interface Bandwidth}}

    • Transport: Encapsulated directly within IPv4 datagrams with Protocol field set to 8989. It bypasses TCP and UDP.

    • Convergence and Stability: Converges rapidly upon topological changes using triggered Link State Advertisements (LSAs); inherently immune to routing loops.

    • Equal-Cost Multi-Path (ECMP): Automatically load-balances traffic across multiple paths sharing identical lowest costs.

    • OSPF Packet Types: Type 1: Hello; Type 2: Database Description (DBD); Type 3: Link-State Request (LSR); Type 4: Link-State Update (LSU); Type 5: Link-State Acknowledgment (LSAck).

    • Two-Level Area Hierarchy:

      • Area 0 (Backbone Area): The central core to which all secondary areas must physically or virtually connect. Inter-area traffic must transit the backbone.

      • Area Border Router (ABR): A router connected simultaneously to Area 0 and one or more peripheral areas. Summarizes internal area topology before advertising it into the backbone.

      • Autonomous System Boundary Router (ASBR): A router interfacing OSPF with external routing domains (e.g., importing BGP routes).

      • Internal Router: A router whose interfaces reside entirely within a single area.

    • Designated Router (DR) and Backup Designated Router (BDR):

      • On broadcast multi-access segments (e.g., shared Ethernet switches), nn OSPF routers would establish n(n−1)2\frac{n(n - 1)}{2} adjacencies, creating high control-traffic overhead.

      • OSPF elects a single DR and one BDR; all other routers (DROthers) form adjacencies solely with the DR and BDR.

      • Election Criteria: Highest interface priority (0 to 2550\text{ to }255; priority 00 makes a router ineligible). Ties are broken by the highest 32-bit Router ID (RID).

      • Multicast Addresses: DR/BDR listen on 224.0.0.6; all OSPF routers listen on 224.0.0.5.

  • Border Gateway Protocol (BGP / BGP-4):

    • Type: Path-Vector EGP.

    • Role: The sole inter-domain routing protocol providing connectivity across the global Internet backbone.

    • Transport: Operates over reliable, connection-oriented TCP on Port 179179.

    • Protocol Flavors: eBGP (External BGP: peering sessions between distinct ASNs); iBGP (Internal BGP: synchronization among BGP routers inside the same ASN).

    • BGP Message Types: OPEN (session initialization), UPDATE (announcing new routes or withdrawing obsolete prefixes), KEEPALIVE (link heartbeat), NOTIFICATION (error reporting and immediate connection closure).

    • Convergence Policy: Intentionally dampens convergence using Minimum Route Advertisement Interval (MRAI) timers to prevent global routing storms caused by flapping links.

  • Systematic Comparative Matrix of Routing Protocols:

    • Routing Domain: RIP is Intradomain (IGP); OSPF is Intradomain (IGP); BGP is Interdomain (EGP).

    • Underlying Algorithm: RIP uses Distance-Vector (Bellman-Ford); OSPF uses Link-State (Dijkstra); BGP uses Path-Vector.

    • Metric: RIP uses hop count (max⁡=15\max = 15); OSPF uses bandwidth-based link cost; BGP uses multi-attribute policy evaluation and AS-PATH length.

    • Transport Protocol: RIP uses UDP Port 520520; OSPF uses IP Protocol 8989; BGP uses TCP Port 179179.

    • Convergence Speed: RIP is slow; OSPF is fast; BGP is deliberately slow for stability.

    • Scalability Limit: RIP is limited to small networks (≤15 hops\le 15\,\text{hops}); OSPF supports large multi-area enterprise networks; BGP scales to the global Internet (>900,000 routes> 900,000\,\text{routes}).

    • Loop Prevention Mechanism: RIP relies on Split Horizon and Poison Reverse; OSPF uses a global topology map and SPF calculation; BGP uses AS-PATH inspection.

Comprehensive Solved Numericals and Algorithmic Walkthroughs

  • Numerical 1: Subnetting a Class C Network (200.1.2.0/24 into 4 Subnets):

    • Problem: An organization receives 200.1.2.0/24 and must create four equal subnets.

    • Derivation:

      • Subnets needed: 2ns≥4  ⟹  ns=2 bits2^{n_s} \ge 4 \implies n_s = 2\,\text{bits}.

      • New prefix: 24+2=/2624 + 2 = /26.

      • Subnet Mask: 255.255.255.192.

      • Host bits remaining: 8−2=68 - 2 = 6.

      • Usable hosts per subnet: 26−2=62 hosts2^6 - 2 = 62\,\text{hosts}.

      • Block increment (stride): 26=642^6 = 64.

    • Subnet Allocations:

      • Subnet 1: Network ID = 200.1.2.0/26; First Host = 200.1.2.1; Last Host = 200.1.2.62; Broadcast = 200.1.2.63.

      • Subnet 2: Network ID = 200.1.2.64/26; First Host = 200.1.2.65; Last Host = 200.1.2.126; Broadcast = 200.1.2.127.

      • Subnet 3: Network ID = 200.1.2.128/26; First Host = 200.1.2.129; Last Host = 200.1.2.190; Broadcast = 200.1.2.191.

      • Subnet 4: Network ID = 200.1.2.192/26; First Host = 200.1.2.193; Last Host = 200.1.2.254; Broadcast = 200.1.2.255.

  • Numerical 1b: Subnetting a Class B Network (172.16.0.0/16 into 64 Subnets):

    • Problem: Partition 172.16.0.0/16 into exactly 64 equal sub-networks.

    • Derivation:

      • Bits borrowed: 2ns=64  ⟹  ns=6 bits2^{n_s} = 64 \implies n_s = 6\,\text{bits}.

      • New prefix: 16+6=/2216 + 6 = /22.

      • Binary mask (third octet): 111111002=25211111100_2 = 252.

      • Dotted-decimal mask: 255.255.252.0.

      • Remaining host bits: 16−6=10 bits16 - 6 = 10\,\text{bits}.

      • Total addresses per subnet: 210=10242^{10} = 1024.

      • Usable hosts per subnet: 1024−2=1022 hosts1024 - 2 = 1022\,\text{hosts}.

      • Third-octet stride: 1024/256=41024 / 256 = 4.

    • Subnet Enumeration:

      • Subnet 1: Network ID = 172.16.0.0/22; First Host = 172.16.0.1; Last Host = 172.16.3.254; Broadcast = 172.16.3.255.

      • Subnet 2: Network ID = 172.16.4.0/22; First Host = 172.16.4.1; Last Host = 172.16.7.254; Broadcast = 172.16.7.255.

      • Subnet 64: Network ID = 172.16.252.0/22; First Host = 172.16.252.1; Last Host = 172.16.255.254; Broadcast = 172.16.255.255.

  • Numerical 3: Host Mask Bitwise Decomposition:

    • Problem: Given host IP 220.15.1.10 with mask 255.255.255.240, find Subnet ID, Broadcast, and Host Range.

    • Derivation:

      • Mask 255.255.255.240 corresponds to /28/28 (32−28=4 host bits32 - 28 = 4\,\text{host bits}).

      • Fourth octet evaluation: 10=00001010210 = 00001010_2, 240=111100002240 = 11110000_2.

      • Subnet ID: 10 & 240=000000002=0  ⟹  10\,\&\,240 = 00000000_2 = 0 \implies 220.15.1.0/28.

      • Broadcast Address: 10 ∣ (∼240)=000010102 ∣ 000011112=000011112=15  ⟹  10\,|\,(\sim 240) = 00001010_2 \,|\, 00001111_2 = 00001111_2 = 15 \implies 220.15.1.15.

      • Valid Host Range: 220.15.1.1 through 220.15.1.14 (14 usable hosts14\,\text{usable hosts}).

  • Numerical 5: IP Packet Fragmentation Breakdown:

    • Problem: Datagram total size = 4000 bytes4000\,\text{bytes} (20 byte20\,\text{byte} header), Identification = 14567, MTU=1500 bytes\text{MTU} = 1500\,\text{bytes}.

    • Derivation:

      • Data payload: 4000−20=3980 bytes4000 - 20 = 3980\,\text{bytes}.

      • Max data per fragment: 1500−20=1480 bytes1500 - 20 = 1480\,\text{bytes} (divisible by 8).

      • Total fragments: ⌈3980/1480⌉=3\lceil 3980 / 1480 \rceil = 3.

      • Fragment 1: Data = 1480 bytes1480\,\text{bytes}; Total Size = 1500 bytes1500\,\text{bytes}; Offset = 0/8=00 / 8 = 0; MF = 1; ID = 14567.

      • Fragment 2: Data = 1480 bytes1480\,\text{bytes}; Total Size = 1500 bytes1500\,\text{bytes}; Offset = 1480/8=1851480 / 8 = 185; MF = 1; ID = 14567.

      • Fragment 3: Data = 3980−2960=1020 bytes3980 - 2960 = 1020\,\text{bytes}; Total Size = 1040 bytes1040\,\text{bytes}; Offset = 2960/8=3702960 / 8 = 370; MF = 0; ID = 14567.

  • Numerical 5b: Fragmentation Efficiency and Extra Header Overhead:

    • Problem: Host A transmits a datagram with 20 byte20\,\text{byte} header and 500 byte500\,\text{byte} payload over a link with MTU=200 bytes\text{MTU} = 200\,\text{bytes}.

    • Derivation:

      • Max payload per fragment: 200−20=180 bytes200 - 20 = 180\,\text{bytes}.

      • Nearest multiple of 8: ⌊180/8⌋×8=176 bytes\lfloor 180 / 8 \rfloor \times 8 = 176\,\text{bytes}.

      • Fragment count: n=⌈500/176⌉=3n = \lceil 500 / 176 \rceil = 3.

      • Fragment 1: Data = 176 bytes176\,\text{bytes}, Total = 196 bytes196\,\text{bytes}, Offset = 00, MF = 1.

      • Fragment 2: Data = 176 bytes176\,\text{bytes}, Total = 196 bytes196\,\text{bytes}, Offset = 176/8=22176 / 8 = 22, MF = 1.

      • Fragment 3: Data = 500−(2×176)=148 bytes500 - (2 \times 176) = 148\,\text{bytes}, Total = 168 bytes168\,\text{bytes}, Offset = 352/8=44352 / 8 = 44, MF = 0.

      • Total on-wire bytes transmitted: 196+196+168=560 bytes196 + 196 + 168 = 560\,\text{bytes}.

      • Extra Header Overhead: (3−1)×20=40 bytes(3 - 1) \times 20 = 40\,\text{bytes}.

      • Transmission Efficiency:             Efficiency=500560≈89.28%\text{Efficiency} = \frac{500}{560} \approx 89.28\%

  • Numerical 5c: Fragmentation with Non-Default Header Options (HLEN = 8):

    • Problem: Datagram total length = 1500 bytes1500\,\text{bytes}, HLEN=8\text{HLEN} = 8, payload = 1468 bytes1468\,\text{bytes}, crossing link with MTU=512 bytes\text{MTU} = 512\,\text{bytes}.

    • Derivation:

      • Header size: 8×4=32 bytes8 \times 4 = 32\,\text{bytes} (20 bytes base+12 bytes options20\,\text{bytes base} + 12\,\text{bytes options}).

      • Max payload capacity: 512−32=480 bytes512 - 32 = 480\,\text{bytes}.

      • Check divisibility: 480/8=60480 / 8 = 60 (valid integer multiple).

      • Fragment count: n=⌈1468/480⌉=⌈3.058⌉=4 fragmentsn = \lceil 1468 / 480 \rceil = \lceil 3.058 \rceil = 4\,\text{fragments}.

      • Fragment 1: Data = 480 bytes480\,\text{bytes}, Start Byte = 00, Offset = 00, MF = 1, Total Size = 512 bytes512\,\text{bytes}.

      • Fragment 2: Data = 480 bytes480\,\text{bytes}, Start Byte = 480480, Offset = 480/8=60480 / 8 = 60, MF = 1, Total Size = 512 bytes512\,\text{bytes}.

      • Fragment 3: Data = 480 bytes480\,\text{bytes}, Start Byte = 960960, Offset = 960/8=120960 / 8 = 120, MF = 1, Total Size = 512 bytes512\,\text{bytes}.

      • Fragment 4: Data = 1468−1440=28 bytes1468 - 1440 = 28\,\text{bytes}, Start Byte = 14401440, Offset = 1440/8=1801440 / 8 = 180, MF = 0, Total Size = 28+32=60 bytes28 + 32 = 60\,\text{bytes}.

      • Total on-wire bytes: 1468+(4×32)=1596 bytes1468 + (4 \times 32) = 1596\,\text{bytes}.

      • Efficiency: 14681596≈91.98%\frac{1468}{1596} \approx 91.98\%.

  • Numerical 6: Dijkstra Shortest Path Step-by-Step on 7-Node Graph:

    • Graph Undirected Edges: A–B=2, A–D=3, B–C=5, B–E=4, C–F=4, C–G=3, D–E=5, E–F=2, F–G=1.

    • Dijkstra Execution from Root A:

      • Init: Settled Set T={A}T = \{A\}; Distance Vector: A:0,B:2,C:∞,D:3,E:∞,F:∞,G:∞A:0, B:2, C:\infty, D:3, E:\infty, F:\infty, G:\infty.

      • Step 1: Min node is BB (D[B]=2D[B] = 2). Add BB to TT. Relax neighbors: D[C]=min⁡(∞,2+5)=7D[C] = \min(\infty, 2 + 5) = 7, D[E]=min⁡(∞,2+4)=6D[E] = \min(\infty, 2 + 4) = 6.

      • Step 2: Min node is DD (D[D]=3D[D] = 3). Add DD to TT. Relax neighbors: D[E]=min⁡(6,3+5)=6D[E] = \min(6, 3 + 5) = 6.

      • Step 3: Min node is EE (D[E]=6D[E] = 6). Add EE to TT. Relax neighbors: D[F]=min⁡(∞,6+2)=8D[F] = \min(\infty, 6 + 2) = 8.

      • Step 4: Min node is CC (D[C]=7D[C] = 7). Add CC to TT. Relax neighbors: D[F]=min⁡(8,7+4)=8D[F] = \min(8, 7 + 4) = 8, D[G]=min⁡(∞,7+3)=10D[G] = \min(\infty, 7 + 3) = 10.

      • Step 5: Min node is FF (D[F]=8D[F] = 8). Add FF to TT. Relax neighbors: D[G]=min⁡(10,8+1)=9D[G] = \min(10, 8 + 1) = 9.

      • Step 6: Min node is GG (D[G]=9D[G] = 9). Add GG to TT.

    • Final Shortest Paths and Forwarding Interface from A:

      • Destination B: Cost = 22; Path = A→BA \rightarrow B; Next Hop = BB.

      • Destination C: Cost = 77; Path = A→B→CA \rightarrow B \rightarrow C; Next Hop = BB.

      • Destination D: Cost = 33; Path = A→DA \rightarrow D; Next Hop = DD.

      • Destination E: Cost = 66; Path = A→B→EA \rightarrow B \rightarrow E; Next Hop = BB.

      • Destination F: Cost = 88; Path = A→B→E→FA \rightarrow B \rightarrow E \rightarrow F; Next Hop = BB.

      • Destination G: Cost = 99; Path = A→B→E→F→GA \rightarrow B \rightarrow E \rightarrow F \rightarrow G; Next Hop = BB.

  • Numerical 7: Distance-Vector (Bellman-Ford) Convergence Simulation:

    • Network Topology: Nodes A, B, C, D with direct links: A–B=2, A–C=7, B–C=1, B–D=4, C–D=3.

    • Round 0 (Initialization - Local Knowledge Only):

      • Vector A: [A:0,B:2,C:7,D:∞][A:0, B:2, C:7, D:\infty].

      • Vector B: [A:2,B:0,C:1,D:4][A:2, B:0, C:1, D:4].

      • Vector C: [A:7,B:1,C:0,D:3][A:7, B:1, C:0, D:3].

      • Vector D: [A:∞,B:4,C:3,D:0][A:\infty, B:4, C:3, D:0].

    • Round 1 (After Single Vector Exchange):

      • Node A computes:             DA[C]=min⁡(7,c[A][B]+DB[C])=min⁡(7,2+1)=3(via B)D_A[C] = \min(7, c[A][B] + D_B[C]) = \min(7, 2 + 1) = 3 \quad (\text{via } B)             DA[D]=min⁡(∞,c[A][B]+DB[D],c[A][C]+DC[D])=min⁡(∞,2+4,7+3)=6(via B)D_A[D] = \min(\infty, c[A][B] + D_B[D], c[A][C] + D_C[D]) = \min(\infty, 2 + 4, 7 + 3) = 6 \quad (\text{via } B)

      • Node D computes:             DD[A]=min⁡(∞,c[D][B]+DB[A],c[D][C]+DC[A])=min⁡(∞,4+2,3+7)=6(via B)D_D[A] = \min(\infty, c[D][B] + D_B[A], c[D][C] + D_C[A]) = \min(\infty, 4 + 2, 3 + 7) = 6 \quad (\text{via } B)

    • Post-Round 1 Converged Distance Tables:

      • Vector A: [A:0,B:2,C:3,D:6][A:0, B:2, C:3, D:6].

      • Vector B: [A:2,B:0,C:1,D:4][A:2, B:0, C:1, D:4].

      • Vector C: [A:3,B:1,C:0,D:3][A:3, B:1, C:0, D:3].

      • Vector D: [A:6,B:4,C:3,D:0][A:6, B:4, C:3, D:0].

    • Subsequent iterations yield no metric changes, indicating network convergence.

Previous Years University and GATE Exam Questions with Derivations

  • KIIT EndSem 2024: IPv4 Header Hexadecimal Parsing:

    • Question: An IPv4 datagram begins with the hexadecimal string 45000028000100000102.... Calculate how many hops the packet can travel before being discarded, and compute data length in bits.

    • Derivation:

      • Byte 0 (45): Version = 44, HLEN = 55 (5×4=20 bytes header5 \times 4 = 20\,\text{bytes header}).

      • Bytes 2–3 (0028): Total length in hex = 0x0028=40 bytes0x0028 = 40\,\text{bytes}.

      • Byte 8 (01): Time To Live (TTL) = 11.

      • Hop evaluation: Since TTL=1\text{TTL} = 1, the packet can travel exactly 1 hop1\,\text{hop}. The very next router will decrement TTL to 00 and drop it.

      • Payload calculation: Data Size=40−20=20 bytes\text{Data Size} = 40 - 20 = 20\,\text{bytes}.

      • Data in bits=20×8=160 bits\text{Data in bits} = 20 \times 8 = 160\,\text{bits}.

  • KIIT EndSem 2024: Fragmentation with Non-Default Header:

    • Question: A datagram of 1600 bytes1600\,\text{bytes} with a 30 byte30\,\text{byte} header traverses a link with MTU=1400 bytes\text{MTU} = 1400\,\text{bytes}. Determine the fragmentation breakdown.

    • Derivation:

      • Payload = 1600−30=1570 bytes1600 - 30 = 1570\,\text{bytes}.

      • Max data per fragment = 1400−30=1370 bytes1400 - 30 = 1370\,\text{bytes}.

      • Nearest multiple of 8 = ⌊1370/8⌋×8=1368 bytes\lfloor 1370 / 8 \rfloor \times 8 = 1368\,\text{bytes}.

      • Fragment 1: Data = 1368 bytes1368\,\text{bytes}, Total Size = 1398 bytes1398\,\text{bytes}, Offset = 00, MF = 1.

      • Fragment 2: Data = 1570−1368=202 bytes1570 - 1368 = 202\,\text{bytes}, Total Size = 232 bytes232\,\text{bytes}, Offset = 1368/8=1711368 / 8 = 171, MF = 0.

  • GATE CSE 2005: Class B Subnet Mask for 64 Subnets:

    • Question: An organization with a Class B network wishes to create subnets for 64 departments. Find the required subnet mask.

    • Derivation:

      • Class B default prefix is /16/16.

      • Subnets needed: 2ns≥64  ⟹  ns=6 bits2^{n_s} \ge 64 \implies n_s = 6\,\text{bits}.

      • New prefix: 16+6=/2216 + 6 = /22.

      • Third octet bit representation: 111111002=25211111100_2 = 252.

      • Resulting Subnet Mask: 255.255.252.0.

  • GATE CSE 2020: CIDR Block Allocation Validity:

    • Question: An ISP owns 202.61.0.0/17. A customer needs addresses for 1500 computers. Which blocks are valid?

      • I. 202.61.84.0/21

      • II. 202.61.104.0/21

      • III. 202.61.64.0/21

      • IV. 202.61.144.0/21

    • Derivation:

      • 1500 hosts+2 reserved=1502  ⟹  211=2048 addresses  ⟹  /211500\,\text{hosts} + 2\,\text{reserved} = 1502 \implies 2^{11} = 2048\,\text{addresses} \implies /21.

      • ISP range for 202.61.0.0/17 spans third octets from 0 to 1270\text{ to }127 (since bit 17 is 0).

      • Block IV (third octet 144144) is out of range (144>127144 > 127).

      • Alignment constraint: A /21/21 block spans 2048/256=82048 / 256 = 8 values in the third octet. The third octet must be an integer multiple of 88.

      • Block I: 84/8=10.584 / 8 = 10.5 (Not aligned; invalid).

      • Block II: 104/8=13104 / 8 = 13 (Aligned; valid).

      • Block III: 64/8=864 / 8 = 8 (Aligned; valid).

      • Conclusion: Blocks II and III only.

  • GATE CSE: Longest Prefix Matching Forwarding Problem:

    • Question: Router table entries: 10.1.1.0/24 (R1), 10.1.1.128/25 (R2), 10.1.1.64/26 (R3), 10.1.1.192/26 (R4). Forward 20 packets each to destinations: 10.1.1.16, 10.1.1.72, 10.1.1.132, 10.1.1.191, 10.1.1.205. Compute total packets routed via R2.

    • Derivation:

      • 10.1.1.16: Matches only /24/24 (range 0–2550\text{--}255)   ⟹  \implies routes via R1 (20 packets20\,\text{packets}).

      • 10.1.1.72: Matches /24/24 and /26/26 (10.1.1.64/26, range 64–12764\text{--}127). Longest match is /26  ⟹  /26 \implies routes via R3 (20 packets20\,\text{packets}).

      • 10.1.1.132: Matches /24/24 and /25/25 (10.1.1.128/25, range 128–255128\text{--}255). Does not match 10.1.1.192/26 (132<192132 < 192). Longest match is /25  ⟹  /25 \implies routes via R2 (20 packets20\,\text{packets}).

      • 10.1.1.191: Matches /24/24 and /25/25. Outside 10.1.1.192/26 (191<192191 < 192). Longest match is /25  ⟹  /25 \implies routes via R2 (20 packets20\,\text{packets}).

      • 10.1.1.205: Matches /24/24, /25/25, and /26/26 (10.1.1.192/26, range 192–255192\text{--}255). Longest match is /26  ⟹  /26 \implies routes via R4 (20 packets20\,\text{packets}).

      • Total Packets Routed via R2: 20+20=40 packets20 + 20 = 40\,\text{packets}.

  • GATE CSE 2018: Double-Link Re-Fragmentation Problem:

    • Question: A datagram of 4500 bytes4500\,\text{bytes} (20 byte20\,\text{byte} header) traverses Link 1 (MTU=1500 bytes\text{MTU} = 1500\,\text{bytes}) and then Link 2 (MTU=600 bytes\text{MTU} = 600\,\text{bytes}). How many fragments reach the destination?

    • Derivation:

      • Stage 1 (Link 1, MTU = 1500 B):

        • Payload = 4480 bytes4480\,\text{bytes}. Max data per fragment = 1500−20=1480 bytes1500 - 20 = 1480\,\text{bytes}.

        • Fragments generated = ⌈4480/1480⌉=4 fragments\lceil 4480 / 1480 \rceil = 4\,\text{fragments}.

        • Fragment sizes: F1=1480 BF_1 = 1480\,\text{B}, F2=1480 BF_2 = 1480\,\text{B}, F3=1480 BF_3 = 1480\,\text{B}, F4=40 BF_4 = 40\,\text{B}.

      • Stage 2 (Link 2, MTU = 600 B):

        • Max data per sub-fragment = 600−20=580 bytes600 - 20 = 580\,\text{bytes}.

        • Nearest multiple of 8: ⌊580/8⌋×8=576 bytes\lfloor 580 / 8 \rfloor \times 8 = 576\,\text{bytes}.

        • Re-fragmenting F1F_1 (1480 B1480\,\text{B}): ⌈1480/576⌉=3 sub-fragments\lceil 1480 / 576 \rceil = 3\,\text{sub-fragments} (576,576,328576, 576, 328).

        • Re-fragmenting F2F_2 (1480 B1480\,\text{B}): produces 3 sub-fragments3\,\text{sub-fragments}.

        • Re-fragmenting F3F_3 (1480 B1480\,\text{B}): produces 3 sub-fragments3\,\text{sub-fragments}.

        • Re-fragmenting F4F_4 (40 B40\,\text{B}): 40<58040 < 580, traverses intact as 1 fragment1\,\text{fragment}.

        • Total fragments reaching destination: 3+3+3+1=10 fragments3 + 3 + 3 + 1 = 10\,\text{fragments}.

  • GATE CSE 2022: Header Options and Byte Range Calculations:

    • Question: Datagram arrives with HLEN=6\text{HLEN} = 6, Total Length=200\text{Total Length} = 200, Fragment Offset=100\text{Fragment Offset} = 100. Find options length and original byte positions.

    • Derivation:

      • Header bytes = 6×4=24 bytes6 \times 4 = 24\,\text{bytes}.

      • Options bytes = 24−20=4 bytes24 - 20 = 4\,\text{bytes}.

      • Payload length = 200−24=176 bytes200 - 24 = 176\,\text{bytes}.

      • First byte in original datagram = Offset×8=100×8=800\text{Offset} \times 8 = 100 \times 8 = 800.

      • Last byte in original datagram = 800+176−1=975800 + 176 - 1 = 975.

Advanced Professor-Style Practice Problems with Solutions

  • Problem 1: Class B Partitioning into 32 Subnets:

    • Given block: 172.20.0.0/16. Create 32 equal subnets.

    • Bits borrowed: 2ns≥32  ⟹  ns=5 bits2^{n_s} \ge 32 \implies n_s = 5\,\text{bits}.

    • New prefix: 16+5=/2116 + 5 = /21.

    • Mask: 255.255.248.0 (111110002=24811111000_2 = 248 in third octet).

    • Usable hosts per subnet: 211−2=2046 hosts2^{11} - 2 = 2046\,\text{hosts}.

    • 5th Subnet (0-indexed = Subnet Index 4, or Index 5):

      • Stride in third octet = 2048/256=82048 / 256 = 8.

      • Subnet 5 base = 5×8=405 \times 8 = 40 in third octet.

      • Network ID = 172.20.40.0/21.

      • Broadcast = 172.20.47.255.

  • Problem 2: Four-Department VLSM Design (192.168.50.0/24):

    • Requirements: Sales (60 hosts60\,\text{hosts}), IT (30 hosts30\,\text{hosts}), HR (14 hosts14\,\text{hosts}), Management (6 hosts6\,\text{hosts}).

    • Sales: Demand 60+2=62  ⟹  26=64 addresses  ⟹  /2660 + 2 = 62 \implies 2^6 = 64\,\text{addresses} \implies /26.

      • Block: 192.168.50.0/26; Usable: 192.168.50.1 to .62; Broadcast: 192.168.50.63.

    • IT: Demand 30+2=32  ⟹  25=32 addresses  ⟹  /2730 + 2 = 32 \implies 2^5 = 32\,\text{addresses} \implies /27.

      • Block: 192.168.50.64/27; Usable: 192.168.50.65 to .94; Broadcast: 192.168.50.95.

    • HR: Demand 14+2=16  ⟹  24=16 addresses  ⟹  /2814 + 2 = 16 \implies 2^4 = 16\,\text{addresses} \implies /28.

      • Block: 192.168.50.96/28; Usable: 192.168.50.97 to .110; Broadcast: 192.168.50.111.

    • Management: Demand 6+2=8  ⟹  23=8 addresses  ⟹  /296 + 2 = 8 \implies 2^3 = 8\,\text{addresses} \implies /29.

      • Block: 192.168.50.112/29; Usable: 192.168.50.113 to .118; Broadcast: 192.168.50.119.

    • Unallocated: 192.168.50.120 through 192.168.50.255 (136 addresses136\,\text{addresses} reserved).

  • Problem 3: Host Mask Analysis:

    • Given: Host 10.4.96.130, Mask 255.255.224.0.

    • Mask binary: Third octet is 224=111000002  ⟹  224 = 11100000_2 \implies Prefix length is /19/19.

    • Third-octet Network ID: 96 & 224=011000002 & 111000002=011000002=9696\,\&\,224 = 01100000_2 \,\&\, 11100000_2 = 01100000_2 = 96.

    • Network Address = 10.4.96.0.

    • Third-octet Broadcast: 96+32−1=127  ⟹  96 + 32 - 1 = 127 \implies Broadcast = 10.4.127.255.

    • Usable hosts: 213−2=8190 hosts2^{13} - 2 = 8190\,\text{hosts}.

    • Subnet check for 10.4.119.200: 119 & 224=011101112 & 111000002=011000002=96119\,\&\,224 = 01110111_2 \,\&\, 11100000_2 = 01100000_2 = 96. Matches 10.4.96.0; occupies the exact same subnet.

  • Problem 4: Subnet Borrowing Calculation:

    • Given block 10.0.0.0/8, design for at least 1000 subnets1000\,\text{subnets} with ≥500 hosts\ge 500\,\text{hosts} each.

    • Subnet condition: 2ns≥1000  ⟹  ns=10 bits2^{n_s} \ge 1000 \implies n_s = 10\,\text{bits} (210=10242^{10} = 1024).

    • New Prefix: 8+10=/188 + 10 = /18.

    • Host verification: Host bits remaining = 32−18=14 bits32 - 18 = 14\,\text{bits}.

    • Usable hosts per subnet = 214−2=16,382≥5002^{14} - 2 = 16,382 \ge 500. Condition verified.

Supplementary Practice Repository and Solution Key

  • Addressing and Supernetting Exercises:

    • Exercise: Check if 200.16.7.0/24 and 200.16.8.0/24 can be aggregated into a single supernet.

      • Solution: No. Although they are two blocks, they do not align on an integer multiple boundary for a /23/23 block (2 blocks2\,\text{blocks}). A /23/23 block must begin at an even third octet (e.g., 6 and 76\text{ and }7, or 8 and 98\text{ and }9). Octet 77 is odd, preventing aggregation.

    • Exercise: Aggregate 198.10.8.0/24, 198.10.9.0/24, 198.10.10.0/24, 198.10.11.0/24.

      • Solution: Four contiguous blocks starting at 88. Since 8=2×48 = 2 \times 4, boundary alignment is satisfied. Common bits in third octet = 6 bits6\,\text{bits}. Supernet is 198.10.8.0/22.

  • Fragmentation Exercises:

    • Exercise: An IP datagram of 3500 bytes3500\,\text{bytes} (20 byte20\,\text{byte} header) crosses a link with MTU=1000 bytes\text{MTU} = 1000\,\text{bytes}. Find fragment specifications.

      • Solution: Payload = 3480 bytes3480\,\text{bytes}. Max payload per fragment = ⌊(1000−20)/8⌋×8=⌊980/8⌋×8=976 bytes\lfloor (1000 - 20) / 8 \rfloor \times 8 = \lfloor 980 / 8 \rfloor \times 8 = 976\,\text{bytes}.

      • Total fragments = ⌈3480/976⌉=4 fragments\lceil 3480 / 976 \rceil = 4\,\text{fragments}.

      • Fragment 1: Data = 976 bytes976\,\text{bytes}, Offset = 00, MF = 1.

      • Fragment 2: Data = 976 bytes976\,\text{bytes}, Offset = 976/8=122976 / 8 = 122, MF = 1.

      • Fragment 3: Data = 976 bytes976\,\text{bytes}, Offset = 1952/8=2441952 / 8 = 244, MF = 1.

      • Fragment 4: Data = 3480−(3×976)=552 bytes3480 - (3 \times 976) = 552\,\text{bytes}, Offset = 2928/8=3662928 / 8 = 366, MF = 0.

    • Exercise: A fragment arrives with Offset = 185185, HLEN=5\text{HLEN} = 5, Total Length=100\text{Total Length} = 100. Find byte range.

      • Solution: First byte = 185×8=1480185 \times 8 = 1480. Payload = 100−20=80 bytes100 - 20 = 80\,\text{bytes}. Last byte = 1480+80−1=15591480 + 80 - 1 = 1559.

    • Exercise: High-volume UDP segment of 8880 bytes8880\,\text{bytes} user data transmitted over Ethernet (MTU=1500 bytes\text{MTU} = 1500\,\text{bytes}, IP header = 20 bytes20\,\text{bytes}, UDP header = 8 bytes8\,\text{bytes}). Find fragment count and last offset.

      • Solution: Total IP payload = 8880+8=8888 bytes8880 + 8 = 8888\,\text{bytes}.

      • Max data per fragment = 1500−20=1480 bytes1500 - 20 = 1480\,\text{bytes}.

      • Fragments = ⌈8888/1480⌉=7 fragments\lceil 8888 / 1480 \rceil = 7\,\text{fragments}.

      • Last fragment offset = 6×14808=1110\frac{6 \times 1480}{8} = 1110.

  • Protocol Mechanics and Diagnostic Exercises:

    • Exercise: What does an ICMP Type 11, Code 0 packet signify, and which diagnostic program relies on it?

      • Solution: Signifies "Time to Live (TTL) exceeded in transit". The traceroute utility relies on this message to discover intermediate router hops.

    • Exercise: A diskless client transmits a RARP Request with Operation Code 33. Why are the Sender and Target IP addresses set to 0.0.0.0?

      • Solution: The diskless machine lacks secondary storage and does not know its IP address; 0.0.0.0 is the default placeholder while querying the RARP server for its assigned IP.

    • Exercise: Why are DHCP DISCOVER and REQUEST messages transmitted as limited broadcasts (255.255.255.255)?

      • Solution: The client does not possess an assigned IP address yet. Furthermore, the REQUEST message must be broadcast so that all responding DHCP servers observe which server's offer was accepted, allowing non-selected servers to release their reserved leases back to their address pools.