Network and Data CommunicationsUnit 812 min read
Application Layer Protocols: HTTP, FTP, SMTP, DNS, and Real-World Use Cases
Unit 8 of Network and Data Communications explores the application layer protocols (HTTP/HTTPS, FTP, SMTP, POP3, IMAP, DNS, DHCP, and SNMP) that enable user services like web browsing, email, and file transfer. It covers their functions, message formats, port numbers, and real-world implementations in apps like eSewa,
TAKEAWAYS:
- HTTP/HTTPS enables web communication using request-response cycles (GET, POST, PUT, DELETE) over port 80/443, with HTTPS adding encryption via TLS.
- FTP transfers files between clients and servers (port 21) using separate control and data connections, while SFTP/FTPS add security.
- SMTP, POP3, and IMAP handle email delivery and retrieval: SMTP sends mail (port 25), POP3 downloads it (port 110), and IMAP syncs it (port 143).
- DNS translates domain names to IP addresses (port 53) using hierarchical name servers and caching to reduce lookup time.
- DHCP automates IP address assignment (ports 67/68) via lease offers and acknowledgments, while SNMP monitors network devices (port 161).
- Real-world ties: WhatsApp uses HTTP/HTTPS for API calls, eSewa relies on HTTPS for secure transactions, and Ncell’s billing portal uses SMTP for email alerts.
Application Layer Protocols: The User-Facing Interface of Networks
The application layer (Layer 7 of the OSI model) is where users interact directly with network services. Unlike lower layers that handle data transmission, this layer defines protocols for specific applications (e.g., web browsing, email, file transfer) and their message formats, ports, and rules. Protocols here are either reliable (guaranteed delivery, e.g., HTTP, SMTP) or unreliable (best-effort, e.g., DNS, UDP-based apps), depending on the use case.
1. HTTP/HTTPS: The Backbone of the Web
Definition: HTTP (HyperText Transfer Protocol) is a stateless, request-response protocol for fetching web resources (HTML, images, JSON). HTTPS (HTTP Secure) adds TLS/SSL encryption for secure transactions (e.g., online banking).
How It Works
- Client-Server Model: A browser (client) sends a request (e.g.,
GET /index.html), and the server responds with data. - Methods:
GET(retrieve),POST(submit data),PUT(update),DELETE(remove). - Status Codes:
200 OK: Success.404 Not Found: Resource missing.500 Internal Server Error: Server failure.
- Headers: Metadata like
Content-Type,Cookie, orAuthorization. - HTTPS Handshake:
- Client → Server: "Hello, I support TLS 1.3."
- Server → Client: "Here’s my certificate (signed by a CA)."
- Client verifies certificate → Exchanges symmetric keys → Encrypted communication begins.
Message Format
GET /api/user HTTP/1.1
Host: esewa.com.np
User-Agent: Mozilla/5.0
Accept: application/json
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 123
{"user_id": 12345, "balance": 5000}
Real-World Example: eSewa Transactions
When you pay a bill on eSewa:
- Your browser sends a
POSTrequest tohttps://esewa.com.np/paywith your card details. - HTTPS encrypts the data using TLS 1.3.
- eSewa’s server validates the request, deducts the amount, and sends a
200 OKresponse with a transaction ID. - Why HTTPS? Without encryption, attackers could intercept your card number (man-in-the-middle attack).
2. FTP: File Transfer Protocol
Definition: FTP (File Transfer Protocol) transfers files between a client and server over two separate connections:
- Control Connection (Port 21): Sends commands (e.g.,
USER,PASS,RETR). - Data Connection (Port 20): Transfers the actual file.
Security Issues and Alternatives
| Protocol | Port | Security | Use Case |
|---|---|---|---|
| FTP | 21 | None | Legacy file transfers |
| SFTP | 22 | SSH | Secure file transfer |
| FTPS | 990 | TLS | Secure FTP over SSL |
Example: Downloading a File from Daraz
- Client connects to
ftp.daraz.comon port 21. - Sends
USER/PASScredentials (in plaintext!). - Uses
RETR filename.pdfto download the file over port 20. Problem: Passwords and data are sent unencrypted. Use SFTP (SSH-based) instead.
3. Email Protocols: SMTP, POP3, IMAP
Email relies on three protocols:
A. SMTP (Simple Mail Transfer Protocol)
- Port: 25 (or 587 for submission).
- Role: Sends emails from client to server or server to server.
- Process:
- Client → Server:
HELO esewa.com - Server → Client:
250 Hello - Client sends
MAIL FROM: <sender@example.com> - Server replies
250 OK - Client sends
RCPT TO: <recipient@khalti.com> - Server replies
250 OK - Client sends email data → Server stores it.
- Client → Server:
B. POP3 (Post Office Protocol v3)
- Port: 110 (or 995 for POP3S with TLS).
- Role: Downloads emails from server to client and deletes them (unless configured otherwise).
- Example: When you check your Ncell email on a desktop app.
C. IMAP (Internet Message Access Protocol)
- Port: 143 (or 993 for IMAPS with TLS).
- Role: Syncs emails between client and server (keeps a copy on the server).
- Example: Gmail or WhatsApp’s email notifications sync via IMAP.
Comparison Table
| Feature | SMTP | POP3 | IMAP |
|---|---|---|---|
| Direction | Send-only | Download | Sync |
| Port | 25/587 | 110/995 | 143/993 |
| Security | TLS (SMTPS) | TLS (POP3S) | TLS (IMAPS) |
| Use Case | Sending | Offline access | Cloud sync |
4. DNS: The Phonebook of the Internet
Definition:
DNS (Domain Name System) translates human-readable domain names (e.g., google.com) to IP addresses (e.g., 142.250.190.46) using a hierarchical, distributed database.
How DNS Works
- User enters
esewa.com→ Browser checks local cache. - If not found, queries the root DNS server (
.). - Root refers to
.comTLD server. - TLD refers to
esewa.comauthoritative server. - Authoritative server returns IP (e.g.,
103.10.192.45). - Browser connects to the IP.
DNS Record Types
| Type | Example | Purpose |
|---|---|---|
| A | esewa.com → 103.10.192.45 |
Maps domain to IPv4 address |
| MX | esewa.com → mail.esewa.com |
Specifies mail server |
| CNAME | www.esewa.com → esewa.com |
Alias for another domain |
| TXT | esewa.com → "v=spf1..." |
SPF/DKIM security records |
Real-World Example: WhatsApp’s DNS Lookup
When you open WhatsApp:
- Your phone queries DNS for
web.whatsapp.com. - DNS returns the IP of WhatsApp’s servers (e.g.,
157.240.11.35). - Your phone connects to this IP to fetch app updates.
5. DHCP: Automating IP Addresses
Definition: DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses to devices on a network, reducing manual configuration.
How DHCP Works (4-Way Handshake)
sequenceDiagram
participant Client as Device (e.g., Laptop)
participant Server as DHCP Server
Client->>Server: DHCPDISCOVER (Broadcast)
Server->>Client: DHCPOFFER (Unicast)
Client->>Server: DHCPREQUEST (Accept offer)
Server->>Client: DHCPACK (Confirm lease)Example: NTC’s Wi-Fi Hotspot
- Your phone broadcasts
DHCPDISCOVERon the NTC network. - DHCP server replies with an IP (e.g.,
192.168.1.100), subnet mask, and gateway. - Your phone configures itself and connects to the internet.
6. SNMP: Monitoring Networks
Definition: SNMP (Simple Network Management Protocol) monitors and manages network devices (routers, switches) by collecting statistics (e.g., bandwidth usage, errors).
How SNMP Works
- Manager (e.g., Ncell’s network ops) sends a
GETrequest to a router. - Agent (SNMP software on the router) responds with data (e.g., CPU usage = 85%).
- Manager takes action (e.g., alerts IT staff).
Example: Ncell’s Network Monitoring
Ncell uses SNMP to:
- Track traffic on fiber optic cables (IMAGE: fiber optic cable diagram | Cross-section of a fiber optic cable).
- Detect link failures and reroute traffic automatically.
## In the Real World
eSewa (HTTPS + DNS)
- When you pay a bill, eSewa uses HTTPS to encrypt your card details during the
POSTrequest. - DNS resolves
esewa.comto its server IPs (e.g.,103.10.192.45) so your browser knows where to send the request.
- When you pay a bill, eSewa uses HTTPS to encrypt your card details during the
WhatsApp (HTTP/HTTPS + DNS)
- WhatsApp’s web version uses HTTP/2 (a faster version of HTTP) to load chats.
- DNS translates
web.whatsapp.comto its global server IPs (e.g.,157.240.11.35) for low-latency access.
Ncell Billing (SMTP + POP3)
- Ncell sends your monthly bill via SMTP (port 25) to your email provider.
- You check it using POP3/IMAP on your phone or computer.
Daraz Orders (FTP/SFTP)
- Daraz’s internal systems use SFTP (secure FTP) to transfer product images from suppliers to their servers.
- Customers download order confirmations via HTTP/HTTPS.
NTC Traffic Routing (SNMP + DNS)
- NTC’s routers use SNMP to monitor fiber optic links (IMAGE: router diagram | A Cisco router used in NTC’s backbone).
- DNS ensures
ntc.net.npresolves to the correct peering points for internet traffic.
## Exam Tip
- Protocol Comparisons: Always compare HTTP vs. HTTPS, POP3 vs. IMAP, or FTP vs. SFTP in tables (as shown above). Examiners love structured answers.
- Port Numbers: Memorize key ports:
- HTTP: 80, HTTPS: 443
- FTP: 21, SFTP: 22
- SMTP: 25, POP3: 110, IMAP: 143
- DNS: 53, DHCP: 67/68, SNMP: 161
- Real-World Scenarios: Link protocols to apps/companies. For example:
- "eSewa uses HTTPS for secure transactions because..."
- "Ncell monitors its network using SNMP to..."
- Message Formats: Draw a fields figure for HTTP requests/responses or DNS queries. Label each part (e.g., method, headers, body).
- DNS Hierarchy: Explain DNS resolution step-by-step with a sequence diagram (as shown for DHCP). Use
root → TLD → authoritativein your answer. - Security: Always mention encryption (TLS for HTTPS, SSH for SFTP) when asked about secure protocols.
- Common Pitfalls:
- Don’t confuse SMTP (sending) with POP3/IMAP (receiving).
- FTP is not secure; always prefer SFTP/FTPS in exams.
- DNS is not a protocol for email routing (that’s SMTP/MX records).
## Visual Summaries
1. OSI Model with Application Layer Highlighted
pie
title OSI Model Layers
"Application (HTTP, DNS, SMTP)" : 15
"Presentation (SSL/TLS)" : 10
"Session (NetBIOS)" : 5
"Transport (TCP/UDP)" : 20
"Network (IP, Routing)" : 20
"Data Link (MAC, Switching)" : 15
"Physical (Cables, Signals)" : 152. HTTP Request/Response Fields
+-------------------------------+
| GET /index.html HTTP/1.1 |
+-------------------------------+
| Host: esewa.com.np |
| User-Agent: Mozilla/5.0 |
| Accept: text/html |
+-------------------------------+
| |
| (Empty line) |
| |
+-------------------------------+
| HTTP/1.1 200 OK |
+-------------------------------+
| Content-Type: text/html |
| Content-Length: 1234 |
+-------------------------------+
| <html>...</html> |
+-------------------------------+
Caption: HTTP/1.1 request and response structure.
3. DNS Resolution Flow
graph TD
A["User enters google.com"] --> B["Check local cache"]
B -->|"Not found"| C["Query Root DNS"]
C --> D["Root refers to .com TLD"]
D --> E["TLD refers to google.com"]
E --> F["Authoritative server returns IP"]
F --> G["Browser connects to 142.250.190.46"]4. Email Flow (SMTP + POP3)
sequenceDiagram
participant A as Alice (Sender)
participant B as SMTP_Server
participant C as IMAP_Server
participant D as Bob (Receiver)
A->>B: Compose email (SMTP Port 25)
B->>C: Deliver email (SMTP)
D->>C: Check mail (IMAP Port 143)
C->>D: Sync email to device## Practice Questions (Exam-Style)
- Differentiate between HTTP and HTTPS. How does eSewa use HTTPS to secure transactions?
- Explain the 4-way DHCP handshake with a sequence diagram. How does NTC’s Wi-Fi use DHCP?
- Draw a table comparing POP3 and IMAP. Which would you use for Ncell’s email service and why?
- Trace the DNS lookup process for
khalti.com. Include root, TLD, and authoritative servers. - Why is FTP insecure? Describe how SFTP solves this problem with a diagram of its connection setup.
Based on the TU BIT syllabus for Network and Data Communications (BIT254), unit 8.
Discussion
Loading…