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 ( 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 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 ().
Total Theoretical Address Space: .
Binary Representation: grouped into four octets, for example:
10000000 00001011 00000011 00011111.Dotted-Decimal Representation: Each octet is independently converted to a base-10 integer (ranging from to ) 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: (Binary:
00000000to01111111).Network Prefix: (, ).
Default Subnet Mask:
255.0.0.0.Maximum Usable Hosts per Network: .
Class B:
Leading Bits:
10...First Octet Range: (Binary:
10000000to10111111).Network Prefix: (, ).
Default Subnet Mask:
255.255.0.0.Maximum Usable Hosts per Network: .
Class C:
Leading Bits:
110...First Octet Range: (Binary:
11000000to11011111).Network Prefix: (, ).
Default Subnet Mask:
255.255.255.0.Maximum Usable Hosts per Network: .
Class D:
Leading Bits:
1110...First Octet Range: (Binary:
11100000to11101111).Purpose: Multicast addressing. No network/host bit division exists; addresses identify logical multicast groups.
Class E:
Leading Bits:
1111...First Octet Range: (Binary:
11110000to11111111).Purpose: Reserved for experimental, research, and future use.
Mathematical Rationale for Reserved Addresses ():
For any subnet or network block containing host bits, total theoretical combinations equal , but usable assignable addresses equal .
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 entire127.0.0.0/8block): 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.0to10.255.255.255( prefix, of ).Class B Range:
172.16.0.0to172.31.255.255( prefix, , ).Class C Range:
192.168.0.0to192.168.255.255( prefix, , ).
Failure of the Classful Addressing Paradigm:
Coarse Granularity: Pre-defined allocation sizes lacked flexibility. An enterprise requiring could not fit within a Class C network () and was assigned a full Class B block (), wasting over .
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 (, , ).
Allows the network prefix length to span any arbitrary integer value from , 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 block containing to an organization needing ).
Mathematical Properties of a CIDR Block
a.b.c.d/n:Total Address Capacity: .
Number of Usable Host Interfaces: .
Prefix Length: defines the number of leading binary ones in the subnet mask.
Host Bits: .
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 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 bits to
1).
Worked Analysis: Evaluating Block
167.199.170.82/27:Step 1: Determine Address Count:
, so remaining host bits .
Total addresses .
Usable host addresses = .
Step 2: Binary Decomposition:
Address
167.199.170.82in binary:Subnet mask in binary (27 ones followed by 5 zeros):
Step 3: Network Address Computation:
Evaluate fourth octet:
Network Address =
167.199.170.64/27.
Step 4: Broadcast Address Computation:
Evaluate fourth octet:
Broadcast Address =
167.199.170.95/27.
Step 5: Usable Host Range:
From Network Address to Broadcast Address :
167.199.170.65through167.199.170.94.
Worked Analysis: Same-Subnet Determination:
Query: Determine if hosts
192.168.10.45and192.168.10.70reside in the same subnet.Mask for is
255.255.255.224.Evaluate Host 1: . . Subnet ID =
192.168.10.32.Evaluate Host 2: . . Subnet ID =
192.168.10.64.Conclusion: Because
192.168.10.32192.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 bits from the available host portion, converting them into subnet identifier bits.
Core Subnetting Formulas:
Number of Resulting Subnets: .
Host Bits Remaining: .
Total Addresses per Subnet: .
Usable Hosts per Subnet: .
New Extended Prefix: .
Step-by-Step Subnetting Derivation: Carving
192.168.1.0/24into Four Subnets:Initial Conditions: Original block is
192.168.1.0/24. Host bits . Total addresses = .Step 1: Compute Borrowed Bits ():
Target: . Equation: .
Step 2: Determine New Prefix and Mask:
New Prefix: ().
Binary Mask:
11111111.11111111.11111111.11000000.Dotted-Decimal Mask:
255.255.255.192.
Step 3: Calculate Subnet Stride (Block Size):
Remaining host bits: .
Addresses per subnet: .
Usable hosts per subnet: .
Step 4: Enumerate Subnet Ranges:
Subnet 0 (Borrowed bits =
00): Network ID =192.168.1.0/26; Usable Host Range =192.168.1.1to192.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.65to192.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.129to192.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.193to192.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 block of must start at an address divisible by ; a block must start at a multiple of ). 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 = ).Department Requirements: Department A (), Department B (), Department C ().
Subnet A Allocation (120 hosts):
Address demand: .
Smallest power of 2: .
Host bits required: ().
Subnet ID:
14.24.74.0/25.Subnet Mask:
255.255.255.128.Usable Range:
14.24.74.1through14.24.74.126().Broadcast Address:
14.24.74.127.
Subnet B Allocation (60 hosts):
Address demand: .
Smallest power of 2: .
Host bits required: ().
Starting address must align on a multiple of :
14.24.74.128satisfies this condition.Subnet ID:
14.24.74.128/26.Subnet Mask:
255.255.255.192.Usable Range:
14.24.74.129through14.24.74.190().Broadcast Address:
14.24.74.191.
Subnet C Allocation (10 hosts):
Address demand: .
Smallest power of 2: .
Host bits required: ().
Starting address must align on a multiple of :
14.24.74.192satisfies this condition ().Subnet ID:
14.24.74.192/28.Subnet Mask:
255.255.255.240.Usable Range:
14.24.74.193through14.24.74.206().Broadcast Address:
14.24.74.207.
Unallocated Reserve Pool:
Spans
14.24.74.208through14.24.74.255( available for future growth).
Supernetting and Route Aggregation
Motivation and Principles:
By 1994, routing tables in core Internet routers faced exponential growth, exceeding .
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 , where is an integer ().
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: .
New prefix length: .
Total addresses: .
Binary examination of third octets:
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 is not a power of .
Correction: Add
205.16.36.0/24to yield four contiguous blocks starting at third octet . Since , it satisfies alignment on a multiple of .Binary evaluation of octets :
Common leading bits in third octet =
001001(). Aggregated prefix: .Resulting Supernet:
205.16.36.0/22().
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 (, the length of IPv4).
Total Address Space: .
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:0001becomes2001:db8::1.
Structural Header Enhancements:
Fixed Base Header Size: Standardized at exactly . 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 IPv4127.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 ; IPv6 uses .
Base Header Size: IPv4 uses variable ; IPv6 uses fixed .
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 ().
With optional IP fields, total header size can expand up to .
Field-by-Field Breakdown:
Version (4 bits): Identifies the IP protocol version. Holds the binary value
0100() for IPv4 or0110() for IPv6.Header Length / HLEN (4 bits): Specifies the total header length in 32-bit (4-byte) words. Minimum value is (); maximum value is ().
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 .
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
1on all fragments except the final fragment, where it is set to0. On unfragmented datagrams, it is set to0.
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 at each intermediate router hop. When TTL reaches , 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:
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 ().
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:
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 = , PPPoE = , legacy WAN = ).
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 wide, representing values from .
If offsets were measured in single bytes, the maximum addressable position would be , rendering the field unable to handle IPv4 datagrams up to .
By scaling offsets in units of , the maximum addressable data position becomes .
Consequence: The data payload of every intermediate fragment (all except the last) must strictly be an integer multiple of .
Router Decision Logic:
Condition 1: Total Size 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):
: First fragment of a fragmented datagram.
: Middle fragment of a fragmented datagram.
: Final fragment of a fragmented datagram.
: Completely unfragmented original datagram.
Fragmentation Equations and Efficiency:
Let , , .
Maximum allowable data per fragment (must be divisible by 8):
Number of fragments generated:
Fragment Offset for fragment (where ):
Total Header Overhead Introduced:
Transmission Efficiency on Wire:
Comprehensive Fragmentation Walkthrough:
Input: Original datagram = total ( header, payload), Identification =
14567, .Step 1: Compute maximum payload: . Since (integer), .
Step 2: Fragment count: .
Fragment 1: Data = (Bytes 0 to 1479); Total Size = ; Offset = ; MF =
1; ID =14567.Fragment 2: Data = (Bytes 1480 to 2959); Total Size = ; Offset = ; MF =
1; ID =14567.Fragment 3: Data = (Bytes 2960 to 3979); Total Size = ; Offset = ; 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 . 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:
Sends a datagram with . The first hop router decrements TTL to , drops the datagram, and returns an ICMP Type 11, Code 0 (Time Exceeded) message, exposing its IP address.
Increments TTL to , successively discovering each intermediate router IP along the path.
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 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.1to its public IP203.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 with10.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 to prevent broadcast flooding on subsequent transmissions.
Ethernet Framing: ARP packets carry an Ethernet Type field of
0x0806(differentiating them from IPv4 datagrams, which carry0x0800).ARP Packet Fields (28 bytes total):
Hardware Type ():
1for Ethernet.Protocol Type ():
0x0800for IPv4.Hardware Length ():
6(bytes in a MAC).Protocol Length ():
4(bytes in an IPv4 address).Operation Code ():
1for ARP Request,2for ARP Reply.Sender Hardware Address (): MAC of sender.
Sender Protocol Address (): IP of sender.
Target Hardware Address (): All zeros in Request; filled with recipient MAC in Reply.
Target Protocol Address (): 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
0x8035and Operation Codes:3(RARP Request) and4(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 ; Server listens on UDP Port .
Relay Capability: Operates across subnets through DHCP Relay Agents running on routers (tracking the agent IP in the
giaddrfield).The 4-Step DORA Handshake:
DHCP DISCOVER: Client broadcasts (Source IP =
0.0.0.0, Dest IP =255.255.255.255) to locate reachable DHCP servers.DHCP OFFER: DHCP server reserves an unassigned IP from its pool and sends an offer specifying lease duration and network parameters.
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.
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: Where is the estimated cost from node to destination , is the cost of the direct link from to neighbor , and is neighbor 's reported shortest distance to .
Algorithmic Execution:
Initialize: ; for direct neighbors , set ; for non-neighbors, set .
Transmit local vector to all neighbors.
Upon receiving an update from neighbor , re-evaluate Bellman-Ford. If an entry changes, transmit the updated vector to all neighbors.
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, and (via ).If link breaks, sets its local cost to to .
Before can broadcast this failure, sends its periodic update stating .
receives this and computes: "I can reach via at cost ". updates its table to and advertises it.
receives 's update, recomputes , and advertises it back to .
Nodes and 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 (e.g., metric = in RIP), actively breaking two-node loops.
Hop Limit Ceiling: Defining an absolute low value as infinity (e.g., RIP sets ) 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: , , .
Initialize: , . For all direct neighbors , ; for non-neighbors, .
Find node with the minimum cost . Add to .
Update distances for all neighbors of node : 4. Repeat Steps 2 and 3 until all nodes are placed in set .
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-PATHattribute).Loop Detection: If a router receives an update containing its own ASN anywhere within the
AS-PATHattribute, 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 ).
Maximum Diameter: Hop count ranges from . A metric of represents infinity (unreachable).
Update Cycle: Periodically transmits its complete routing table to all direct neighbors every .
Transport: Encapsulated in UDP datagrams on Port .
Protocol Versions: RIPv1 (classful, broadcasts updates to
255.255.255.255, no subnet mask support); RIPv2 (classless, supports CIDR/VLSM, multicasts to224.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:
Transport: Encapsulated directly within IPv4 datagrams with Protocol field set to . 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), OSPF routers would establish 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 (; priority 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 on224.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 .
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 (); OSPF uses bandwidth-based link cost; BGP uses multi-attribute policy evaluation and AS-PATH length.
Transport Protocol: RIP uses UDP Port ; OSPF uses IP Protocol ; BGP uses TCP Port .
Convergence Speed: RIP is slow; OSPF is fast; BGP is deliberately slow for stability.
Scalability Limit: RIP is limited to small networks (); OSPF supports large multi-area enterprise networks; BGP scales to the global Internet ().
Loop Prevention Mechanism: RIP relies on Split Horizon and Poison Reverse; OSPF uses a global topology map and SPF calculation; BGP uses
AS-PATHinspection.
Comprehensive Solved Numericals and Algorithmic Walkthroughs
Numerical 1: Subnetting a Class C Network (
200.1.2.0/24into 4 Subnets):Problem: An organization receives
200.1.2.0/24and must create four equal subnets.Derivation:
Subnets needed: .
New prefix: .
Subnet Mask:
255.255.255.192.Host bits remaining: .
Usable hosts per subnet: .
Block increment (stride): .
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/16into 64 Subnets):Problem: Partition
172.16.0.0/16into exactly 64 equal sub-networks.Derivation:
Bits borrowed: .
New prefix: .
Binary mask (third octet): .
Dotted-decimal mask:
255.255.252.0.Remaining host bits: .
Total addresses per subnet: .
Usable hosts per subnet: .
Third-octet stride: .
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.10with mask255.255.255.240, find Subnet ID, Broadcast, and Host Range.Derivation:
Mask
255.255.255.240corresponds to ().Fourth octet evaluation: , .
Subnet ID:
220.15.1.0/28.Broadcast Address:
220.15.1.15.Valid Host Range:
220.15.1.1through220.15.1.14().
Numerical 5: IP Packet Fragmentation Breakdown:
Problem: Datagram total size = ( header), Identification =
14567, .Derivation:
Data payload: .
Max data per fragment: (divisible by 8).
Total fragments: .
Fragment 1: Data = ; Total Size = ; Offset = ; MF =
1; ID =14567.Fragment 2: Data = ; Total Size = ; Offset = ; MF =
1; ID =14567.Fragment 3: Data = ; Total Size = ; Offset = ; MF =
0; ID =14567.
Numerical 5b: Fragmentation Efficiency and Extra Header Overhead:
Problem: Host A transmits a datagram with header and payload over a link with .
Derivation:
Max payload per fragment: .
Nearest multiple of 8: .
Fragment count: .
Fragment 1: Data = , Total = , Offset = , MF =
1.Fragment 2: Data = , Total = , Offset = , MF =
1.Fragment 3: Data = , Total = , Offset = , MF =
0.Total on-wire bytes transmitted: .
Extra Header Overhead: .
Transmission Efficiency:
Numerical 5c: Fragmentation with Non-Default Header Options (HLEN = 8):
Problem: Datagram total length = , , payload = , crossing link with .
Derivation:
Header size: ().
Max payload capacity: .
Check divisibility: (valid integer multiple).
Fragment count: .
Fragment 1: Data = , Start Byte = , Offset = , MF =
1, Total Size = .Fragment 2: Data = , Start Byte = , Offset = , MF =
1, Total Size = .Fragment 3: Data = , Start Byte = , Offset = , MF =
1, Total Size = .Fragment 4: Data = , Start Byte = , Offset = , MF =
0, Total Size = .Total on-wire bytes: .
Efficiency: .
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 ; Distance Vector: .
Step 1: Min node is (). Add to . Relax neighbors: , .
Step 2: Min node is (). Add to . Relax neighbors: .
Step 3: Min node is (). Add to . Relax neighbors: .
Step 4: Min node is (). Add to . Relax neighbors: , .
Step 5: Min node is (). Add to . Relax neighbors: .
Step 6: Min node is (). Add to .
Final Shortest Paths and Forwarding Interface from A:
Destination B: Cost = ; Path = ; Next Hop = .
Destination C: Cost = ; Path = ; Next Hop = .
Destination D: Cost = ; Path = ; Next Hop = .
Destination E: Cost = ; Path = ; Next Hop = .
Destination F: Cost = ; Path = ; Next Hop = .
Destination G: Cost = ; Path = ; Next Hop = .
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: .
Vector B: .
Vector C: .
Vector D: .
Round 1 (After Single Vector Exchange):
Node A computes:
Node D computes:
Post-Round 1 Converged Distance Tables:
Vector A: .
Vector B: .
Vector C: .
Vector D: .
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 = , HLEN = ().Bytes 2–3 (
0028): Total length in hex = .Byte 8 (
01): Time To Live (TTL) = .Hop evaluation: Since , the packet can travel exactly . The very next router will decrement TTL to and drop it.
Payload calculation: .
.
KIIT EndSem 2024: Fragmentation with Non-Default Header:
Question: A datagram of with a header traverses a link with . Determine the fragmentation breakdown.
Derivation:
Payload = .
Max data per fragment = .
Nearest multiple of 8 = .
Fragment 1: Data = , Total Size = , Offset = , MF =
1.Fragment 2: Data = , Total Size = , Offset = , 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 .
Subnets needed: .
New prefix: .
Third octet bit representation: .
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/21II.
202.61.104.0/21III.
202.61.64.0/21IV.
202.61.144.0/21
Derivation:
.
ISP range for
202.61.0.0/17spans third octets from (since bit 17 is0).Block IV (third octet ) is out of range ().
Alignment constraint: A block spans values in the third octet. The third octet must be an integer multiple of .
Block I: (Not aligned; invalid).
Block II: (Aligned; valid).
Block III: (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 (range ) routes via R1 ().10.1.1.72: Matches and (10.1.1.64/26, range ). Longest match is routes via R3 ().10.1.1.132: Matches and (10.1.1.128/25, range ). Does not match10.1.1.192/26(). Longest match is routes via R2 ().10.1.1.191: Matches and . Outside10.1.1.192/26(). Longest match is routes via R2 ().10.1.1.205: Matches , , and (10.1.1.192/26, range ). Longest match is routes via R4 ().Total Packets Routed via R2: .
GATE CSE 2018: Double-Link Re-Fragmentation Problem:
Question: A datagram of ( header) traverses Link 1 () and then Link 2 (). How many fragments reach the destination?
Derivation:
Stage 1 (Link 1, MTU = 1500 B):
Payload = . Max data per fragment = .
Fragments generated = .
Fragment sizes: , , , .
Stage 2 (Link 2, MTU = 600 B):
Max data per sub-fragment = .
Nearest multiple of 8: .
Re-fragmenting (): ().
Re-fragmenting (): produces .
Re-fragmenting (): produces .
Re-fragmenting (): , traverses intact as .
Total fragments reaching destination: .
GATE CSE 2022: Header Options and Byte Range Calculations:
Question: Datagram arrives with , , . Find options length and original byte positions.
Derivation:
Header bytes = .
Options bytes = .
Payload length = .
First byte in original datagram = .
Last byte in original datagram = .
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: .
New prefix: .
Mask:
255.255.248.0( in third octet).Usable hosts per subnet: .
5th Subnet (0-indexed = Subnet Index 4, or Index 5):
Stride in third octet = .
Subnet 5 base = 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 (), IT (), HR (), Management ().
Sales: Demand .
Block:
192.168.50.0/26; Usable:192.168.50.1to.62; Broadcast:192.168.50.63.
IT: Demand .
Block:
192.168.50.64/27; Usable:192.168.50.65to.94; Broadcast:192.168.50.95.
HR: Demand .
Block:
192.168.50.96/28; Usable:192.168.50.97to.110; Broadcast:192.168.50.111.
Management: Demand .
Block:
192.168.50.112/29; Usable:192.168.50.113to.118; Broadcast:192.168.50.119.
Unallocated:
192.168.50.120through192.168.50.255( reserved).
Problem 3: Host Mask Analysis:
Given: Host
10.4.96.130, Mask255.255.224.0.Mask binary: Third octet is Prefix length is .
Third-octet Network ID: .
Network Address =
10.4.96.0.Third-octet Broadcast: Broadcast =
10.4.127.255.Usable hosts: .
Subnet check for
10.4.119.200: . Matches10.4.96.0; occupies the exact same subnet.
Problem 4: Subnet Borrowing Calculation:
Given block
10.0.0.0/8, design for at least with each.Subnet condition: ().
New Prefix: .
Host verification: Host bits remaining = .
Usable hosts per subnet = . Condition verified.
Supplementary Practice Repository and Solution Key
Addressing and Supernetting Exercises:
Exercise: Check if
200.16.7.0/24and200.16.8.0/24can be aggregated into a single supernet.Solution: No. Although they are two blocks, they do not align on an integer multiple boundary for a block (). A block must begin at an even third octet (e.g., , or ). Octet 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 . Since , boundary alignment is satisfied. Common bits in third octet = . Supernet is
198.10.8.0/22.
Fragmentation Exercises:
Exercise: An IP datagram of ( header) crosses a link with . Find fragment specifications.
Solution: Payload = . Max payload per fragment = .
Total fragments = .
Fragment 1: Data = , Offset = , MF =
1.Fragment 2: Data = , Offset = , MF =
1.Fragment 3: Data = , Offset = , MF =
1.Fragment 4: Data = , Offset = , MF =
0.
Exercise: A fragment arrives with Offset = , , . Find byte range.
Solution: First byte = . Payload = . Last byte = .
Exercise: High-volume UDP segment of user data transmitted over Ethernet (, IP header = , UDP header = ). Find fragment count and last offset.
Solution: Total IP payload = .
Max data per fragment = .
Fragments = .
Last fragment offset = .
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
tracerouteutility relies on this message to discover intermediate router hops.
Exercise: A diskless client transmits a RARP Request with Operation Code . 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.0is 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.