Enlarged Diagram
Interactive Study Environment β€’ APJ Abdul Kalam Technological University
KTU 2024 SCHEME 6 CONTACT HOURS THEORY MASTERCLASS

Module 1: Introduction and Application Layer

A textbook-rigorous, examination-focused interactive guide designed to teach you every single concept from absolute zero, explain every diagram from the PDF notes, and train you to write flawless 3-mark, 6-mark, and 9-mark KTU examination answers.

49 Pages
Official PDF Notes Synthesized
61 Figures
High-Res Diagrams with Draw Guides
100% Theory
Hands-on Excluded (As Per KTU)
10 Parts
Step-by-Step Learning Progression
OFFICIAL UNIVERSITY NOTES ORIGINAL EMBEDDED PDF

CN Module 1.pdf (49 Pages)

β†— Open in New Window ⬇ Download PDF

Scroll and read through your original 49-page lecture notes directly below, or reference them alongside each interactive concept in the study guide.

PART 01 HIGH PRIORITY β€’ 3M / 6M

Overview of the Internet, Networks & Switching

PDF Pages: 1 – 4
πŸ’‘ What You Are Learning & Why It Matters

Before diving into protocols, we must understand the fundamental physical and logical anatomy of the Internet: what constitutes a network, how hosts connect via LANs and WANs, why switching is required, how circuit and packet switching operate, and how Internet Service Providers (ISPs) form the global backbone.

1. Basic Explanation: What is a Network & The Internet?

A network is an interconnection of a set of devices capable of communication. A device can be a host (end system such as a computer, laptop, smartphone, server, or security camera) or a connecting device (router, switch, or modem).

The Internet (short for internetwork) is literally a "network of networks." Billions of heterogeneous computing devices worldwide communicate across transmission media (wired cables like twisted-pair, coaxial, and optical fiber, or wireless media like radio and microwave).

Overview of the Internet and Networks
Figure 1.1: The Internet as an Internetwork of Interconnected Devices (Page 1)
Exam Drawing Tip: Show end-systems (hosts) on the edge connected to connecting devices (switches, routers) in the core, joined by transmission media.

2. Technical Categories of Networks: LAN vs. WAN

Computer networks are fundamentally categorized based on their geographic span, ownership, and connectivity topology:

Parameter Local Area Network (LAN) Wide Area Network (WAN)
Geographical Span Confined to a single office, building, or campus (a few meters to a kilometer). Spans a town, city, state, country, or the entire globe.
What It Interconnects Directly interconnects hosts (end systems). Interconnects connecting devices (switches, routers, modems).
Ownership Privately owned by an individual or organization. Created and operated by communication companies (telecoms/ISPs) and leased.
Internal Types Common bus/cable (historic) or Link-layer switched (modern). Point-to-Point WAN or Switched WAN.
Addressing Each host has a unique link-layer hardware address (Physical / MAC address). Hierarchical logical addressing (IP addresses and WAN link identifiers).
Data Rates & Delay High data rates (typically 100 Mbps to 10 Gbps) and very low propagation delay. Lower data rates compared to LANs and significant propagation delays.
Local Area Network (LAN)
Figure 1.2: Modern Switched LAN Architecture (Page 1)

A link-layer switch forwards packets only to the intended destination host based on its destination MAC address, preventing collisions and enabling multiple pairs of hosts to communicate simultaneously.

Point-to-Point WAN
Figure 1.3: Point-to-Point WAN (Page 2)

Connects exactly two connecting devices via a dedicated transmission medium (cable or air) with no intermediate switches.

Switched WAN
Figure 1.4: Switched WAN with Multiple Ends (Page 2)
Key Concept: A switched WAN consists of multiple point-to-point links joined by internal switches, forming a multi-point backbone capable of routing data across vast geographical distances.

3. Internetwork (Internet) & Connecting Topology

When two or more independent networks (such as two office LANs) are joined together, they form an internetwork. For instance, two office LANs can be interconnected using routers (R1 and R2) across a leased point-to-point WAN.

Two LANs connected by WAN
Figure 1.5: Private Internetwork Connecting Two LANs via Routers (Page 2)
πŸ“ High-Frequency KTU Formula: Full-Mesh WAN Links

If \(n\) independent LANs must be connected directly in pairs using dedicated point-to-point WAN links, the number of point-to-point WAN links \(W\) required is given by the combination formula:

\[W = \frac{n(n - 1)}{2}\]

Example: To connect 5 LANs in a full mesh requires \(W = \frac{5 \times 4}{2} = 10\) leased WAN lines. Because this scales quadratically as \(O(n^2)\), full-mesh connectivity is economically prohibitive. Therefore, networks are connected through switched backbones and routers.

Mesh of LANs and WANs
Figure 1.6: Heterogeneous Internetwork with Routers and Switched WAN (Page 2)

4. Switching: Circuit-Switched vs. Packet-Switched Networks

A switch connects two or more transmission links and forwards data between them. The two foundational switching paradigms are:

Feature Circuit-Switched Network Packet-Switched Network
Connection Setup Mandatory dedicated physical path set up before data transfer begins. No pre-allocated dedicated circuit; data is broken into independent packets.
Resource Reservation Full bandwidth is reserved for the duration of the call, even during silence. Resources allocated on demand (statistical multiplexing / store-and-forward).
Packet Routing All bits follow the exact same pre-allocated physical path. Datagram network: packets routed independently;
Virtual-circuit network: logical path followed.
Efficiency Low bandwidth efficiency (wasted during idle periods). High efficiency; bandwidth shared dynamically among many active users.
Delays High setup delay, but zero queuing delay during active transfer. Zero setup delay (in datagrams), but variable queuing and transmission delays.
Example Traditional Public Switched Telephone Network (PSTN). The Internet (IP network).
Circuit Switched Network
Figure 1.7: Circuit-Switched Network (Page 3)
Packet Switched Network
Figure 1.8: Packet-Switched Network (Page 3)

Datagram Networks vs. Virtual-Circuit Networks

5. Structure of the Internet: ISP Hierarchy & Access Networks

The global Internet is organized as a multi-tier hierarchy of Internet Service Providers (ISPs):

ISP Hierarchy and Peering Points
Figure 1.9: Multi-Tier ISP Architecture and Peering Points (Page 4)

Access Technologies (Connecting to the ISP)

πŸ“ KTU Examination Model Questions & Answers (Part 1)

Model Answer:

  1. Span: LAN covers a small geographic area (office, single building, campus), whereas WAN spans a town, state, country, or the world.
  2. Interconnection: LAN interconnects hosts (end-systems) directly, whereas WAN interconnects connecting devices (switches, routers, modems).
  3. Ownership: LAN is privately owned and maintained by an organization; WAN is created and maintained by telecommunication providers and leased to customers.

Solution:

Given number of nodes \(n = 6\).
Formula for full mesh point-to-point links: \[W = \frac{n(n - 1)}{2} = \frac{6 \times (6 - 1)}{2} = \frac{30}{2} = 15 \text{ links.}\] Therefore, 15 dedicated point-to-point WAN lines are required.

PART 02 VERY HIGH PRIORITY β€’ 5M / 9M ESSAY

Protocol Layering & The TCP/IP Protocol Suite

PDF Pages: 5 – 12
πŸ’‘ Why Layering? The Foundation of Computer Networks

In a large network with millions of diverse computers, communication is immensely complex. Layering breaks this massive task into small, modular, independent layers. Each layer handles a single well-defined responsibility and offers services to the layer above it.

1. Principles & Scenario of Protocol Layering

Consider the classic Maria and Ann scenario: Maria in India wants to send an encrypted confidential letter to Ann in America.

Maria and Ann Layering Analogy
Figure 2.1: Maria and Ann Three-Layer Communication Analogy (Page 5)
Logical vs Physical Communication
Figure 2.2: Logical Connections (Dotted) vs Real Path (Solid) (Page 5)
⭐ Two Fundamental Principles of Protocol Layering
  1. Bidirectional Communication: If we want bidirectional communication, each layer at the sender must perform the exact inverse operation of the corresponding layer at the receiver.
  2. Identical Objects: The two objects under each layer at both communication endpoints must be identical. For example, below Layer 3 is plaintext, below Layer 2 is ciphertext, and below Layer 1 is the physical parcel.

2. The Five-Layer TCP/IP Protocol Suite

The original TCP/IP protocol suite defined a 4-layer architecture (RFC 1122: Link, Network, Transport, Application). Modern textbooks (Forouzan) present the standard five-layer model:

TCP/IP 4-layer vs 5-layer model
Figure 2.3: (a) Original 4-Layer TCP/IP Architecture vs (b) Modern 5-Layer Model (Page 6)
Layer Protocol Data Unit (PDU) Primary Responsibilities Key Protocols
5. Application Layer Message Provides network services directly to user applications; handles high-level user communication. HTTP, SMTP, FTP, TELNET, SSH, SNMP, DNS, IGMP
4. Transport Layer Segment (TCP) / User Datagram (UDP) Process-to-process logical communication, error control, flow control, and port addressing. TCP, UDP, SCTP
3. Network Layer Datagram / Packet Host-to-host communication, logical addressing (IP), packet routing, and forwarding across networks. IPv4, IPv6, ICMP, IGMP, OSPF, BGP
2. Data Link Layer Frame Node-to-node (hop-to-hop) frame delivery across a single physical link, physical/MAC addressing, error detection. Ethernet (802.3), Wi-Fi (802.11), PPP, ARP
1. Physical Layer Bits Transmits individual raw bits over a physical transmission medium (electrical voltages, light pulses, or radio waves). RS-232, 1000BASE-T, DSL, Fiber optics

Comprehensive Table: Protocols and Their Uses (PDF Page 8)

ProtocolLayerStandard Purpose & Use
HTTPApplicationAccessing the World Wide Web and web documents.
SMTPApplicationTransferring electronic mail between mail servers.
FTPApplicationInteractive file transfer between client and server.
TELNET / SSHApplicationRemote terminal access and secure shell login.
SNMPApplicationNetwork management and monitoring of network devices.
DNSApplicationFinding the network-layer IP address from a human-readable domain name.
TCPTransportConnection-oriented, reliable, byte-stream transmission with flow and congestion control.
UDPTransportConnectionless, lightweight, low-overhead transport (DNS, VoIP, video streaming).
SCTPTransportStream Control Transmission Protocol; supports multi-streaming and multi-homing.
IP (IPv4 / IPv6)NetworkBest-effort, connectionless host-to-host packet delivery and logical addressing.
ICMPNetworkInternet Control Message Protocol; error reporting and network diagnostics (e.g., ping).
IGMPNetworkInternet Group Management Protocol; manages multicast group membership.

3. Layers in Network Devices & End-to-End vs. Hop-to-Hop

Not all devices implement all five layers:

Layers implemented in devices
Figure 2.4: Layers in Hosts (5), Routers (3), and Switches (2) (Page 6)
End-to-End vs Hop-to-Hop
Figure 2.5: End-to-End (Top 3) vs Hop-to-Hop (Bottom 2) (Page 7)
Identical Objects below layers
Figure 2.6: PDUs Below Each Layer: Message, Segment, Datagram, Frame, Bits (Page 7)

4. Encapsulation and Decapsulation Journey

As user data moves down the protocol stack at the sender, each layer prepends a protocol header (and sometimes a trailer). This is called encapsulation. At the destination, each layer strips its header moving up the stack. This is called decapsulation.

Encapsulation and Decapsulation Journey
Figure 2.7: Encapsulation at Host A, Router Hop Replacement, and Decapsulation at Host B (Page 9)
Crucial KTU Exam Point: When a packet passes through an intermediate router, the router decapsulates the data link frame up to the network layer, checks the destination IP address to choose the outgoing interface, and then re-encapsulates the datagram into a brand-new data link frame with new source and destination MAC addresses!

5. Addressing at Different Layers

To successfully deliver data across the Internet, four levels of addresses are used:

Addressing at Each TCP/IP Layer
Figure 2.8: Four Levels of Addresses in the TCP/IP Architecture (Page 10)
Layer Address Type Bit Size Example Scope & Purpose
Application Specific Address Variable text user@example.com, www.ktu.edu.in Human-friendly identifiers for services or users.
Transport Port Address 16 bits (0 to 65535) Port 80 (HTTP), Port 25 (SMTP) Identifies the specific sending or receiving process on a host.
Network Logical / IP Address 32 bits (IPv4) / 128 bits (IPv6) 192.168.1.1, 142.250.190.46 Globally identifies a host or interface across the entire Internet.
Data Link Physical address / MAC Address 48 bits (6 bytes hex) 00:1A:2B:3C:4D:5E Identifies the Network Interface Card (NIC) within a local network hop.

6. Multiplexing, Demultiplexing & OSI Comparison

Multiplexing: At the sender, a lower-layer protocol (like IP) can encapsulate packets coming from multiple higher-layer protocols (TCP, UDP, ICMP) one at a time.
Demultiplexing: At the receiver, a protocol decapsulates packets and delivers them to the correct higher-layer protocol based on protocol ID or port numbers.

Multiplexing and Demultiplexing
Figure 2.9: Multiplexing at Sender and Demultiplexing at Receiver (Page 11)
OSI 7-Layer Model
Figure 2.10: The ISO-OSI 7-Layer Reference Model (Page 11)
OSI vs TCP/IP Mapping
Figure 2.11: Direct Comparison: OSI 7-Layer vs. TCP/IP 5-Layer Model (Page 12)
Why TCP/IP merged Presentation & Session into Application: The designers of TCP/IP felt that presentation functions (encryption, compression, encoding) and session management (dialogue control, checkpoints) are best implemented inside individual application programs when needed, rather than adding two separate protocol layers that introduce processing overhead for every simple network transaction.
πŸ›οΈ The OSI 7-Layer Model: Functions of Session and Presentation Layers

The International Organization for Standardization (ISO) created the Open Systems Interconnection (OSI) 7-layer reference model. The two layers in OSI that are merged into the Application layer in TCP/IP are:

  • Presentation Layer (Layer 6): Concerned with the syntax and semantics of the information exchanged. Responsible for:
    1. Translation: Converting character encodings between different computer systems (e.g., EBCDIC to ASCII).
    2. Encryption & Decryption: Ensuring privacy and confidentiality of sensitive data during transit.
    3. Compression: Reducing the number of bits in multimedia streams to optimize link bandwidth.
  • Session Layer (Layer 5): Establishes, manages, and terminates dialogues between communicating applications. Responsible for:
    1. Dialog Control: Determines whether communication is half-duplex (two-way alternate) or full-duplex (two-way simultaneous).
    2. Synchronization & Checkpointing: Inserts checkpoints into long data streams. If a 2-hour file transfer crashes at minute 50, the session layer allows retransmission to resume from the last valid checkpoint rather than restarting from the beginning.
⚠️ Why Did the OSI Model Fail in Practice? (Why OSI was Not Successful)

Although the OSI model is widely studied as a theoretical teaching reference, it never achieved widespread commercial deployment over TCP/IP due to three primary historical reasons:

  1. Bad Timing: The OSI standards were finalized in the late 1970s and 1980s. It was completed when TCP/IP was fully in place; changing would cost too much. Organizations had already invested billions in TCP/IP infrastructure, and replacing it would cost too much.
  2. Flawed Technology & Redundancy: Some layers (Session and Presentation) were never fully defined or needed separate software protocols, while functions like flow control, error checking, and addressing were needlessly duplicated across multiple layers (Transport and Data Link).
  3. Poor Initial Implementations: Early software implementations of OSI protocols were complex, bulky, and noticeably slower compared to the lean, modular UNIX implementations of the TCP/IP stack.
πŸ“ KTU Examination Essay Answer (9 Marks)

Question: Explain the layered architecture of the TCP/IP protocol suite with a neat diagram. State the function of each layer and the data unit handled at each layer. [KTU Part B High-Frequency]

Structure to secure full 9/9 marks:

  1. Introduction (1 Mark): Define TCP/IP as a hierarchical 5-layer protocol suite developed before OSI, serving as the communication protocol for the Internet.
  2. Neat Architecture Diagram (2 Marks): Draw the 5 layers vertically (Application, Transport, Network, Data Link, Physical) showing data flow and PDUs.
  3. Layer Functions & PDUs (5 Marks - 1 mark per layer):
    • Application Layer (PDU: Message): User interface, protocol examples (HTTP, SMTP, DNS, FTP).
    • Transport Layer (PDU: Segment/Datagram): Process-to-process delivery, port addressing, TCP (connection-oriented, reliable) and UDP (connectionless).
    • Network Layer (PDU: Datagram): Host-to-host routing, logical IP addressing, routing protocols.
    • Data Link Layer (PDU: Frame): Hop-to-hop frame delivery, physical MAC addressing, error detection.
    • Physical Layer (PDU: Bits): Bit transmission over physical media, signal encoding, hardware connectors.
  4. Addressing Scheme Summary (1 Mark): State the 4 addressing levels (Specific, Port, Logical, Physical address).
PART 03 CORE THEORY β€’ 3M / 5M

Application-Layer Paradigms & Socket Concept

PDF Pages: 13 – 16
πŸ’‘ What is the Application Layer?

The Application Layer is the top layer in the TCP/IP suite. It is the only layer that directly interacts with the end-user. All four lower layers (Transport, Network, Data Link, Physical) exist solely to provide end-to-end communication services to the Application Layer.

1. Client-Server Paradigm vs. Peer-to-Peer Paradigm

Modern network applications are built following two major architectural paradigms:

Client-Server Paradigm
Figure 3.1: The Traditional Client-Server Paradigm (Page 13)
Peer-to-Peer Paradigm
Figure 3.2: The Peer-to-Peer (P2P) Paradigm (Page 14)
Feature Client-Server Paradigm Peer-to-Peer (P2P) Paradigm
Architecture Centralized. Clear distinction between service requester (client) and service provider (server). Decentralized. Nodes (peers) have equal capabilities and responsibilities.
Server Uptime Server must run continuously (24/7) with a fixed, well-known IP address. No central server runs all the time; peers join and leave dynamically (churn).
Role of Nodes Client only requests service; Server only provides service. A peer can provide service at one moment and receive service at another, or do both simultaneously.
Scalability Bottleneck at high loads; scaling requires massive data centers and load balancers. Self-scaling: as new peers arrive to download, they also bring upload bandwidth capacity.
Single Point of Failure Yes. If the central server crashes, the entire service becomes unavailable. No single point of failure; resilient to individual peer failures.
Examples World Wide Web (HTTP), Email (SMTP/POP3), FTP, DNS. BitTorrent, Gnutella, Blockchain (Bitcoin), VoIP (early Skype).

2. Application Programming Interface (API) & Sockets

How does an application program written by a software developer communicate with the operating system's networking stack? It uses an Application Programming Interface (API).

The standard API used across modern operating systems is the Socket Interface (first introduced in Berkeley UNIX / BSD Sockets).

Socket Interface between Application and OS
Figure 3.3: Socket Interface Between Application Layer and OS Transport Layer (Page 15)
πŸ”‘ What is a Socket?

A socket is a software abstraction that acts as a door or endpoint for communication between a user application process and the network protocol stack. To send data, the process pushes bytes through its socket door; to receive data, it reads bytes from the socket door.

Client-Server Socket Communication
Figure 3.4: Sockets Used by Client and Server Processes (Page 15)
Socket Address Composition
Figure 3.5: Composition of a Socket Address (Page 15)
⭐ Definition: Socket Address (KTU 3-Mark Essential)

A Socket Address is the unique combination of an IP Address and a Port Number:

\[\text{Socket Address} = \text{IP Address} + \text{Port Number}\]

Example: 200.100.10.5:80 specifies that the packet is directed to the host at IP 200.100.10.5 and specifically to the Web Server process listening on Port 80.

3. Finding Socket Addresses (PDF Page 16)

For communication to occur, both the client process and the server process must obtain local and remote socket addresses:

Site Address Role How It Is Obtained
Server Local Socket Address The IP address is assigned to the server's network interface by the OS. Standard servers listen on well-known ports (e.g., HTTP = 80, SMTP = 25); other servers get a port designated by the system architect.
Server Remote Socket Address Extracted dynamically from the incoming client request packet headers (source IP and source port). It changes with each connecting client.
Client Local Socket Address The OS provides the local IP address. The port is a temporary, dynamically assigned ephemeral port number (range 49152–65535) unused by any other active client.
Client Remote Socket Address The server's port number is well known (e.g., 80). The server's IP address is resolved from its domain name using a DNS lookup.
PART 04 VERY HIGH PRIORITY β€’ 3M / 6M / 9M

World Wide Web (WWW) and HTTP Protocol

PDF Pages: 17 – 23
πŸ’‘ What is the World Wide Web & HTTP?

The World Wide Web (WWW) is a distributed client-server information service. Web pages distributed across millions of servers worldwide contain text, images, multimedia, and hyperlinks. HTTP (Hypertext Transfer Protocol) is the underlying application-layer protocol that powers the Web.

1. Web Architecture & Uniform Resource Locator (URL)

A Web client (browser) requests Web documents from a Web server using HTTP over a reliable TCP transport connection (default port 80). Each resource on the Web is uniquely addressed by a Uniform Resource Locator (URL):

WWW Client Server Architecture
Figure 4.1: Distributed Web Client-Server Architecture (Page 17)
HTTP Request and Response
Figure 4.2: HTTP Request-Response Transaction (Page 17)
URL Format
Figure 4.3: Uniform Resource Locator (URL) Structure (Page 18)
πŸ“Œ Anatomy of a URL: protocol://host[:port]/path
  • Protocol: The application-layer client-server protocol used (e.g., http, https, ftp).
  • Host: The domain name or IP address of the server holding the resource (e.g., www.mhhe.com).
  • Port (optional): The TCP port number where the server process is listening (default 80 for HTTP, 443 for HTTPS).
  • Path: The local file-path directory on the server identifying the specific file (e.g., /compsci/forouzan/chapter1.html).

2. Non-Persistent vs. Persistent HTTP Connections

HTTP operates over TCP. An HTML base document often references multiple embedded objects (e.g., 10 images). How these objects are fetched differentiates the two connection strategies:

Non-Persistent HTTP
Figure 4.4: Non-Persistent HTTP: Separate TCP Connection Per Object (Page 19)
Persistent HTTP
Figure 4.5: Persistent HTTP: Single TCP Connection for All Objects (Page 19)
Comparison Parameter Non-Persistent HTTP (HTTP/1.0) Persistent HTTP (HTTP/1.1)
TCP Connections A separate new TCP connection is opened and closed for every single object requested. A single TCP connection is kept open for the base HTML and all embedded objects.
Connection Overhead High server overhead; server must allocate buffers and TCP variables for each connection. Low server overhead; single TCP state maintained per client session.
Round-Trip Time (RTT) per Object Requires 2 RTTs per object (1 RTT for TCP 3-way handshake + 1 RTT for HTTP request/data). Without pipelining: 1 RTT per object after initial setup.
With pipelining: all objects requested back-to-back in ~1 RTT total!
Default in Protocols Default in HTTP/1.0. Default in HTTP/1.1 (header: Connection: keep-alive).
πŸ“ High-Frequency KTU Numerical: RTT Latency Comparison

Suppose a base HTML file contains references to \(N\) embedded images. Let \(\text{RTT}\) be the Round Trip Time between client and server, and assume object transmission time is negligible.

  • Non-Persistent HTTP Total Time:
    Base HTML requires \(2 \times \text{RTT}\). Each of the \(N\) images requires \(2 \times \text{RTT}\).
    \[T_{\text{non-persistent}} = 2 \times \text{RTT} + 2N \times \text{RTT} = 2(N + 1)\,\text{RTT}\]
  • Persistent HTTP (Without Pipelining):
    Base HTML setup + fetch takes \(2 \times \text{RTT}\). Each image is requested sequentially over the open connection taking \(1 \times \text{RTT}\) each.
    \[T_{\text{persistent, no-pipe}} = 2 \times \text{RTT} + N \times \text{RTT} = (N + 2)\,\text{RTT}\]
  • Persistent HTTP (With Pipelining):
    Base HTML takes \(2 \times \text{RTT}\). All \(N\) images are sent in one pipelined burst taking \(1 \times \text{RTT}\).
    \[T_{\text{persistent, pipe}} = 2 \times \text{RTT} + 1 \times \text{RTT} = 3\,\text{RTT}\]

Example: For \(N = 10\) images, Non-Persistent takes \(22\,\text{RTT}\), Persistent without pipelining takes \(12\,\text{RTT}\), and Persistent with pipelining takes only \(3\,\text{RTT}\)!

3. HTTP Message Formats & Methods

πŸ“œ HTTP Message Structure: Request Line and Status Line

Both HTTP Request and HTTP Response messages follow a standardized 4-part structure:

HTTP Request Message

  1. Request Line: Contains three fields separated by spaces: Method URL HTTP-Version (e.g., GET /index.html HTTP/1.1).
  2. Header Lines: Key-value pairs providing metadata (e.g., Host: www.example.com, User-Agent: Mozilla/5.0, Cookie: user_id=42 (Cookie header)).
  3. Blank Line: A carriage-return and line-feed (\r\n) marking the end of headers.
  4. Entity Body (Optional): Contains form input or payload data (used in POST and PUT).

HTTP Response Message

  1. Status Line: Contains three fields: HTTP-Version Status-Code Status-Phrase (e.g., HTTP/1.1 200 OK).
  2. Header Lines: Server metadata (e.g., Date: Sun, 22 Nov 2026, Server: Apache, Set-Cookie: session=xyz, Content-Length: 2048).
  3. Blank Line: A mandatory \r\n separating headers from body.
  4. Entity Body: The actual requested file or web content (HTML document, JPEG image).

HTTP is an ASCII-text based protocol. There are two kinds of messages: Request Messages and Response Messages.

HTTP Request Message Format
Figure 4.6: HTTP Request Message Format (Page 21)
HTTP Response Message Format
Figure 4.7: HTTP Response Message Format (Page 21)

HTTP Request Methods (PDF Page 20)

MethodAction PerformedSafe / Idempotent
GETRequests a document from the server. Carries no entity body.Safe & Idempotent
POSTSends user input/data (e.g., form data) in the body to be processed by server.Not Idempotent
HEADRequests only the header lines of the response without the entity body. (Used for testing/caching).Safe & Idempotent
PUTUploads a replacement document to the server at the specified URL.Idempotent
DELETERequests the deletion of the specified document from the server.Idempotent
OPTIONSInquires about available options and supported methods.Safe & Idempotent
TRACEEchoes back the received request for network path diagnostics.Safe & Idempotent
CONNECTReserved for SSL/TLS tunneling through proxy servers.Special

Comprehensive HTTP Request Headers (PDF Page 20)

Request HeaderStandard Meaning & Usage
User-agentIdentifies the client software / browser program.
AcceptSpecifies the media/MIME formats the client can accept (e.g., text/html).
Accept-charsetSpecifies the character sets accepted by client (e.g., UTF-8).
Accept-encodingSpecifies the compression schemes accepted (e.g., gzip, deflate).
Accept-languagePreferred natural language (e.g., en-US).
AuthorizationCarries credentials for authenticating client with server.
HostHost and port of the requested resource (mandatory in HTTP/1.1 for virtual hosting).
DateCurrent date and time of request generation.
UpgradeRequests switching to a newer or preferred protocol (e.g., HTTP/2, WebSocket).
CookieReturns a previously stored cookie to the server.
If-Modified-SinceUsed for conditional caching; requests document only if modified since date.

HTTP Status Codes (Response Message)

Code RangeCategoryCrucial KTU Exam Examples
1xxInformational100 Continue (Server received request headers, client can proceed).
2xxSuccessful200 OK (Request succeeded; document follows in entity body).
3xxRedirection301 Moved Permanently; 304 Not Modified (Cached copy is fresh!).
4xxClient Error400 Bad Request; 404 Not Found (Document does not exist).
5xxServer Error500 Internal Server Error; 503 Service Unavailable; 505 HTTP Version Not Supported (Overloaded).

4. Maintaining State: HTTP Cookies

HTTP is fundamentally a stateless protocol: the server does not retain information about earlier requests from the same client. To maintain state (e.g., shopping carts, login authentication, user preferences), Cookies are employed.

Cookie Creation and State Maintenance
Figure 4.8: Cookie Creation, Storage, and Tracking Across Sessions (Page 22)
4-Step Cookie Workflow:
  1. Client sends an initial HTTP request to the server without a cookie.
  2. Server generates a unique cookie ID, stores it in its database, and replies with header: Set-Cookie: 123456.
  3. Browser stores the cookie in its local cookie file indexed by server domain.
  4. On all subsequent visits to that server, browser includes header: Cookie: 123456, allowing server to identify the user.

5. Web Caching & Proxy Servers

A Proxy Server (Web Cache) is a network entity that satisfies HTTP requests on behalf of an origin Web server. It stores recent request-response pairs in local storage to reduce access latency, conserve enterprise bandwidth, and alleviate origin server load.

Proxy Server Architecture
Figure 4.9: Proxy Server Intercepting Client Requests (Page 23)
Conditional GET Workflow
Figure 4.10: Conditional GET with 304 Not Modified Response (Page 23)
⭐ Conditional GET: How Caches Keep Content Fresh

A proxy cache must verify that its cached copy has not become stale. It sends a Conditional GET request to the origin server containing the header:

If-Modified-Since: Wed, 21 Oct 2026 07:28:00 GMT

  • If NOT modified: Origin server returns 304 Not Modified with NO message body. Saves massive bandwidth!
  • If modified: Origin server sends 200 OK along with the updated document in the entity body.
PART 05 EXAM FAVORITE β€’ 3M / 5M

File Transfer Protocol (FTP)

PDF Pages: 24 – 26
πŸ’‘ Why is FTP Different from HTTP?

FTP is the standard client-server protocol used for transferring files between hosts. Unlike HTTP, which sends commands and files over the same connection, FTP establishes two separate connections between the client and server.

1. The Dual-Connection Architecture of FTP

FTP separates control commands from data transmission by using two distinct TCP connections:

FTP Dual Connection Architecture
Figure 5.1: FTP Architecture: Control Connection (21) and Data Connection (20) (Page 26)
Exam Drawing Requirement: Clearly draw the Client side with 3 boxes (User Interface, Control Process, Data Transfer Process) and the Server side with 2 boxes (Control Process, Data Transfer Process). Connect the two Control Processes with a line labeled Control Connection (Port 21) and the two Data Transfer Processes with a line labeled Data Connection (Port 20).
⭐ Out-of-Band Control vs. In-Band Control (KTU 3-Mark Question)

Because FTP sends its control information (commands and replies) over a separate TCP connection from the data, FTP is said to send its control information out-of-band.

In contrast, protocols like HTTP and SMTP send their request headers and data over the exact same TCP connection; therefore, HTTP and SMTP use in-band control.

2. Active Mode vs. Passive Mode in FTP

πŸ”Œ Active Mode vs. Passive Mode: The PORT and PASV Commands

Because firewalls and NAT routers block unsolicited incoming connections, FTP supports two distinct operating modes:

  • Active Mode (PORT command):
    1. Client initiates control connection to server port 21 from ephemeral port \(C\).
    2. When a file transfer is required, client opens a listening ephemeral port \(D\) and transmits its IP and port to the server using the PORT command (e.g., PORT 192,168,1,5,19,136 where port = \(19 \times 256 + 136 = 5000\)).
    3. The server initiates an active open from its standard port 20 to the client's port \(D\). (Often blocked by client-side firewalls!)
  • Passive Mode (PASV command):
    1. Client sends the PASV command to the server over the control connection.
    2. Server opens a dynamic ephemeral port \(S\) and replies with its IP address and port number.
    3. The client initiates the data connection from its own ephemeral port to the server's port \(S\). This resolves firewall issues because the client initiates both connections.
Parameter Active Mode (Default) Passive Mode (PASV)
Who Initiates Data Conn? The Server initiates the connection to the client. The Client initiates the connection to the server.
Command Sent Client sends PORT h1,h2,h3,h4,p1,p2 telling server its IP and port. Client sends PASV; server replies with its listening IP and port.
Firewall Friendliness Poor. Client firewalls frequently block incoming server connections. Excellent. Firewalls allow outbound client connections.

3. Comprehensive FTP Commands (PDF Pages 24 – 25)

CommandArgumentDescription
USERUser IDIdentifies user for authentication.
PASSPasswordSends password for authentication.
ACCTAccount infoSends account information if needed.
RETRRemote FilenameRetrieve (Download) a file from server to client.
STORRemote FilenameStore (Upload) a file from client to server.
APPERemote FilenameAppend data to an existing file on server.
LISTDirectory PathRequests directory listing over data connection.
NLSTDirectory PathReturns simple list of filenames without details.
CDUPNoneChange to parent directory on server.
CWDDirectory PathChange working directory.
PWDNonePrint current working directory path.
DELEFilenameDelete specified file on server.
RNFR / RNTOFilenameRename file from (RNFR) / Rename to (RNTO).
ABORNoneAbort previous FTP command and transfer.
PORTh1,h2,h3,h4,p1,p2Specifies client's IP and port for active data transfer.
PASVNoneRequests server to listen for passive connection.
TYPEA, E, I, LSets representation type (ASCII, EBCDIC, Image/Binary, Local).
STRUF, R, PSets file structure (File, Record, Page).
MODES, B, CSets transmission mode (Stream, Block, Compressed).
QUITNoneTerminates session and closes control connection.

FTP Status Reply Codes (PDF Page 25)

Every FTP command yields a 3-digit status code. The first digit reveals the general status:

Reply CodeDescriptionReply CodeDescription
125Data connection already open; transfer starting.250Requested file action okay, completed.
150File status okay; about to open data connection.331User name okay, password needed.
200Command okay.425Can't open data connection.
220Service ready for new user.530Not logged in.
221Service closing control connection (Logged out).550Requested action not taken; file unavailable.
226Closing data connection; requested file action successful.500Syntax error; command unrecognized.
PART 06 VERY HIGH PRIORITY β€’ 5M / 9M ESSAY

Electronic Mail (E-mail) Architecture & MIME

PDF Pages: 27 – 35
πŸ’‘ Why is E-mail Architecture Asynchronous?

Unlike HTTP or FTP where both parties are connected live, e-mail is an asynchronous store-and-forward system. The sender can send an e-mail when the receiver is offline. The message waits in intermediate mail servers until the recipient chooses to log in and retrieve it.

1. Email Architecture: The Three Core Components

An e-mail system is composed of three distinct functional agents:

Email Architecture Alice to Bob
Figure 6.1: Complete E-mail Architecture: Alice to Bob (Page 27)
Push vs Pull Protocols
Figure 6.2: Push Protocols (SMTP) vs Pull Protocols (POP3/IMAP) (Page 28)
⭐ Crucial KTU Distinction: Push vs. Pull Protocols

SMTP is a PUSH Protocol: The client sends (pushes) the message to the server.
POP3 and IMAP4 are PULL Protocols: The client retrieves (pulls) the message from the server mailbox.

2. SMTP (Simple Mail Transfer Protocol)

SMTP is the standard protocol for transferring mail reliably over TCP (port 25). It uses 7-bit NVT ASCII text format.

SMTP Three Mail Transfer Phases
Figure 6.3: The Three Phases of an SMTP Session (Page 30)

Comprehensive SMTP Commands (PDF Page 29)

KeywordArgumentDescription
HELO / EHLOSender's host domainIdentifies client to server (EHLO for Extended SMTP).
MAIL FROMSender email addressIdentifies message author and sender mailbox.
RCPT TORecipient email addressIdentifies intended recipient; repeated for multiple recipients.
DATANoneInitiates mail body input; terminated by line with single dot (<CRLF>.<CRLF>).
RSETNoneResets/aborts current mail transaction without closing connection.
VRFYUser / email nameVerifies recipient address without sending mail.
NOOPNoneNo operation; checks if connection is alive.
TURNNoneReverses roles of client and server.
EXPNMailing list nameExpands mailing list membership.
HELPCommand nameRequests documentation on specific command.
QUITNoneTerminates SMTP session and closes connection.

The Three Phases of SMTP:

  1. Connection Establishment: Client connects to server port 25. Server responds with 220 Service Ready. Client introduces itself: HELO client.domain.com. Server replies 250 OK.
  2. Mail Transfer: Sender issues MAIL FROM: <alice@domain.com>. Server replies 250 OK. Sender issues RCPT TO: <bob@domain.com>. Server replies 250 OK. Sender issues DATA. Server replies 354 Start mail input; end with <CRLF>.<CRLF>. Client transmits headers, blank line, body text, and ends with a single period . on a line by itself. Server: 250 OK.
  3. Connection Termination: Client issues QUIT. Server replies 221 Service closing transmission channel.

3. Mail Access Protocols: POP3 vs. IMAP4

πŸ“₯ POP3 Operating Modes: Download-and-Delete vs. Download-and-Keep

Post Office Protocol version 3 (POP3) operates in two distinct user modes:

  • Download-and-Delete Mode (Download and delete): The client downloads all messages from the mail server to the local computer and deletes them from the server mailbox.
    • Disadvantage: The user cannot read or access their emails from another device (e.g., office computer or mobile phone).
  • Download-and-Keep Mode (Download and keep): The client downloads copies of messages while leaving the originals on the server.
    • Disadvantage: Status changes (marking an email as read, moving to folders, or deleting) are NOT synchronized across devices. Every new device downloads all messages again as unread.
POP3 Connection Sequence
Figure 6.4: POP3 Session: Authorization, Transaction, Update (Page 31)
MIME Architecture
Figure 6.5: MIME Sits Between UA and SMTP System (Page 32)
POP3 Mode (PDF Page 31)BehaviorTypical Use Case
Delete Mode Mail is permanently deleted from the server mailbox after each successful retrieval. User works at a permanent, dedicated desktop computer and wants to free server space.
Keep Mode Mail stays preserved in the server mailbox after retrieval. User reads mail away from primary machine (e.g., laptop/phone) and will read again later.
FeaturePOP3 (Post Office Protocol v3)IMAP4 (Internet Message Access Protocol)
TCP PortPort 110Port 143
Operating PhilosophyOffline access: download and manage locally.Online / synchronized access: manage directly on server.
Folder ManagementNo server-side folder creation or hierarchy.Supports creating, renaming, and nesting folders on server.
Partial RetrievalMust download entire message including large attachments.Allows checking headers, searching content, and selective download.
Multi-Device SyncPoor; status changes on one device are not mirrored on others.Seamless synchronization across phone, laptop, and webmail.

4. MIME (Multipurpose Internet Mail Extensions)

Basic SMTP can only transmit 7-bit NVT ASCII text. It cannot send non-English characters (Malayalam, Hindi, Arabic, Chinese), images, audio, video, or executable binary files.

MIME transforms non-ASCII data into 7-bit NVT ASCII at the sender and reconstructs the original binary data at the receiver.

MIME Headers Placement
Figure 6.6: Five Essential MIME Header Fields in an Email (Page 32)

Five Essential MIME Headers:

MIME Content Types & Subtypes (PDF Page 33)

Top-Level TypeSubtypeDescription
TextplainUnformatted textual data.
htmlHypertext document with HTML formatting.
MultipartmixedIndependent body parts with different types sent together.
alternativeSame message in different formats (e.g., plain text and HTML).
parallelBody parts intended to be viewed simultaneously (e.g., audio and video).
digestEach body part is a complete RFC 822 mail message.
Messagerfc822Body is an encapsulated RFC 822 mail message.
partialBody is a fragment of a larger message split for transmission.
external-bodyBody contains a pointer/URL to an external resource.
Imagejpeg, gifStatic image in specified photographic format.
VideompegVideo stream in MPEG format.
AudiobasicSingle-channel audio encoded using 8-kHz \(\mu\)-law.
ApplicationpostscriptAdobe PostScript formatted file.
octet-streamGeneral uninterpreted 8-bit binary data (executables, zip).

Content-Transfer-Encoding Methods (PDF Page 33)

Encoding TypeDescription & Characteristics
7-bitStandard NVT ASCII characters with line lengths under 1000 characters.
8-bitNon-ASCII characters permitted with short lines, but not accepted by pure SMTP servers.
binaryArbitrary 8-bit characters with no line-length restrictions.
base64Encodes arbitrary binary data into 6-bit chunks mapped to 64 ASCII characters.
quoted-printableLeaves ASCII characters untouched; encodes non-ASCII bytes as =XX hex.

5. MIME Encoding Mechanisms & Numerical Calculations

Base64 Encoding Mechanism
Figure 6.7: Base64: 3 Bytes (24 bits) to 4 Characters (Page 33)
Quoted Printable Encoding
Figure 6.8: Quoted-Printable Encoding for Mostly-ASCII Data (Page 34)
πŸ“ High-Frequency KTU Numerical: Base64 Encoding Overhead

Base64 Mechanism: Takes 3 bytes of binary data (24 bits), divides them into four 6-bit chunks, and maps each 6-bit value (\(0 \text{ to } 63\)) to one of 64 printable ASCII characters (A–Z, a–z, 0–9, +, /). If input bytes are not a multiple of 3, padding character = is appended.

Overhead Formula: For \(B\) bytes of binary input, the encoded size is: \[\text{Size}_{\text{Base64}} = \lceil \frac{B}{3} \rceil \times 4 \text{ bytes}\] Data Overhead: Base64 incurs an overhead of: \[\frac{4 - 3}{3} \times 100\% = 33.33\% \text{ size increase.}\]

Quoted-Printable Encoding (Figure 6.8 from Notes)

Best for data that is mostly ASCII text with only a few non-ASCII special characters:

  • All printable standard ASCII characters are transmitted unmodified (1 byte).
  • Any non-ASCII byte (MSB = 1) is converted into three ASCII characters: an equals sign = followed by its 2-digit hexadecimal representation.
  • Example from PDF: The sequence 01001100 ('L'), 10011101 (hex 9D), and 00111001 ('9') is sent as L=9D9.
Email Security PGP and S/MIME
Figure 6.9: E-mail Security Using PGP or S/MIME (Page 35)
PART 07 VERY HIGH PRIORITY β€’ 3M / 6M / 9M

Domain Name System (DNS)

PDF Pages: 36 – 42
πŸ’‘ Why DNS is Essential

Humans prefer mnemonic domain names like www.google.com or www.ktu.edu.in, but network routers require numerical IP addresses like 142.250.190.46. The Domain Name System (DNS) is the Internet's globally distributed, hierarchical directory service that maps domain names to IP addresses.

1. Flat vs. Hierarchical Name Space & The DNS Tree

ParameterFlat Name SpaceHierarchical Name Space (DNS)
StructureSequence of characters with no internal structure or hierarchy.Divided into structured parts (labels) separated by dots.
ManagementMust be centralized to avoid duplicate names worldwide.Decentralized; authority is delegated to separate entities.
ScalabilityCannot scale to large networks (like the Internet).Extremely scalable; billions of unique names managed efficiently.
DNS Domain Name Space Tree
Figure 7.1: The Inverted Tree Hierarchy of Domain Name Space (Page 36)
Domain Name Construction
Figure 7.2: Construction of a Domain Name from Labels (Page 36)
⭐ FQDN vs. PQDN (KTU 3-Mark Question)
  • Fully Qualified Domain Name (FQDN): A complete domain name that terminates with a null label (a trailing dot .). It uniquely identifies a node from the root down.
    Example: challenger.atc.fhda.edu.
  • Partially Qualified Domain Name (PQDN): An incomplete domain name that does not end with a trailing dot. The local DNS resolver automatically appends the local default domain suffix to complete it.
    Example: challenger (in the fhda.edu department).

2. Domain vs. Zone & Name Server Hierarchy

A crucial distinction frequently asked in university exams:

ConceptDefinitionControl & Responsibility
Domain The entire subtree rooted at a particular node in the DNS tree. Represents the complete conceptual naming branch, including all sub-domains.
Zone The contiguous portion of the domain that a specific DNS server directly controls. If a server delegates administration of a sub-domain to another server, that sub-domain leaves its zone!
Hierarchy of DNS Servers
Figure 7.3: Hierarchy of DNS Servers (Root, Top-level domain [TLD], Authoritative) (Page 37)
Domain vs Zone Distinction
Figure 7.4: Comparison Between a Domain and a Zone (Page 38)

3. Name-Address Resolution: Recursive vs. Iterative

When a client program needs an IP address, its local stub resolver queries a DNS server using one of two resolution mechanisms:

Recursive Resolution
Figure 7.5: Recursive DNS Resolution (Page 39)
Iterative Resolution
Figure 7.6: Iterative DNS Resolution (Page 39)
ParameterRecursive ResolutionIterative Resolution
Who Contacts Next Server?The queried DNS server itself queries the next server on behalf of the client.The server replies with a referral (IP of next server), and the requester contacts it directly.
Workload on ServerHeavy workload on intermediate and root servers.Light workload on root and TLD servers.
Where It Is UsedBetween client host and Local DNS Server.Between Local DNS Server and Root / TLD / Authoritative servers.

4. DNS Message Format & Resource Records (RR)

DNS Message Format
Figure 7.7: DNS Query/Response Message Format (Page 41)
DNS Message Structure: A fixed 12-byte Header (Identification, Flags, Counts) followed by 4 variable-length sections: Question, Answer, Authoritative, and Additional records.

Common DNS Resource Record (RR) Types

TypeMeaningValue StoredExample Usage
A (Type A)IPv4 Address32-bit IPv4 address (Type A)example.com -> 93.184.216.34
AAAA (Type AAAA)IPv6 Address128-bit IPv6 address (Type AAAA quad-A)example.com -> 2606:2800:220:1::
CNAME (Type CNAME)Canonical NameTrue primary domain name (Type CNAME alias)www.example.com -> server1.example.com
NS (Type NS)Name ServerHost name of authoritative DNS server (Type NS)example.com -> ns1.example.com
MX (Type MX)Mail ExchangeHost name of mail server + priority (Type MX)example.com -> mail.example.com (Priority 10)
PTR (Type PTR)PointerDomain name for Reverse DNS (Type PTR)34.216.184.93.in-addr.arpa -> example.com
SOA (Type SOA)Start of AuthorityAuthoritative zone parameters (SOA record)serial number, refresh, retry, admin email

5. Dynamic DNS (DDNS) & Zone Transfers (PDF Page 42)

In traditional DNS, zone files are configured manually by network administrators. In modern networks where IP addresses are dynamically assigned by DHCP, manual updating is impossible.

PART 08 VERY HIGH PRIORITY β€’ 6M / 9M ESSAY

Peer-to-Peer (P2P) Networks & Chord DHT

PDF Pages: 43 – 46
πŸ’‘ What are P2P Overlay Networks?

In a Peer-to-Peer network, computers communicate directly without a centralized server. Peers form a logical application-layer network on top of the physical Internet, known as an overlay network.

πŸ›‘οΈ DNS Security (DNSSEC)

Traditional DNS queries travel over unencrypted UDP without authentication, making them vulnerable to DNS Spoofing, Cache Poisoning, and Query Flooding attacks. DNSSEC (DNS Security Extensions) provides:

  • Origin Authentication: Verifies that DNS response records originate from the genuine authoritative zone server.
  • Data Integrity: Uses public-key digital signatures (RRSIG records) to ensure responses have not been modified or corrupted in transit.

1. Evolution of P2P Architectures

Centralized Directory P2P
Figure 8.1: Centralized Directory P2P Network Architecture (Page 42)
πŸ” Unstructured P2P Networks & Query Flooding

In unstructured P2P networks (such as early Gnutella), peers connect randomly without a predefined overlay topology:

  • Query Flooding: When a peer searches for a file, it sends the request to all its directly connected neighbors. Each neighbor searches its local files and forwards the query to all its neighbors, continuing until a Time-To-Live (TTL) hop limit is reached.
  • Pros: Highly resilient to peer churn (nodes joining/leaving freely); requires no central index server.
  • Cons: Generates massive duplicate traffic (flooding storms); cannot guarantee finding rare files even if they exist in the network.

Comparison of Distributed Hash Table (DHT) Protocols

DHT ProtocolIdentifier SpaceRouting MechanismKey Location RuleProminent Application
ChordCircular identifier space (Identifier circle) (modulo \(2^m\))Finger Table (\(O(\log N)\) hops)Successor node of the key: \(\text{Successor}(\text{Key})\)Cooperative File System (CFS)
Pastry128-bit circular spacePrefix-based routing table + Leaf setNumerically closest live nodePAST storage utility
Kademlia160-bit space (SHA-1)Tree-based routing with \(k\)-buckets using XOR metric distance: \(d(x,y) = x \oplus y\)Node with minimal XOR distanceBitTorrent Mainline DHT, Ethereum

2. Structured P2P: The Chord Protocol & DHT

Chord uses a circular 1D identifier space of size \(2^m\) arranged in a logical ring modulo \(2^m\) (identifiers range from \(0\) to \(2^m - 1\)):

Chord Circular Address Space
Figure 8.2: Circular Identifier Space Modulo 2^m (Page 45)
Consistent Hashing Key Assignment
Figure 8.3: Key Assignment in Chord Ring: Key k14 Stored at Node N17 (Page 46)
πŸ“ High-Frequency KTU Topic: Chord Finger Tables & Routing

If each node only knows its immediate clockwise successor, routing a query takes \(O(N)\) linear hops. To achieve fast \(O(\log N)\) lookups, each node \(n\) maintains a routing table of \(m\) entries called a Finger Table.

The Finger Table Formula: The \(i\)-th entry in the finger table of node \(n\) is:

\[\text{Finger}[i] = \text{successor}\left((n + 2^{i - 1}) \bmod 2^m\right) \quad \text{for } i = 1, 2, \dots, m\]

Example: For \(m = 4\) (ring size 16), at Node \(N5\):

  • \(i = 1: (5 + 2^0) \bmod 16 = 6 \implies \text{successor}(6)\)
  • \(i = 2: (5 + 2^1) \bmod 16 = 7 \implies \text{successor}(7)\)
  • \(i = 3: (5 + 2^2) \bmod 16 = 9 \implies \text{successor}(9)\)
  • \(i = 4: (5 + 2^3) \bmod 16 = 13 \implies \text{successor}(13)\)

Lookup Routing: When looking up key \(k\), node \(n\) forwards the query to the closest predecessor of \(k\) in its finger table, halving the remaining distance to the target at each hop!

PART 09 EXAMINATION ESSAY β€’ 5M / 9M

Case Study: BitTorrent Protocol

PDF Pages: 47 – 48
πŸ’‘ What is BitTorrent?

BitTorrent is a wildly successful peer-to-peer file-distribution protocol designed by Bram Cohen. It divides large files into small chunks and uses clever game-theoretic incentives to encourage cooperation and eliminate free riders.

1. Core BitTorrent Terminology

TermMeaning & Technical Role
Torrent File (.torrent)A metadata file containing tracker URLs, piece sizes, and cryptographic SHA-1 hashes of all pieces.
TrackerA central coordinating entity that tracks which peers are currently participating in the torrent and gives new peers an initial peer list. (Does not touch file data!).
SwarmThe collective group of all peers actively downloading and uploading pieces of the same file.
SeedA peer that possesses the complete 100% file and continues uploading to other peers.
LeechA peer that has only a fraction of the pieces and is actively downloading the remainder.
Piece & BlockFile is split into pieces (typically 256 KB to 1 MB); each piece is further divided into blocks (typically 16 KB).
BitTorrent Swarm Architecture
Figure 9.1: BitTorrent Swarm: Tracker, Seeds (Peers 2 & 4), and Leechers (Page 47)

2. How a Peer Joins and Downloads a Torrent

  1. The user obtains the .torrent file from a Web server or magnet link.
  2. The BitTorrent client contacts the Tracker specified in the torrent file.
  3. The Tracker responds with a randomized list of IP addresses of active peers in the swarm.
  4. The client initiates direct TCP connections with peers from the list, discovering which pieces they have.
  5. The client downloads missing pieces while simultaneously uploading pieces it already owns to interested peers.
  6. Once all pieces are downloaded and cryptographically verified, the leecher becomes a Seed.

3. BitTorrent Policies for Fairness & Efficiency (PDF Page 48)

PolicyWorking Principle & Why It Is Used
Rarest-First Policy The peer always requests the pieces that are rarest (held by the fewest peers in the swarm).
Why: Rapidly replicates rare pieces so they don't become extinct if a seed leaves, and ensures peers have unique pieces they can trade with others.
Choking & Unchoking Each peer limits simultaneous upload connections (typically to ~4 peers) to avoid overloading bandwidth. Unchoked peers exchange data; choked peers are temporarily blocked.
Tit-for-Tat (TFT) Policy Peers unchoke the 4 peers that are currently sending data to them at the highest download rates. Peers that upload fast are rewarded with fast downloads. Prevents "free-riding"!
Optimistic Unchoking Every 30 seconds, a peer randomly unchokes one additional peer regardless of its upload rate.
Why: Allows new peers with zero pieces to bootstrap and download their first piece, and discovers if a random peer has better upload bandwidth.
Endgame Mode When the last few missing blocks remain, the peer requests them from all connected peers simultaneously to avoid waiting on a slow peer.
πŸ“¦ Anatomy of a .torrent File & Anti-Snubbing Policy
PART 10 EXAM MASTERCLASS β€’ NUMERICALS & QUESTION BANK

KTU Examination Masterclass & Solved Problems

PDF Pages: 49 – 50
πŸ“ Master Numerical 1: Protocol Header Overhead & Efficiency (KTU 3M / 4M)

Problem: An application on a host generates 1460 bytes of user data. The transport layer uses UDP with an 8-byte header, the network layer adds a 20-byte IP header, and the data link layer adds an Ethernet header and trailer totalling 18 bytes. Calculate:

  1. The total size of the Ethernet frame transmitted over the network.
  2. The overhead efficiency (percentage of the frame that is actual application data).

Step-by-Step Solution:

Given:
Application Data (\(D\)) = 1460 bytes
Transport Header (UDP, \(H_t\)) = 8 bytes
Network Header (IP, \(H_n\)) = 20 bytes
Data Link Header + Trailer (Ethernet, \(H_d\)) = 18 bytes

1. Total Frame Size (\(S\)): \[S = D + H_t + H_n + H_d = 1460 + 8 + 20 + 18 = 1506 \text{ bytes}\]

2. Overhead Efficiency (\(E\)): \[E = \frac{\text{Application Data}}{\text{Total Frame Size}} \times 100\% = \frac{1460}{1506} \times 100\% = 96.95\%\]

Total Overhead: \(100\% - 96.95\% = 3.05\%\) (or \(\frac{46}{1506} \times 100\% = 3.05\%\)).

πŸ“ Master Numerical 2: Persistent vs. Non-Persistent HTTP Timing (KTU 4M)

Problem: A web browser requests an HTML base page that references 5 small embedded image objects. The RTT between client and server is 50 ms. Assuming transmission times and server processing times are negligible, calculate the total retrieval time for:

  1. Non-Persistent HTTP (HTTP/1.0, serial connections).
  2. Persistent HTTP without pipelining (HTTP/1.1).
  3. Persistent HTTP with pipelining (HTTP/1.1).

Step-by-Step Solution:

Given \(N = 5\) objects, \(\text{RTT} = 50\text{ ms}\).

  • 1. Non-Persistent HTTP:
    Total time \(= 2(N + 1)\,\text{RTT} = 2(5 + 1) \times 50\text{ ms} = 12 \times 50\text{ ms} = \mathbf{600\text{ ms}}\).
  • 2. Persistent HTTP without Pipelining:
    Total time \(= (N + 2)\,\text{RTT} = (5 + 2) \times 50\text{ ms} = 7 \times 50\text{ ms} = \mathbf{350\text{ ms}}\).
  • 3. Persistent HTTP with Pipelining:
    Total time \(= 3\,\text{RTT} = 3 \times 50\text{ ms} = \mathbf{150\text{ ms}}\).

KTU Module 1 Comprehensive Question Bank (Theory Only)

Answer:

  • Control Connection (Port 21): Used for transmitting user credentials, commands (e.g., USER, RETR), and server status replies out-of-band. Remains open throughout the session.
  • Data Connection (Port 20): Used strictly for transferring the actual file data or directory listings. It is established dynamically on-demand for each transfer and closed immediately upon completion.

Answer:

A cookie is a small piece of state information sent by a server and stored on the client browser. Because HTTP is stateless, the server generates a unique cookie ID and sends it via the Set-Cookie: ID response header. On future visits, the browser automatically includes this ID in the Cookie: ID request header, enabling the server to recognize the returning user and maintain session state.

Answer Blueprint:

  1. Architecture Diagram (2 Marks): Draw Alice (UA) → Alice Mail Server (MTA Client → MTA Server) → Bob Mail Server (MTA Server → Mailbox) → Bob (MAA Client → UA).
  2. User Agent (UA) (1.5 Marks): Software used to compose, read, and organize emails.
  3. Message Transfer Agent (MTA) & SMTP (2.5 Marks): Server-to-server push protocol over TCP port 25. Explain the three phases: connection establishment (HELO), mail transfer (MAIL FROM, RCPT TO, DATA), and termination (QUIT).
  4. Message Access Agent (MAA) & Protocols (2.5 Marks): Pull protocols used by recipient. Differentiate POP3 (port 110, simple download/delete) vs IMAP4 (port 143, server-side folders, multi-device synchronization).
  5. Role of MIME (0.5 Mark): Enables sending non-ASCII and multimedia attachments.
⚑ Module 1 Last-Minute Memory Mnemonics
  • TCP/IP 5 Layers (Bottom to Top): Please Do Not Throw Sausage Pizza → Physical, Data Link, Network, Transport, Application.
  • Standard Port Numbers:
    • FTP Control: 21 | FTP Data: 20
    • SMTP: 25 | DNS: 53
    • HTTP: 80 | POP3: 110 | IMAP4: 143
  • Mesh Links Formula: \(W = \frac{n(n - 1)}{2}\)
  • Base64 Overhead: 3 bytes in → 4 chars out (33.3% size expansion).
  • Chord Finger Table: \(\text{Finger}[i] = \text{successor}((n + 2^{i-1}) \bmod 2^m)\).