Application Layer Paradigms Explained
Application Layer Paradigms Explained
Definition
• No Central Authority: No required always-on server process
• Distributed Service: Responsibility for service spread among all peers
• Dual Roles: Each computer acts as both client AND server simultaneously
• Direct Communication: Peers communicate directly without intermediary
Key Characteristic: Dual Roles
A single computer can: - Request a service from one peer (acting as CLIENT) - Provide a
service to another peer (acting as SERVER) - Do both simultaneously without
contradiction
Example: - Computer A downloads file from Computer B (A is client, B is server) - While
uploading file to Computer C (A is server, C is client) - Both happen at the same time!
Operational Flow
Step 1: Peers connect to Internet - Any peer can join at any time
Step 2: Peers locate other peers (Peer Discovery) - Query indexing service (if exists) - Or
broadcast to find peers - Or connect to known peer
Step 3: Direct peer-to-peer communication - No central server needed - Peers exchange
data directly - Each handles their own requests/responses
Scalability Detail: In client-server, new users = more load (bad). In P2P, new peers = more
resources (good!).
Characteristics Comparison
Feature Client-Server Peer-to-Peer
Central Server Required Not required
Server Role Dedicated, always-on Any peer, intermittent
Client Initiates Yes, always Any peer can initiate
Scalability Limited (server bottleneck) High (peers add capacity)
Security Easier (centralized) Harder (distributed)
Cost High (expensive server) Low (user hardware)
Reliability Single point of failure Redundancy built-in
Complexity Simpler More complex
Implementation Strategy
Two-Tier Approach:
Tier 1 - Client-Server: For Discovery/Lookup - Use centralized server - Light-weight
operations - Fast lookups - Server manages directory/index
Tier 2 - Peer-to-Peer: For Data Transfer - Direct P2P connections - Heavy-weight
operations - Efficient bandwidth usage - No server involvement
More Examples
Application Discovery (C-S) Communication (P2P)
Skype Locate user in Direct video/voice call
directory
BitTorrent Tracker finds peers Direct file transfer
Streaming Find available sources Stream from nearby
peer
Definition
• Set of instructions/functions provided by operating system
• Enables application programs to use network services
• Bridge between Application Layer and OS/TCP-IP stack
• Language-independent specification
Purpose
Application programs written in C, Java, Python, etc. do not have built-in network
knowledge. These languages have math, string, I/O operations but lack network operations.
API Solution: Provides standardized functions for network operations.
SOCKET INTERFACE
What is a Socket?
Definition
• Abstraction: Software object representing communication endpoint
• Purpose: Endpoint for sending/receiving data across network
• Metaphor: Just like reading from a file or writing to terminal
Key Analogy
Standard I/O Network I/O
Program reads from FILE Program reads from SOCKET
Program writes to FILE Program writes to SOCKET
File = Source/sink of data Socket = Source/sink of network
data
OS manages file I/O OS manages socket I/O
Unifying Principle: Treat network operations like file operations. Standard read/write
operations work with sockets too!
Socket Architecture
Basic Setup:
Client Program Server Program
| |
└─→ Create Socket ←──────────┘
| |
└─ Socket ─────────┘
|
Communication Link
Communication Flow: 1. Client creates socket 2. Server creates socket 3. Sockets connect
(appears as direct link to application) 4. Application reads/writes to socket as if it’s a file 5.
OS handles actual network transmission
SOCKET ADDRESSES
The Fundamental Problem
Goal: Process-to-process communication
Question: How do we address a specific process on a specific computer?
Challenge: - Computer address alone (IP) not sufficient - multiple processes per computer
- Process identification alone not sufficient - needs to know which computer
Solution: Socket Address = IP Address + Port Number
Example: [Link]:80
↑ ↑
Computer Process
Well-Known Ports (Examples): - Port 80: HTTP - Port 25: SMTP (Email) - Port 53: DNS -
Port 443: HTTPS - Port 22: SSH - Port 110: POP3
Key Point: Server port is fixed and known in advance so clients know where to find it.
Analogy: Phone directory - you look up person’s name to find their number.
Historical Context
• Inventor: Tim Berners-Lee at CERN (1989)
• Innovation: Revolutionary distributed information system
• Impact: Transformed the Internet from research network to mainstream
Components
Component Role Examples
Web Client Retrieves & Chrome, Firefox, Safari, Edge
displays pages
Web Server Stores & serves Apache, Nginx, IIS
pages
Site Collection of [Link], [Link]
related pages on
one server
Web Page File with content HTML file with text, images
& links
Link Pointer to <a href="...">
another resource
Client-Server Model
• Client (Browser): Requests documents
• Server: Provides documents
• Protocol: HTTP (HyperText Transfer Protocol)
• Transport: TCP/IP
Server II contains:
- File C (another HTML document)
Process:
Transaction 1: Fetch HTML - User types URL or clicks link to File A - Browser requests File
A from Server I - Server I sends File A (HTML)
Transaction 2: Auto-fetch embedded image - Browser parses HTML - Finds <img
src="[Link]"> - Browser automatically requests Image B from Server I - Server I
sends Image B
Transaction 3: User clicks link - User reads page, clicks link to File C - Browser requests
File C from Server II - Server II sends File C
Key Point: Each file is a separate transaction with separate request/response.
Example:
User 1 requests: [Link]?city=NYC
Server generates: Weather for NYC today
Active Documents
Aspect Details
Definition Program/script executed at client
Location Runs in browser (client-side)
Purpose Interactive features, animations
Technologies Java Applets, JavaScript,
WebAssembly
Server Load None (client does work)
Examples Games, maps, real-time chat
Why Active Documents: - Server cannot handle processing load - User experiences better
interactivity - Reduces bandwidth (only logic sent, not rendered output)
Web Components
Web Server
Responsibilities: - Stores web pages/documents - Listens for client requests - Processes
requests - Sends responses
Features: - Caching: Cache memory for frequently accessed pages - Threading: Handle
multiple simultaneous requests - Logging: Record all accesses - Security: Enforce
permissions
Common Examples: - Apache HTTP Server - Nginx - Microsoft IIS - [Link] - Flask/Django
(Python)
[Link]
│ │ │ │
│ │ │ └─ Path/Filename
│ │ └─ Port number (default 80 for HTTP)
│ └─ Host (domain or IP)
└─ Protocol (how to access)
Detailed Breakdown:
Examples:
[Link]
[Link]
[Link]
[Link]
Definition
• Full Name: HyperText Transfer Protocol
• Type: Text-based, request-response protocol
• Layer: Application layer
• Transport: TCP (reliable delivery)
• Port: 80 (HTTP), 443 (HTTPS)
• Standard: RFC 7230-7235
Key Characteristics
Feature Details
Protocol Type Request-Response
Text Format Messages are human-readable text
Connection Uses TCP on port 80
Reliability Reliable (TCP ensures this)
State Stateless (each request
independent)
Standard Defined in RFCs
HTTP Versions and Connection Types
HTTP/1.0 (Legacy)
Connection Model: Nonpersistent - One TCP connection per object - Limited efficiency
Example: Loading a web page with 1 HTML + 10 images
Connection 1: Request HTML → Response HTML → Close
Connection 2: Request Image1 → Response Image1 → Close
Connection 3: Request Image2 → Response Image2 → Close
...
Connection 11: Request Image10 → Response Image10 → Close
Overhead: - Each connection needs 3-way handshake - Each close needs teardown -
Significant latency and resource usage
Advantages: - Fewer handshakes (major latency reduction) - Lower CPU usage - Less
memory per server - Much faster page loads
Key Point: HTTP/1.1 DEFAULT is persistent. To disable: Connection: close header
Structure
REQUEST LINE
HEADERS (multiple lines)
[BLANK LINE]
[BODY - optional, usually empty]
Request Line
Format: METHOD URL HTTP/VERSION
Example: GET /images/[Link] HTTP/1.1
Components:
HEAD - Purpose: Like GET but response has NO body - Use: Check if resource exists, get
metadata - Body: No body - Advantage: Faster (no data transfer overhead) - Example:
HEAD /[Link] HTTP/1.1
POST (Second Most Common) - Purpose: Send data to server for processing - Use: Form
submissions, API requests - Body: Contains form data or JSON - Safe: No (modifies server
state) - Example: Form submission with username/password
PUT - Purpose: Upload a document to server - Use: Update resources, upload files - Body:
The file or resource content - Safe: No (creates/modifies) - Example: REST API updates
DELETE - Purpose: Delete a resource on server - Use: API operations, file deletion - Body:
Usually empty - Safe: No (destructive) - Example: DELETE /api/users/123 HTTP/1.1
PATCH - Purpose: Partial update of resource - Use: REST APIs, partial modifications -
Difference from PUT: PUT replaces entire resource; PATCH modifies parts
Content-Type: application/json
{"username": "john", "email": "john@[Link]"}
Content-Type: multipart/form-data
(file upload with boundaries)
username=john&password=secret
Structure
STATUS LINE
HEADERS (multiple lines)
[BLANK LINE]
[BODY - the actual document/data]
Status Line
Format: HTTP/VERSION STATUS-CODE REASON-PHRASE
Example: HTTP/1.1 200 OK
<!DOCTYPE html>
<html>
<head><title>Welcome</title></head>
<body>
<h1>Hello World</h1>
</body>
</html>
Conditional Requests
Translation: “Send me [Link], but ONLY if it’s been modified since this date”
Server Response - Case 1: Modified
HTTP/1.1 200 OK
Content-Type: text/html
Content-Length: 256
Benefit of 304: - Client can use cached version - Only headers transmitted (tiny) - Massive
bandwidth saving - Fast page load
Implementation:
Client Side: 1. Cache page on local disk 2. Send If-Modified-Since with cached timestamp 3.
If 304: Use cached version 4. If 200: Download new version, update cache
Server Side: 1. Check if-Modified-Since header 2. Compare with file’s Last-Modified
timestamp 3. Send 304 if not modified 4. Send 200 with data if modified
Definition of Stateless
• Each request treated as independent
• Server doesn’t remember previous requests
• No “memory” between interactions
• Fresh start for each request
Other Problems: - Can’t track user login - Can’t maintain shopping cart - Can’t personalize
content - Can’t track user preferences
Real-World Consequence
Without cookies: - Every page load feels like first visit - Can’t stay logged in - Can’t
remember preferences - Same ads shown repeatedly (no tracking)
Cookie Solution
What is a Cookie?
Definition: Small text file stored on client computer, sent with each request
Contains: User identifier, session ID, or preference data
Size: Typically 100 bytes to 4 KB
Format: Name=Value pairs
Example Cookie:
sessionId=9f84ab6c2b3e4d7f
username=john_doe
preferences=dark_mode,large_font
Key Point: Cookie sent automatically and transparently - user doesn’t need to do
anything!
Cookie Uses
1. Electronic Commerce
Purpose: Shopping cart persistence
How It Works: - User adds item to cart - Server stores item in database linked to sessionId
- Cookie maintains sessionId across pages - User can browse different products - Server
always knows what’s in cart - Checkout retrieves cart from database
Benefit: Can leave and return later, cart still there (within session timeout)
Cookie Anatomy
Basic Format:
Set-Cookie: name=value; [attributes]
Example:
Set-Cookie: sessionId=abc123; Domain=.[Link]; Path=/;
Max-Age=86400; Secure; HttpOnly
Components:
Definition
• Intermediary computer between client and web server
• Acts as both server (to client) and client (to web server)
• Sits at network gateway (campus, company, ISP)
• Caches frequently accessed pages
Architecture
Client 1 ─┐
Client 2 ─┤─→ Proxy Server ←→ Original Web Server
Client 3 ─┘
Definition
• Standard TCP/IP protocol for copying files between computers
• Application layer protocol
• Older but still widely used
• Specialized for file transfer (vs HTTP which is general-purpose)
Client Components
Component Purpose
User Interface CLI or GUI for human user
Client Control Process Sends commands, receives
responses
Client Data Transfer Process Handles actual file data
Server Components
Component Purpose
Server Control Process Listens for commands, executes them
Server Data Transfer Process Manages data connection, transfers
files
FTP Connections
Opening:
Client connects to server:21
Server responds: 220 Service ready
Client: HELO
Server: 250 OK
Closing:
Client: QUIT
Server: 221 Goodbye
Connection closes
Lifecycle:
File transfer initiated
↓
Data connection opened
↓
File data transferred
↓
Data connection closed
↓
Control connection still active
↓
Next file transfer can begin
Directory Management:
Diagram:
CLIENT SERVER
:50000 ←─────────────────────── :20 (Data)
Port for data listening connects here
Problem with ACTIVE mode: Client must accept incoming connection (firewall blocks)
Diagram:
CLIENT SERVER
:50001 ──────────────────────→ :60000
Client initiates to server's listening port
Comparison
Aspect ACTIVE PASSIVE
Initiator Server connects to client Client connects to server
Client Port Listen and accept Connect and send
Firewall Issues Client firewall blocks Usually passes through
Modern Default Rarely used Most common
Why Passive Clients often behind Client outbound works better
firewalls
Examples:
TYPE A → Text file, convert line endings
TYPE I → Binary file (image), exact copy
TYPE E → IBM EBCDIC file
Step 6: Logout
Client: QUIT
Server: 221 Goodbye
[Control connection closes]
Characteristics
Different from HTTP/FTP: - HTTP/FTP: Synchronous - Client initiates - Server responds
immediately - Two-way real-time interaction
• Email: Asynchronous
– Sender and receiver not online simultaneously
– Sender doesn’t need recipient’s computer on
– Recipient retrieves when ready
– Days can pass between send and read
Architecture Difference: - HTTP: Direct client-server - Email: Sender → Intermediate
Server → Recipient - Indirect (through mail servers) - One-way push (initially) - Recipient
pulls when ready
Part 1: Envelope
Purpose: Routing information for MTAs
Contains: - Sender address (from) - Recipient address (to) - CC, BCC fields - Routing
information
Used By: Mail servers for delivery
Visible To: Typically hidden from user
Part 2: Message
Two Sections:
A. Header: - Sender info - Recipient info - Subject - Date sent - Message-ID - References (for
threading) - Content type
B. Body: - Actual message text - HTML content - Attachments metadata
Visible To: User sees header and body
Email Addressing
Format: local-part@domain-name
Examples:
[Link]@[Link]
alice_smith@[Link]
support+bug123@[Link]
Components:
Component Example Details
Local Part [Link] Mailbox identifier on
the server
**@** Separator Literal @ symbol
Domain [Link] Mail server domain
Definition
• Standard protocol for sending emails
• Push protocol (client pushes message to server)
• Port: 25 (relay), 587 (submission with auth)
• Text-based: Human-readable commands
Uses
Context Details
Sender → Server UA sends mail to sender’s MTA
Server → Server MTAs relay mail across Internet
Cannot Use For Recipient to retrieve mail (that’s
POP3/IMAP)
Hello Bob,
Let's meet tomorrow at 10 AM.
Thanks,
Alice
.
↓
Server: 250 2.0.0 OK: Message queued as ABC123
Key Details: - Message body ends with . on its own line (period, CR, LF) - This signals end
of message to server - Server responds with message ID
SMTP Commands
Command Example Purpose
HELO HELO myhost Identify client
EHLO EHLO myhost Extended SMTP
MAIL FROM MAIL Specify sender
FROM:sender@exampl
[Link]
RCPT TO RCPT Specify recipient
TO:recipient@example.
com
DATA DATA Start message
transmission
QUIT QUIT End session
RSET RSET Reset session
NOOP NOOP No operation (keep
alive)
VRFY VRFY user Verify user exists
EXPN EXPN mailinglist Expand distribution list
Overview
Aspect Details
Purpose Simple mail retrieval from server to
client
Port 110 (clear) or 995 (SSL/TLS)
Model Download-and-delete (by default)
Complexity Simple
Features Basic (no folder management)
Use Case Single-device mail access
How POP3 Works
Two Modes:
Delete Mode (Default):
Step 1: Connect and login
Step 2: Retrieve messages
Step 3: Delete messages from server
Result: Client has copy, server is empty
Good for: Single device (laptop)
Bad for: Multiple devices (can't sync)
Keep Mode:
Step 1: Connect and login
Step 2: Retrieve messages
Step 3: Messages stay on server
Result: Both client and server have copy
Good for: Reference, multiple devices (limited)
Bad for: Server storage fills up
POP3 Commands
Command Purpose
USER Send username
PASS Send password
STAT Get mailbox status (number of
messages, total size)
LIST List message numbers and sizes
RETR Retrieve specific message
DELE Delete message
QUIT Close connection (commit
deletions)
POP3 Limitations
• No folder management: Can’t organize on server
• No searching: Must download all to search
• Synchronization: Difficult with multiple devices
• Bandwidth: Must download entire message
• Limited control: Can only download or delete
Overview
Aspect Details
Purpose Advanced mail management on
Aspect Details
server
Port 143 (clear) or 993 (SSL/TLS)
Model Manage on server
Complexity More complex
Features Comprehensive
Use Case Multi-device mail access
IMAP4 Features
Feature Description Example
Folder Management Create, delete, rename folders on Create “Projects” folder
server
Message Flags Mark messages (read, important, Flag important emails
deleted, etc.)
Server Search Search on server before Find all from “John”
downloading
Partial Download Get header without body Preview before
download
Multiple Devices Consistent view across devices Check mail on phone,
laptop, desktop
IDLE Server notifies of new mail Real-time notifications
Translation Service
MIME acts as translator:
Non-ASCII Data
↓
MIME Encoding (at sender)
↓
7-bit ASCII representation
↓
SMTP Transfer (works perfectly)
↓
MIME Decoding (at receiver)
↓
Original Non-ASCII Data
MIME Process
Transmission
SMTP transfers the ASCII representation
(no issues, it's plain ASCII)
MIME Headers
Purpose: Tell receiver how to decode
Added to email message:
Header 1: MIME-Version
MIME-Version: 1.1
(Indicates MIME usage and version)
Header 2: Content-Type
Content-Type: type/subtype; parameters
Examples:
Content-Type: text/plain
Content-Type: text/html
Content-Type: image/jpeg
Content-Type: audio/mpeg
Content-Type: video/mp4
Content-Type: application/pdf
Content-Type: multipart/mixed (for multiple parts)
Header 3: Content-Transfer-Encoding
Specifies HOW data was converted to ASCII
Values:
- 7bit: No conversion (already 7-bit ASCII)
- 8bit: No conversion (has 8-bit chars)
- binary: No conversion (binary data)
- quoted-printable: Text-heavy, few non-ASCII chars
- base64: General binary data
Header 4: Content-Id
Content-Id: <unique-identifier>
(Uniquely identifies this MIME part)
Header 5: Content-Description
Content-Description: My Picture
(Human-readable description)
Purpose
• Encode any binary data into safe ASCII
• Most universal MIME encoding
How It Works
Input: Binary data (any bytes)
Process: 1. Take 24 bits (3 bytes) of binary data 2. Divide into four 6-bit chunks 3. Map
each 6-bit value to Base64 character set
Base64 Character Set (64 characters):
A-Z (26) + a-z (26) + 0-9 (10) + +, / (2) = 64 characters
Example
Original: 3 bytes of binary data
Binary: 01001000 01100001 01101100
Hex: 48 61 6C (represents "Hal")
Conversion:
Split into 6-bit chunks:
010010 000110 000101 101100
Map to Base64:
010010 = S (index 18)
000110 = G (index 6)
000101 = F (index 5)
101100 = s (index 44)
Padding
If input not multiple of 3: - Add padding zeros - Pad output with = signs - Receiver knows
to ignore
------boundary
Content-Type: text/plain
------boundary
Content-Type: image/jpeg
Content-Transfer-Encoding: base64
Content-Description: My vacation photo
/9j/4AAQSkZJRgABAQEAYABgAAD...
(hundreds of base64 characters)
...lQWEBAEBAQEBAQEBAf/Z
------boundary--
WEB-BASED MAIL
Traditional vs. Web-Based Email
Traditional Email
Setup: - User installs email client (Outlook, Thunderbird) - Client connects to mail server
(POP3, IMAP) - Mail downloaded and stored locally
Access: Desktop/Laptop only (where client is installed)
Example: Microsoft Outlook
Web-Based Email
Setup: - No installation needed - Access via any web browser - Mail stays on server - Server
provides web interface
Access: Any computer with internet (phone, tablet, internet cafe)
Examples: Gmail, Yahoo Mail, [Link], ProtonMail
Protocols Used: - Alice → Server: SMTP - Server → Server: SMTP (inter-server relay) -
Bob → Gmail: HTTP/HTTPS (web browser)
Key Point: SMTP still handles server-to-server transfer
Protocols Used: - Alice → Gmail: HTTP/HTTPS - Gmail → Gmail internal: SMTP - Gmail
→ Outlook: SMTP (relay) - Bob → Outlook: HTTP/HTTPS
Key Point: Even web-based, servers still use SMTP to relay
EMAIL SECURITY
Insecurity of Basic Email
Problems
SMTP Vulnerability: - Plaintext passwords (USER, PASS sent unencrypted) - Plaintext
body (anyone sniffing network can read) - No authentication (anyone can claim to be
sender)
POP3/IMAP Vulnerability: - Plaintext authentication - Unencrypted mail download
Consequences: - Login credentials stolen - Mail intercepted and read - Spoofed emails
(fake sender) - Malicious attachments added in transit
Purpose
• Allows user on one computer to log into another computer remotely
• Access another computer’s resources and programs
• As if sitting directly at the remote keyboard
• Thousands of miles away
Example Scenarios
Scenario 1: System administrator in New York manages server in Tokyo - Logs into Tokyo
server from NYC - Runs commands remotely - Administers as if present
Scenario 2: Researcher accesses university’s powerful computer from home - Connects
from personal laptop - Runs computations on university server - Gets results back
Terminology
• Remote Logging or Remote Access: The concept
• Client (Telnet Client): User’s computer
• Server (Telnet Server): Remote computer being accessed
Definition
• Universal 8-bit character format
• Bridge between heterogeneous systems
• Client side: Local → NVT
• Server side: NVT → Remote OS format
NVT Advantages
• Standardized
• Simple (just bytes)
• Works across all systems
• Handles both data and control
Negotiation Process
Before/during connection: 1. Client tells server: “I support colors, function keys, 8-bit
chars” 2. Server tells client: “I support echo mode, line editing” 3. Both agree on options to
use 4. Rest of session uses those options
Example:
Server: "Do you support 8-bit mode?"
Client: "Yes, 8-bit mode supported"
[Both now use 8-bit for this session]
Definition
• Secure application-layer protocol
• For remote logging and file transfer
• REPLACES: Insecure protocols (TELNET, rsh, rlogin)
• Port: 22 (standard SSH port)
• Modern Standard: SSH-2 (SSH-1 deprecated)
Design Goal
• Encrypt everything (unlike TELNET)
• Authenticate both parties
• Ensure data integrity
• Replace insecure remote access tools
Versions
Version Status Issues
SSH-1 Deprecated Security vulnerabilities
SSH-2 Current Standard Robust, incompatible
with SSH-1
Build Order: Bottom-up 1. TRANS creates secure channel 2. AUTH authenticates user
through that channel 3. CONN multiplexes applications over that channel
Negotiate:
- Encryption algorithm (AES-128, AES-256, etc.)
- Integrity algorithm (SHA-256, MD5, etc.)
- Key exchange method (Diffie-Hellman, ECDH)
- Compression method
1. Privacy/Confidentiality
What it does: Encrypts all messages
How: - Messages scrambled using negotiated cipher - Only recipient can decrypt (has key) -
Eavesdropper sees gibberish
Example:
Original: "password=secret123"
Encrypted: "x7#k9@m2$l8%p3&qR9()"
(meaningless to eavesdropper)
2. Data Integrity
What it does: Detects if message modified in transit
How: - Calculate cryptographic checksum of message - Send checksum with message -
Recipient recalculates checksum - Compare checksums
If Different: - Message was modified - Attacker tried to alter it - Message rejected
3. Server Authentication
What it does: Client verifies server identity
Purpose: Prevent “Man-in-the-Middle” attacks
Attack It Prevents:
Attacker on network
↓
Intercepts client connection
↓
Pretends to be server (impersonation)
↓
Client connects to attacker, thinking it's server
↓
Attacker relays to real server
↓
Attacker sees all traffic!
SSH Solution: - Server has public key certificate - Server proves its identity using
certificate - Client verifies certificate - Attacker cannot impersonate without certificate
4. Compression
Optional service: - Compress messages before encryption - Reduce bandwidth - Side
benefit: Makes certain attacks harder
SSH-TRANS Summary
Service Provides Against
Encryption Confidentiality Eavesdropping
Integrity Data integrity Modification
Server Auth Authentication Man-in-the-middle
Compression Efficiency Bandwidth waste
Process
Client sends:
{
username: "john_doe",
service: "ssh-userauth", // What service (usually SSH)
method: "password", // How to authenticate
password: "secret123" // The credential
}
Failure:
Server: "SSH_MSG_USERAUTH_FAILURE"
Client: Invalid credentials
SSH-AUTH Significance
Difference from SSL: - SSL authenticates server (server certificate) - SSH-AUTH
authenticates client (user credentials) - Complementary: Both parties authenticated
Security: - Authentication happens OVER secure channel - Credentials encrypted - No
plaintext password on wire - Even if compromised connection, attacker sees only
encrypted creds
Types of Channels
Example:
User types: ls -la
Server sends: List of files
User sees: File listing
SSH-CONN Services
Service Description
Multiple Channels Many apps over one SSH connection
Window Size Control Flow control to prevent buffer
overflow
Channel Closure Graceful shutdown of individual
channels
Global Requests Network-level requests
SSH PACKET FORMAT
Structure
Each SSH packet has defined format:
┌─────────────────────────────────────┐
│ Length (4 bytes) │ Packet size
├─────────────────────────────────────┤
│ Padding (1-8 bytes) │ For alignment & security
├─────────────────────────────────────┤
│ Type (1 byte) │ Packet type
├─────────────────────────────────────┤
│ Data (variable) │ Actual content
├─────────────────────────────────────┤
│ CRC (4 bytes) │ Error detection
└─────────────────────────────────────┘
Field Details
Length (4 bytes)
• Specifies packet size (excluding padding)
• Receiver knows how much to read
Type (1 byte)
• Identifies packet category
• Examples:
– SSH_MSG_CHANNEL_DATA
– SSH_MSG_CHANNEL_REQUEST
– SSH_MSG_CHANNEL_CLOSE
– SSH_MSG_GLOBAL_REQUEST
Data (Variable)
• Actual payload
• Structure depends on packet type
CRC (4 bytes)
• Cyclic Redundancy Check
• Error detection (not integrity check)
• Quick corruption detection
SSH APPLICATIONS
1. Remote Logging
With SSH:
ssh john@[Link]
(everything encrypted)
What is SFTP?
Definition: SSH File Transfer Protocol
Subset of SSH: Runs as subsystem over SSH connection
How It Works:
SFTP Client
↓
SSH Connection to Server
↓
SSH Server spawns SFTP subsystem
↓
SFTP Server
Operations: - List files on remote (ls) - Change directory (cd) - Upload file (put) -
Download file (get) - Delete file (rm) - Create directory (mkdir)
All encrypted through SSH tunnel
Why SFTP?
Feature FTP SFTP
Encryption No Yes
Port 21 (may be blocked) 22 (usually open)
Passwords Plaintext Encrypted
Files Plaintext Encrypted
Installation FTP server SSH server
Firewall Often blocked Usually open
3. Port Forwarding/Tunneling
Local machine
Port 3306 (client connects here)
↓
SSH tunnel (encrypted)
↓
Remote server
Port 3306 (database server)
Purpose of DNS
Primary Function: Translate domain names to IP addresses
Analogy: Telephone directory - Look up: Person’s name - Get: Phone number - DNS
version: Look up domain name, get IP address
NAME SPACE
What is a Name Space?
Definition: Mapping of addresses to unique names
Goal: Every IP address (address) maps to unique name (no duplicates)
Two Models
[Link]
↓ ↓ ↓
↓ ↓ └─ Same TLD
↓ └──── Same domain
└────── Different subdomain (mail)
Components
Root
Aspect Details
Position Top of tree (level 0)
Label Empty string (null)
Notation Just “.”
Servers 13 logical root server clusters
worldwide
Function Directs to TLD servers
Generic TLDs:
.com = Commercial
.edu = Education
.gov = Government
.org = Non-profit
.net = Network infrastructure
.mil = Military
.int = International organization
Country TLDs:
.us = United States
.uk = United Kingdom
.fr = France
.in = India
.de = Germany
.jp = Japan
.ca = Canada
.au = Australia
Nodes and Domains
Node: Single point in tree
Domain: Subtree of the name space
Example:
edu (node and domain)
└── [Link] (node and domain)
└── [Link] (node and domain)
└── [Link] (node - host, also domain if delegated)
Definition
FQDN: Complete domain name ending with root
Format: Sequence of labels from node to root, separated by dots
Ending: Ends with “.” (represents root)
Example: [Link]. (note the final dot)
Characteristics: - Uniquely identifies a host on Internet - Unambiguous (ending “.” makes
it absolute) - Globally unique
Example FQDNs
[Link].
[Link].
[Link].
[Link].
Practical Note
Browsers hide trailing dot: - User types: [Link] (no dot) - Browser converts to:
[Link]. (adds dot) - Same thing!
Definition
PQDN: Domain name without reaching root
Format: Doesn’t end with “.”
Scope: Only understood in local context
Example:
If you're at MIT:
- PQDN: "www" means "[Link]"
- Outside MIT: "www" is ambiguous
Outside Organization:
At home, type: "mail"
DNS doesn't know: "mail" what?
Doesn't resolve
What is a Zone?
Definition: Specific part of domain for which a server is responsible
Scope: Zone ⊆ Domain (zone is subset of domain it manages)
Responsibility: Server has authority over zone
Analogy: - Domain: Entire organization - Zone: Department within organization (server
responsible for it)
Example: [Link]
Entire Domain: [Link] (includes all subdomains)
Possible Zones: - Zone 1: [Link] (Google’s own servers manage main domain) - Zone
2: [Link] (separate team manages mail) - Zone 3: [Link] (separate
team manages drive)
Each Zone has its own primary and secondary servers
Server Types
Root Servers
Aspect Details
Zone Entire tree (root)
Authority Over all of DNS
Number 13 logical servers (hundreds of physical
machines via anycast)
Distribution Worldwide
Purpose Directs queries to TLD servers
Function:
"Where is [Link]?"
Root server: "I don't know exactly, but ask the .com server"
Client then asks .com server
Function:
"Where is [Link]?"
.com TLD server: "Ask Google's nameserver at [Link]"
Client then asks Google's server
Authoritative Servers
Aspect Details
Zone Specific domain
Authority Authoritative for domain’s records
Number Usually 2+ (primary + secondary)
Purpose Provide definitive answers
Function:
"What's IP of [Link]?"
Google's nameserver: "[Link]"
(definitive answer)
Primary Server
Aspect Details
Role Master server for domain
Responsibility Create, maintain, update zone file
Storage Zone file on disk
Updates Primary server updated first
Propagation Changes propagate to secondaries
Secondary Server
Aspect Details
Role Backup/slave server
Copy Zone file copy from primary
Retrieval Zone transfer from primary or other
secondary
Purpose Redundancy and load distribution
Updates Updated from primary (not directly
edited)
Secondary Servers:
├─ [Link] (copy of zone file)
├─ [Link] (copy of zone file)
└─ ... (more secondaries)
Use Cases: - Email server validation (reverse DNS lookup) - Security checks - Logging
(resolve IPs to names)
DNS RESOLUTION
The Process
Goal: Translate name to IP address
Resolver: Client program that initiates resolution
How It Works: Client contacts DNS server, server recursively queries until answer found
Recursive Resolution
What is it?
Burden Placed: On the servers
Flow: Query flows up the hierarchy until answered
Direction: Answer flows back down
What is it?
Burden Placed: On the client’s resolver
Flow: Each server tells resolver where to ask next
Direction: Resolver keeps asking
Caching
TTL (Time-To-Live)
Problem: Cached data becomes stale
Solution: Set expiration time
TTL: How long (in seconds) cached data is valid
Example:
[Link] A record: [Link], TTL=300
Common TTL Values: - 300 seconds (5 min): Frequently changing records - 3600
seconds (1 hour): Standard records - 86400 seconds (1 day): Stable records - 43200
seconds (12 hours): Mixed frequency
Low TTL: Always fresh, more queries, more traffic
High TTL: Less fresh, fewer queries, less traffic
Use Cases
• Home networks (dynamic IP from ISP)
• Mobile devices (change networks frequently)
• Virtual machines (constantly spawned/destroyed)
• Cloud infrastructure (auto-scaling)
Message Structure
┌─────────────────────────────┐
│ Header (12 bytes) │ Identification, Flags, Counts
├─────────────────────────────┤
│ Question Section (variable) │ What are we asking for?
├─────────────────────────────┤
│ Answer Section (variable) │ Answers to question (in response)
├─────────────────────────────┤
│ Authority Section (variable)│ Authority records
├─────────────────────────────┤
│ Additional Section (var) │ Extra info (optional)
└─────────────────────────────┘
Header (12 bytes)
Fields:
Question Section
Contains: What we’re asking for
Example:
Name: [Link]
Type: A (IPv4 address)
Class: IN (Internet)
Answer Section
Contains: Answers to question (only in response)
Format: Resource Records
Example:
[Link] A [Link]
(Name Type IP Address)
Authority Section
Contains: Information about authoritative nameserver
Used for: Directing to next server in resolution chain
Additional Section
Contains: Supplementary information
Example: IP of nameserver mentioned in Authority section
Examples of Registrars
• GoDaddy
• Namecheap
• Network Solutions
• 1&1
• Google Domains
• Hostinger
Registration Process
Step 1: User chooses registrar
Step 2: User provides: - Desired domain name - Admin contact info - Technical contact info
- Nameserver addresses
Step 3: Registrar: - Checks domain availability (not already registered) - Verifies
uniqueness - Creates DNS zone file - Enters into database
Step 4: User is registered owner
Step 5: Charges annual fee for registration
DNS SECURITY
DNS Vulnerabilities
Problem 1: Reconnaissance
Attack: Read DNS responses to map network
Method: - Query DNS server - Response reveals internal IP addresses - Attacker learns
network structure
Consequence: - All users cached to fake IP - Users visit attacker’s site thinking it’s bank -
Phishing, credential theft, malware
What is it?
Solution: Add security to DNS records
Method: Digital signatures on DNS records
What it provides:
1. Data Origin Authentication - Verify answer came from real server - Not spoofed or
intercepted
2. Data Integrity - Verify answer not changed in transit - Ensures data is unchanged
What it does NOT provide:
Confidentiality: Records not encrypted (queries visible)
How it Works
Concept: Sign DNS records with cryptographic key
Process:
Original Record:
[Link] A [Link]
Recipient verifies:
Uses public key to validate signature
If valid: Trust the answer
If invalid: Reject (spoofed or tampered)
Benefits
• Prevents cache poisoning
• Prevents spoofing
• Ensures data integrity
• Protects users from malicious redirects
Socket Addressing
Formula: Socket Address = IP Address + Port Number
Well-Known Ports: - 21: FTP - 25: SMTP - 53: DNS - 80: HTTP - 110: POP3 - 143: IMAP -
443: HTTPS - 22: SSH
HTTP
Methods: GET (retrieve), POST (send), HEAD (metadata), PUT (upload), DELETE (remove)
Status Codes: - 2xx: Success - 3xx: Redirect - 4xx: Client error - 5xx: Server error
Persistent connections (HTTP/1.1 default): One TCP connection for multiple requests
FTP
Two connections: - Control (port 21): Commands - Data (port 20/ephemeral): File data
Modes: - Active: Server connects to client - Passive: Client connects to server
Email
Three agents: - UA (User Agent): Compose/read emails - MTA (SMTP): Relay between
servers - MAA (POP3/IMAP): Recipient retrieves
Protocols: - SMTP (port 25): Send (push) - POP3 (port 110): Download and delete - IMAP
(port 143): Manage on server
TELNET
Problem: Heterogeneous systems speak different languages
Solution: NVT (Network Virtual Terminal) - universal format
Security: Plaintext (NEVER use for sensitive data)
SSH
Three-layer architecture: 1. SSH-TRANS: Encryption and integrity 2. SSH-AUTH: User
authentication 3. SSH-CONN: Multiplexing channels
Uses: Remote login, SFTP (file transfer), port forwarding
Port: 22
Security: Everything encrypted
DNS
Purpose: Translate domain names to IP addresses
Hierarchy: Root → TLD → Authoritative servers
Resolution: - Recursive: Server does queries, client waits - Iterative: Server tells where to
ask next
Caching: TTL (Time-to-Live) determines cache duration
DNSSEC: Digital signatures for security
The hierarchical structure of the Domain Name System (DNS) offers significant benefits, including decentralization, scalability, and fault tolerance. By dividing the namespace into different levels (root, TLDs, domains, and subdomains), DNS ensures that no single server bears the entire resolution burden, leading to faster, localized queries and reduced points of failure, enhancing reliability and maintenance flexibility. However, challenges include the complexity of updates and coordination across numerous authoritative servers, potential propagation delays, and the necessity for robust security measures such as DNSSEC to prevent cache poisoning or spoofing attacks. Moreover, dependence on root and TLD servers can create central points of failure or bottlenecks if not resiliently designed and distributed .
Traditional FTP has several vulnerabilities, including the transmission of data and credentials in plaintext, making them susceptible to interception, credentials theft, and man-in-the-middle attacks. An attacker could sniff the network traffic to read passwords or file contents easily. The integration of an SSL/TLS wrapper (creating FTPS) mitigates these risks by encrypting the data and control channels, ensuring that any intercepted traffic is unreadable to an attacker without decryption keys. This encryption also authenticates the server with certificates, adding a layer of trust and integrity to the transfer process. Using SSL/TLS thus transforms FTP into a secure protocol, vastly improving its security posture .
The Session Initiation Protocol (SIP) differs fundamentally from FTP and Email in its communication model and functionality. SIP is designed for establishing, modifying, and terminating real-time communication sessions, such as VoIP or video conferencing. It operates in a peer-to-peer and synchronous manner where both parties must be online simultaneously for interaction. In contrast, FTP is used for file transfers, following a client-server model where the client requests resources from the server in a mostly synchronous interaction. Email, unlike both SIP and FTP, is inherently asynchronous, allowing messages to be sent and stored until the recipient retrieves them at their convenience, often resulting in significant delays between communication acts .
FTPS and SFTP differ fundamentally in how they secure file transfers. FTPS is essentially FTP with an added layer of SSL/TLS for encryption, which secures both commands and data. It uses ports 990 or 21 with STARTTLS for encryption and integrates smoothly into existing FTP infrastructure. On the other hand, SFTP is a different protocol altogether, using SSH (port 22) to provide a secure channel. SFTP offers a more modern security model and is integrated with SSH, providing benefits like easier firewall traversal and better security management, but it may require more setup changes to adopt. SFTP might be preferred for newer systems or where SSH infrastructure is prevalent, offering stronger security posture and simpler configuration through a single port, while FTPS might be useful where compatibility with traditional FTP services is needed .
The FTP passive mode helps overcome firewall issues because it changes the way the data connection is established. Instead of the server connecting back to the client (which could be blocked by the client's firewall), the client initiates the data connection by connecting to a port the server opens and indicates during the control session. This approach is often preferred in modern environments because clients are frequently behind firewalls or NAT, which typically allow outbound connections more readily than accepting inbound ones. This makes passive mode more firewall-friendly and common in current practice .
DNS plays a crucial role in internet infrastructure by translating human-friendly domain names into IP addresses, allowing users to interact with network resources easily without needing to remember complex numerical addresses. It handles the problem of centralization by distributing name resolution across a hierarchical and decentralized network of servers. This hierarchical structure divides the namespace into manageable zones, each of which is handled by authoritative servers. Root servers direct queries to the appropriate top-level domain (TLD) servers, which in turn direct queries to domain-specific authoritative servers. This division of responsibility ensures redundancy, reduces latency by localizing queries, and avoids a single point of failure, making DNS scalable and resilient to network changes and growth .
Authoritative DNS servers play a critical role in the DNS resolution process as they provide definitive answers regarding domain-to-IP mappings. When queried, they supply the requested domain records, establishing the accuracy and reliability of the domain's address information. The benefits of deploying primary and secondary servers are numerous: the primary server maintains the original zone file, while one or more secondary servers hold copies. This setup offers redundancy, ensuring that if the primary server fails, secondary servers can continue to provide DNS services, thus maintaining service availability. Additionally, by distributing queries among multiple servers, the DNS architecture benefits from load balancing, reduced latency, and increased reliability across geographically dispersed locations .
The Message Transfer Agent (MTA) is a crucial component in email delivery, responsible for routing emails from the sender's system to the recipient's mail server over the Internet. It operates by receiving emails from the sender's User Agent (UA), and using the Simple Mail Transfer Protocol (SMTP) to transfer these messages network-to-network until they reach the recipient's MTA server. SMTP ensures that the emails are appropriately routed by specifying the sender, recipient, and message content in a format that can be forwarded between MTAs across different mail servers. The MTA uses DNS to resolve the recipient's domain to its mail server address and handles email queuing, retries, and error management, ensuring delivery consistency .
The SSH protocol provides several advantages for secure communications compared to SSL/TLS, particularly regarding the model of client-server authentication. SSH inherently supports bidirectional authentication, with the server and client both verifying each other. SSH uses mechanisms like public key cryptography, password-based, and host-based authentication, allowing flexible and robust credential verification without exposing raw credentials over the network. Unlike SSL/TLS, which primarily authenticates the server to the client (and optionally the reverse in some setups), SSH starts each session with mutual authentication, ensuring both parties' identities and encrypting the entire session. This setup not only offers a simpler firewall traversal (using port 22) but also integrates easily with other services like SFTP under one protocol suite, enhancing security management and efficiency .
A Fully Qualified Domain Name (FQDN) is a complete domain name that specifies its absolute position in the DNS hierarchy, ending with a dot that represents the root. For example, 'www.example.com.' is an FQDN, ensuring global uniqueness and unambiguity. Conversely, a Partially Qualified Domain Name (PQDN) doesn't specify the entire path to the root, making it ambiguous without additional context. PQDNs are typically used within local networks or organizational contexts where the surrounding domain can be assumed. For example, within an organization called 'example.com,' a user might type 'www' to refer to 'www.example.com.' FQDNs are essential for internet-wide communication, while PQDNs offer convenience and brevity in internal settings where the context is implicit .