CS24305 • Module 5

Module 5: Networking, Transport & Application Layers

Topics 37 to 52 • IPv4/IPv6, Subnetting, Dijkstra/Bellman-Ford, TCP AIMD & HTTP/3
Module V: Networking, Transport & Application Layers — 16-Topic Master Syllabus Guide
Topic 37: IPv4 Header Format (20-byte base fields, TTL, Protocol, Header Checksum, Fragmentation)
Topic 38: IPv6 Architecture (128-bit addressing, 40-byte base header, Extension Headers vs. IPv4)
Topic 39: Subnetting, Supernetting & Classless Inter-Domain Routing (CIDR Notation & Prefix Masks)
Topic 40: Address Resolution Protocol (ARP Request/Reply, ARP Cache & RARP / DHCP)
Topic 41: Internet Control Message Protocol (ICMP Error Reporting: Ping, Traceroute Mechanics)
Topic 42: Routing Algorithms: Distance Vector Routing (Bellman-Ford & Count-to-Infinity Problem)
Topic 43: Routing Algorithms: Link State Routing (Dijkstra's Shortest Path Algorithm & OSPF)
Topic 44: Hierarchical Routing & Inter-Domain Routing (Border Gateway Protocol BGP-4 Path Vector)
Topic 45: Transport Layer: User Datagram Protocol (UDP 8-byte Header & Pseudo-Header Checksum)
Topic 46: Transmission Control Protocol (TCP Segment Header Architecture & Flags: SYN, ACK, FIN, RST)
Topic 47: TCP Connection Management (3-Way Handshake SYN/SYN-ACK/ACK & 4-Way FIN Teardown)
Topic 48: TCP Flow Control (Sliding Window & Silly Window Syndrome Prevention: Nagle & Clark Algorithms)
Topic 49: TCP Congestion Control (AIMD, Slow Start, Congestion Avoidance, Fast Retransmit, Fast Recovery)
Topic 50: Domain Name System (DNS Hierarchical Namespace, Root Servers, Iterative vs Recursive Queries)
Topic 51: Electronic Mail Architecture (SMTP, POP3, IMAP4, MIME & Message Transfer Agents)
Topic 52: Web Protocols: HTTP/1.0, HTTP/1.1 (Persistent Connections & Pipelining), HTTP/2 & HTTP/3 QUIC

Topic 37 & 39: IPv4 Header Architecture, Subnetting & CIDR Math

IPv4 Field Field Size Core Routing Function & Protocols
Version4 BitsSpecifies IP version (`0100` = IPv4, `0110` = IPv6).
IHL (Header Length)4 BitsHeader length in 32-bit words (Minimum value = 5 $\implies 20\text{ bytes}$; Maximum = 15 $\implies 60\text{ bytes}$).
Total Length16 BitsTotal datagram size (Header + Data) in bytes (Max $65,535\text{ bytes}$).
Identification16 BitsUnique integer tagging all fragments belonging to same original datagram.
Flags3 BitsBit 0 (Reserved); Bit 1 (DF = Don't Fragment); Bit 2 (MF = More Fragments).
Fragment Offset13 BitsOffset of fragment relative to original unfragmented payload in 8-byte blocks.
TTL (Time to Live)8 BitsHop counter decremented by 1 at every router; discarded at 0 with ICMP Time Exceeded.
Protocol8 BitsSpecifies Layer 4 payload: ICMP = 1, IGMP = 2, TCP = 6, UDP = 17, OSPF = 89.
Header Checksum16 Bits1's complement checksum covering ONLY the IP header (recomputed at every hop).
Source & Dest IP32 Bits eachOrigin and final destination IPv4 logical addresses.
🏛️ Step-by-Step Solved Problem 1: IPv4 Fragmentation Calculation

An IPv4 packet with Total Length = $4020\text{ bytes}$ (20 bytes IP header + 4000 bytes data) travels across an Ethernet link with $\text{MTU} = 1500\text{ bytes}$. Calculate the fields for all resulting fragments.

Solution: Max payload per fragment = $1500 - 20 = 1480\text{ bytes}$ (divisible by 8: $1480 / 8 = 185$).

🏛️ Step-by-Step Solved Problem 2: CIDR Subnetting & Address Allocation

An ISP assigns block `198.51.100.0/24` to an organization needing 4 equal subnets. Find: (1) Subnet mask, (2) Usable hosts per subnet, (3) Subnet network addresses, and (4) Broadcast addresses.

Solution:

Topic 42 & 43: Routing Algorithms: Distance Vector vs. Link State (Dijkstra)

Dimension Distance Vector Routing (Bellman-Ford / RIP) Link State Routing (Dijkstra / OSPF)
Knowledge of Topology Routers know only distance vectors of immediate direct neighbors ("Routing by rumor"). Every router possesses complete global topological graph of entire Autonomous System.
Algorithm Bellman-Ford Equation: $D_x(y) = \min_v \{ c(x, v) + D_v(y) \}$. Dijkstra's Shortest Path Tree algorithm.
Convergence Speed Slow convergence; suffers from Count-to-Infinity problem on link failures. Fast Convergence: Link State Advertisements (LSAs) flood updates instantly.
Loop Prevention Split Horizon, Poison Reverse, Maximum Hop Count (= 15 in RIP). Zero routing loops (Dijkstra guarantees unique loop-free shortest path tree).

Topic 46, 47 & 49: TCP Architecture, Handshakes & Congestion Control

Client Server 1. SYN (seq = x) 2. SYN-ACK (seq = y, ack = x + 1) 3. ACK (seq = x + 1, ack = y + 1)
Figure 5.1: TCP 3-Way Handshake Connection Establishment Protocol
The 4 Phases of TCP Congestion Control (AIMD): 1. Slow Start: Starts with $\text{cwnd} = 1\text{ MSS}$. Doubles $\text{cwnd}$ every RTT ($\text{cwnd} \leftarrow \text{cwnd} \times 2$) exponentially until reaching $\text{ssthresh}$. 2. Congestion Avoidance: Linear growth: increases $\text{cwnd}$ by $1\text{ MSS}$ per RTT ($\text{cwnd} \leftarrow \text{cwnd} + 1$) until packet loss occurs. 3. Timeout Reaction (TCP Tahoe): Sets $\text{ssthresh} \leftarrow \text{cwnd} / 2$, resets $\text{cwnd} \leftarrow 1\text{ MSS}$, re-enters Slow Start. 4. 3 Duplicate ACKs (TCP Reno): Fast Retransmit triggers immediate retransmission; sets $\text{ssthresh} \leftarrow \text{cwnd}/2$, $\text{cwnd} \leftarrow \text{ssthresh} + 3\text{ MSS}$, enters Fast Recovery!

Topic 50, 51 & 52: Application Layer Protocols (DNS, Email & HTTP)

Protocol Port & Transport Architecture & Function Key Evolution Highlights
DNS Port 53 (UDP primary, TCP for zone transfer) Hierarchical distributed database: Root $\rightarrow$ TLD (.com, .edu) $\rightarrow$ Authoritative servers. Iterative vs. Recursive resolution; DNSSEC security records.
SMTP Port 25 / 587 (TCP) Push protocol for sending email between Message Transfer Agents (MTAs). MIME extensions support attachments, audio, HTML formatting.
POP3 / IMAP4 POP3: Port 110; IMAP: Port 143 (TCP) Pull protocols for retrieving email from mail servers to local user mail clients. POP3 downloads and deletes; IMAP syncs folders dynamically across multiple devices.
HTTP/1.1 Port 80 (TCP) Persistent TCP connections (`Keep-Alive`) & pipelining over single connection. Suffers from Head-of-Line (HoL) blocking at application level.
HTTP/2 Port 443 (TLS/TCP) Binary framing layer; multiplexes multiple independent request/response streams over 1 TCP socket. HPACK header compression, Server Push; TCP-level packet drop still stalls all streams.
HTTP/3 (QUIC) Port 443 (UDP) Replaces TCP with QUIC over UDP: combines TLS 1.3 handshake and transport in single round-trip! Zero Head-of-Line Blocking: Packet loss in one stream never stalls other streams!

🧠 M5 Active Recall & 10-Question University Exam Master Bank

Q1. Draw the complete IPv4 Header format and explain the function of TTL, Header Checksum, and Fragmentation fields. (10 Marks)
• TTL (8 bits): Hop counter decremented at each router. Prevents undeliverable packets from looping infinitely.
• Header Checksum (16 bits): 1's complement sum covering header only. Verified at every hop.
• Identification (16 bits): Tags fragments of same datagram.
• Flags (3 bits): DF (Don't Fragment), MF (More Fragments).
• Fragment Offset (13 bits): Measures data offset in 8-byte blocks relative to unfragmented payload.
Q2. Explain TCP 3-Way Handshake Connection Establishment and 4-Way Connection Termination with sequence diagrams. (10 Marks)
• 3-Way Establishment: (1) Client $\rightarrow$ Server: `SYN (seq=x)`; (2) Server $\rightarrow$ Client: `SYN-ACK (seq=y, ack=x+1)`; (3) Client $\rightarrow$ Server: `ACK (seq=x+1, ack=y+1)`.
• 4-Way Teardown: (1) Client $\rightarrow$ Server: `FIN`; (2) Server $\rightarrow$ Client: `ACK` (half-close); (3) Server $\rightarrow$ Client: `FIN`; (4) Client $\rightarrow$ Server: `ACK` (Client waits $2\text{ MSL}$ in `TIME_WAIT` before closing).
Q3. Explain TCP Congestion Control mechanisms: Slow Start, Congestion Avoidance, Fast Retransmit, and Fast Recovery. (10 Marks)
• Slow Start: Exponential growth: $\text{cwnd} \leftarrow \text{cwnd} \times 2$ per RTT until reaching $\text{ssthresh}$.
• Congestion Avoidance: Additive linear growth: $\text{cwnd} \leftarrow \text{cwnd} + 1\text{ MSS}$ per RTT.
• Fast Retransmit: 3 duplicate ACKs trigger immediate retransmission without waiting for RTO timeout.
• Fast Recovery: Multiplicative decrease: $\text{ssthresh} = \text{cwnd}/2$, sets $\text{cwnd} = \text{ssthresh} + 3\text{ MSS}$, continues congestion avoidance.
Q4. Compare Distance Vector (Bellman-Ford) and Link State (Dijkstra) routing algorithms. How is Count-to-Infinity solved? (8 Marks)
• Distance Vector: Periodic routing table exchange with neighbors only; slow convergence; suffers Count-to-Infinity. Solved by Split Horizon (do not advertise route back to neighbor who supplied it) and Poison Reverse (advertise cost as $\infty$).
• Link State: Floods Link State Advertisements (LSAs) to all routers; builds global topology map; runs Dijkstra's algorithm; zero routing loops!
Q5. Compare HTTP/1.1, HTTP/2, and HTTP/3 QUIC across multiplexing, transport layer, and Head-of-Line blocking. (8 Marks)
• HTTP/1.1 (TCP): Sequential requests per socket; application Head-of-Line (HoL) blocking.
• HTTP/2 (TCP): Binary multiplexed streams over single TCP connection; single packet drop stalls all streams (TCP HoL blocking).
• HTTP/3 (QUIC/UDP): Native multiplexed streams over UDP; packet drop in stream 1 never delays stream 2 (Zero HoL blocking!).

Topic 52.2: Comprehensive Network Layer & Transport Layer Solved Numericals

🏛️ Solved Numerical 1: Dijkstra's Link State Shortest Path Algorithm Trace

Find the shortest paths from source router $A$ to all nodes in network graph:

Execution Trace Table:

StepVisited Set $N'$$D(B), p(B)$$D(C), p(C)$$D(D), p(D)$$D(E), p(E)$
0$\{A\}$$2, A$$5, A$$\infty$$\infty$
1$\{A, B\}$2, A$4, B$$6, B$$\infty$
2$\{A, B, C\}$2, A4, B$5, C$$9, C$
3$\{A, B, C, D\}$2, A4, B5, C$6, D$
4$\{A, B, C, D, E\}$2, A4, B5, C6, D

Shortest Paths from $A$: to $B = 2$, to $C = 4$ ($A \rightarrow B \rightarrow C$), to $D = 5$ ($A \rightarrow B \rightarrow C \rightarrow D$), to $E = 6$ ($A \rightarrow B \rightarrow C \rightarrow D \rightarrow E$).

🏛️ Solved Numerical 2: TCP AIMD Congestion Window Evolution

A TCP Reno connection has $\text{ssthresh} = 16\text{ MSS}$. It starts in Slow Start ($\text{cwnd} = 1$). Trace $\text{cwnd}$ over successive RTTs until a timeout occurs at $\text{cwnd} = 20$, followed by 3 duplicate ACKs at $\text{cwnd} = 12$:

  1. RTT 1–5 (Slow Start): $\text{cwnd}$ doubles: $1 \rightarrow 2 \rightarrow 4 \rightarrow 8 \rightarrow 16\text{ MSS}$ (Reaches $\text{ssthresh}$).
  2. RTT 6–9 (Congestion Avoidance): Linear growth: $17 \rightarrow 18 \rightarrow 19 \rightarrow 20\text{ MSS}$.
  3. Timeout at $\text{cwnd} = 20$: Sets $\text{ssthresh} \leftarrow 20/2 = 10\text{ MSS}$, resets $\text{cwnd} \leftarrow 1\text{ MSS}$, re-enters Slow Start.
  4. RTT 10–14: Doubles $1 \rightarrow 2 \rightarrow 4 \rightarrow 8 \rightarrow 10$ ($\text{ssthresh}$ reached), then linear: $11 \rightarrow 12\text{ MSS}$.
  5. 3 Duplicate ACKs at $\text{cwnd} = 12$: Fast Retransmit! Sets $\text{ssthresh} \leftarrow 12/2 = 6\text{ MSS}$, sets $\text{cwnd} \leftarrow 6 + 3 = 9\text{ MSS}$ in Fast Recovery!

Topic 52.3: Comprehensive Internetworking, BGP & Transport Internals

In global autonomous internetworking, routing is divided into **Intra-Domain Interior Gateway Protocols (IGP: OSPF, IS-IS)** and **Inter-Domain Exterior Gateway Protocols (EGP: BGP-4)**:

Routing Protocol Algorithm Family Underlying Transport Protocol Routing Metric & Domain
RIPv2 Distance Vector (Bellman-Ford) UDP (Port 520) Hop Count (Max = 15 hops; 16 = $\infty$); Small LANs.
OSPFv2 / OSPFv3 Link State (Dijkstra) Raw IP (Protocol 89) Cost = $\frac{10^8}{\text{Bandwidth (bps)}}$; Large Enterprise / Campus.
BGP-4 Path Vector TCP (Port 179) AS-Path list, Policy-based routing, Local Preference; Global Internet Core.
🏛️ Complete Step-by-Step Distance Vector Routing & Count-to-Infinity Trace

Consider 3 linear routers $A \leftrightarrow B \leftrightarrow C$ with unit link costs ($1$):

Remedies: (1) Split Horizon: $A$ never advertises its route to $C$ back to $B$. (2) Poison Reverse: $A$ advertises $D_A(C) = \infty$ to $B$.

🏛️ Step-by-Step Silly Window Syndrome Prevention: Nagle vs. Clark Algorithms

Silly Window Syndrome occurs when data is exchanged in tiny 1-byte segments (e.g. typing single characters in Telnet), causing a 40-byte TCP/IP header overhead for every single byte of payload:

Topic 52.4: Master University Solved Examination Numerical Bank

🏛️ Solved Numerical 3: Hierarchical CIDR Route Aggregation & Supernetting

A regional ISP router receives routing updates for four contiguous IP address blocks:

Route Aggregation (Supernetting) Solution:

Comparing the 3rd octets in binary: `00000000`, `00000001`, `00000010`, `00000011`. All 4 blocks share the identical first 22 bits (`11001000.00010000.000000xx`).

$$\mathbf{\text{Single Aggregated Supernet Route} = \mathbf{200.16.0.0/22} \quad (\text{Subnet Mask: } 255.255.252.0)}$$

Benefit: Replaces 4 independent routing table entries with 1 consolidated entry, reducing router BGP memory table size by $75\%$!

🏛️ Solved Numerical 4: TCP Maximum Throughput & Mathis Equation

A cross-continental $10\text{ Gbps}$ TCP link has an RTT of $100\text{ ms}$ and standard MSS of $1460\text{ bytes}$. If the packet loss rate is $p = 0.0001$ ($0.01\%$), calculate the maximum achievable TCP throughput according to the Mathis Formula.

Solution (Mathis Formula):

$$\mathbf{\text{Throughput} \le \frac{\text{MSS}}{\text{RTT}} \times \frac{1.22}{\sqrt{p}}}$$ $$\text{Throughput} \le \frac{1460 \times 8 \text{ bits}}{0.100\text{ s}} \times \frac{1.22}{\sqrt{0.0001}} = 116,800 \times \frac{1.22}{0.01} = 116,800 \times 122 = \mathbf{14,249,600 \text{ bps} \approx \mathbf{14.25 \text{ Mbps}}}$$

Critical Engineering Insight: Even on a $10\text{ Gbps}$ physical pipe, a tiny $0.01\%$ packet drop throttles standard TCP Reno throughput down to $14.25\text{ Mbps}$ due to aggressive AIMD window halving!

Topic 52.5: Comprehensive Transport State Machines & Variable Length Subnetting (VLSM)

🏛️ Solved Numerical 5: Complete Variable-Length Subnet Masking (VLSM) Design

An enterprise organization is assigned address block `172.16.0.0/16`. Design an optimal VLSM subnetting plan for 4 distinct departments:

VLSM Allocation Plan:

DepartmentHosts NeededBits Needed ($2^h - 2 \ge N$)Prefix MaskAssigned Network AddressUsable Host Range
Dept A4000$h=12 \ (4094)$$/20 \ (255.255.240.0)$`172.16.0.0/20``172.16.0.1 - 172.16.15.254`
Dept B2000$h=11 \ (2046)$$/21 \ (255.255.248.0)$`172.16.16.0/21``172.16.16.1 - 172.16.23.254`
Dept C1000$h=10 \ (1022)$$/22 \ (255.255.252.0)$`172.16.24.0/22``172.16.24.1 - 172.16.27.254`
Dept D500$h=9 \ (510)$$/23 \ (255.255.254.0)$`172.16.28.0/23``172.16.28.1 - 172.16.29.254`
🏛️ Step-by-Step TCP Jacobson's RTO Calculation Algorithm

Given initial $\text{SRTT} = 100\text{ ms}$, $\text{RTTVAR} = 10\text{ ms}$, and $\alpha = 0.125, \beta = 0.25$. If a new sample RTT measurement $R = 140\text{ ms}$ arrives, compute the updated Retransmission Timeout ($\text{RTO}$):

$$\text{Error } E = R - \text{SRTT} = 140 - 100 = \mathbf{+40 \text{ ms}}$$ $$\text{Updated SRTT} \leftarrow \text{SRTT} + \alpha \times E = 100 + 0.125(40) = 100 + 5 = \mathbf{105 \text{ ms}}$$ $$\text{Updated RTTVAR} \leftarrow \text{RTTVAR} + \beta \times (|E| - \text{RTTVAR}) = 10 + 0.25(40 - 10) = 10 + 7.5 = \mathbf{17.5 \text{ ms}}$$ $$\mathbf{\text{New RTO} = \text{SRTT} + 4 \times \text{RTTVAR} = 105 + 4(17.5) = 105 + 70 = \mathbf{175 \text{ ms}}}$$
🏛️ Solved Numerical 6: Bellman-Ford Distance Vector Calculation with Routing Table Updates

Given 4 routers $A, B, C, D$. Router $B$ has direct neighbor costs: $c(B, A) = 3, c(B, C) = 1, c(B, D) = 6$. $B$ receives distance vectors from $A$ and $C$:

Update $B$'s routing table for destination $D$ using Bellman-Ford: $D_B(D) = \min \{ c(B, A) + D_A(D), \ c(B, C) + D_C(D), \ c(B, D) \}$.

$$\text{Via } A: 3 + 2 = 5$$ $$\text{Via } C: 1 + 3 = 4$$ $$\text{Direct } D: 6$$ $$\mathbf{D_B(D) = \min(5, 4, 6) = \mathbf{4 \quad (\text{Next Hop: Router } C)}}$$
Q6. Compare IPv4 and IPv6 across address space, header size, fragmentation, checksum, and security. (10 Marks)
• Address Space: IPv4 has 32-bit addresses ($4.3 \times 10^9$); IPv6 has 128-bit addresses ($3.4 \times 10^{38}$).
• Header Size: IPv4 is variable ($20\text{--}60\text{ B}$); IPv6 has a fixed $40\text{-byte}$ base header with chained Extension Headers.
• Fragmentation: IPv4 routers perform fragmentation; in IPv6, ONLY the source host fragments packets (Path MTU Discovery).
• Header Checksum: IPv4 recomputes checksum at every hop; IPv6 eliminates header checksum to maximize router forwarding speed.
• Security: IPsec is optional add-on in IPv4; IPsec support is built natively into the core IPv6 protocol specification!
Q7. Explain Address Resolution Protocol (ARP), ARP Request (Broadcast), ARP Reply (Unicast), and ARP Cache Poisoning. (8 Marks)
• ARP: Maps a known Layer 3 logical IP address to an unknown Layer 2 physical MAC address on the local subnet.
• ARP Request: Broadcast frame (`FF:FF:FF:FF:FF:FF`) asking: *"Who has IP X.X.X.X? Tell MAC Y."*
• ARP Reply: Unicast frame from the target host stating: *"I have IP X.X.X.X, my MAC is Z."*
• ARP Poisoning (Spoofing): An attacker sends gratuitous fake ARP replies associating the gateway's IP with the attacker's MAC, enabling Man-in-the-Middle (MitM) packet sniffing!

Topic 52.6: Advanced TCP State Transition Machine & Congestion Control Math

CLOSED SYN_SENT ESTABLISHED FIN_WAIT_1/2 TIME_WAIT
Figure 5.2: The Classical TCP Client Connection Lifetime State Machine
🏛️ Step-by-Step Solved Problem: Variable Length Subnet Masking (VLSM) Enterprise Plan

An enterprise is allocated IP address block `10.0.0.0/16`. Subnet the block for: (1) Head Office: 10,000 hosts, (2) Branch 1: 5,000 hosts, (3) Branch 2: 2,000 hosts, (4) Branch 3: 1,000 hosts, (5) Five WAN point-to-point links (2 hosts each).

Efficiency: 100% zero address collisions with over $40,000$ IP addresses preserved for future organizational growth!