- Authors

- Name
- Youngju Kim
- @fjvbn20031
This post is based on the textbook Computer Networking: A Top-Down Approach (6th Edition) by James Kurose and Keith Ross.
- 1. Email Protocols
- 2. DNS (Domain Name System)
- 3. DNS Records and Messages
- 4. P2P File Distribution
- 5. Distributed Hash Table (DHT)
- 6. Summary
- 7. Review Questions
1. Email Protocols
1.1 Components of the Internet Email System
Three major components of the Internet email system:
1. User Agent (UA)
- Reading, composing, and sending email
- Examples: Outlook, Gmail web, Thunderbird
2. Mail Server
- Mailbox: Stores incoming messages
- Message queue: Outgoing message queue
3. SMTP (Simple Mail Transfer Protocol)
- Protocol for transferring messages between mail servers
1.2 SMTP Protocol
Email transmission process:
Alice's UA -> Alice's mail server -> Bob's mail server -> Bob's UA
SMTP transfer SMTP transfer
1. Alice composes a message -> UA sends to Alice's mail server
2. Alice's mail server stores message in the message queue
3. SMTP client opens TCP connection to Bob's mail server SMTP server (port 25)
4. SMTP handshaking followed by message transfer
5. Bob's mail server stores message in Bob's mailbox
6. Bob reads the message via UA
SMTP Handshaking Example
S: 220 mail.example.com SMTP ready
C: HELO mail.alice.com
S: 250 Hello mail.alice.com
C: MAIL FROM: alice@alice.com
S: 250 OK
C: RCPT TO: bob@example.com
S: 250 OK
C: DATA
S: 354 Start mail input
C: From: alice@alice.com
C: To: bob@example.com
C: Subject: Hello
C:
C: Hi Bob, how are you?
C: .
S: 250 OK
C: QUIT
S: 221 Bye
SMTP Characteristics
| Characteristic | Description |
|---|---|
| Uses TCP | Port 25, reliable delivery |
| Push protocol | Sender pushes messages to the receiving server |
| 7-bit ASCII | Body is 7-bit ASCII only (extended via MIME) |
| Persistent connection | Multiple messages can be sent over one connection |
SMTP vs HTTP Comparison
| Aspect | HTTP | SMTP |
|---|---|---|
| Direction | Pull (client retrieves) | Push (server pushes) |
| Encoding | Binary allowed | 7-bit ASCII |
| Objects | Each object in separate response | All objects in one message |
1.3 Mail Access Protocols
The protocol for reading email from the mail server is not SMTP.
Sending Receiving
Alice UA --SMTP--> Mail server --SMTP--> Mail server --POP3/IMAP/HTTP--> Bob UA
(Push) (Push) (Pull)
- POP3: Simple; downloads mail then deletes from server (or keeps)
- IMAP: Messages remain on server; folder management; more complex
- Web-based email: Access via HTTP (Gmail, Outlook.com, etc.)
2. DNS (Domain Name System)
2.1 Services Provided by DNS
DNS is a distributed database system that translates host names to IP addresses.
User wants to access: www.example.com
|
DNS query: www.example.com -> ?
|
DNS response: 93.184.216.34
|
HTTP connection: 93.184.216.34:80
Additional DNS Services
1. Host Aliasing
Assign a simple alias to a complex canonical hostname
relay1.east.example.com -> www.example.com
2. Mail Server Aliasing
Specify mail servers via MX records
Mail for example.com -> mail.example.com
3. Load Distribution
Map a single name to multiple IP addresses
www.example.com -> 93.184.216.34, 93.184.216.35, ...
DNS rotates IP order in responses
2.2 Why DNS Is Not Centralized
Problems with centralized DNS:
+-- Single point of failure: Server crash brings down entire Internet
+-- Traffic volume: Cannot handle worldwide DNS queries
+-- Distant database: Increased latency
+-- Maintenance: Impossible to update a single database
-> DNS is designed as a distributed hierarchical database!
2.3 Hierarchical Structure of DNS
Root DNS server (.)
/ | \
.com .org .kr
/ \ | |
example google wiki naver
Three Types of DNS Servers
1. Root DNS Server
- 13 root server clusters worldwide (A through M)
- Provides IP addresses of TLD servers
2. TLD Server (Top-Level Domain Server)
- Handles .com, .org, .net, .kr, .jp, etc.
- Provides IP addresses of authoritative DNS servers
3. Authoritative DNS Server
- Maintains DNS records for an organization's public hosts
- Provides the final hostname-to-IP mapping
Local DNS Server
Not strictly part of the hierarchy, but plays a crucial role in the DNS architecture.
Each ISP has a local DNS server (default name server)
- When a host sends a DNS query, the local DNS server queries on its behalf
- Located nearby for fast responses
2.4 DNS Query Methods
Recursive Query
Host -> Local DNS -> Root DNS -> TLD DNS -> Authoritative DNS
|
Host <- Local DNS <- Root DNS <- TLD DNS <- Authoritative DNS
Each server queries the next server on behalf of the requester
and returns the result back up the chain
Iterative Query
Host -> Local DNS --query--> Root DNS
<--reply-- "Ask the TLD server"
Local DNS --query--> TLD DNS
<--reply-- "Ask the authoritative server"
Local DNS --query--> Authoritative DNS
<--reply-- "IP address: 93.184.216.34"
Host <- Local DNS (final answer)
In practice, queries from the local DNS to root/TLD/authoritative servers are iterative, while the query from the host to the local DNS is recursive -- a hybrid approach is typical.
2.5 DNS Caching
DNS caching behavior:
1. Local DNS server caches responses it receives
2. Responds directly from cache for the same name queries
3. Cache expires after TTL (Time To Live)
Effect: Most queries can be resolved without contacting root/TLD servers
3. DNS Records and Messages
3.1 DNS Resource Records (RR)
DNS databases store resource records (RRs).
Format: (Name, Value, Type, TTL)
| Type | Name | Value | Example |
|---|---|---|---|
| A | Hostname | IP address | (example.com, 93.184.216.34, A) |
| NS | Domain | Authoritative DNS server name | (example.com, dns.example.com, NS) |
| CNAME | Alias | Canonical name | (www.ibm.com, east.us.ibm.com, CNAME) |
| MX | Alias | Mail server canonical name | (example.com, mail.example.com, MX) |
3.2 DNS Message Format
+----------------------+
| Header (12 bytes) |
| ID, flags, counts |
+----------------------+
| Question section |
| Query name, type |
+----------------------+
| Answer section |
| Resource records |
+----------------------+
| Authority section |
| Authority server RRs|
+----------------------+
| Additional section |
| Additional RRs |
+----------------------+
You can perform DNS queries directly with the nslookup command:
nslookup www.example.com
4. P2P File Distribution
4.1 Client-Server vs P2P Distribution Time
Let us compare the time to distribute a file of size F to N peers.
Client-Server Approach
Server must send N copies:
D_cs >= max(NF/u_s, F/d_min)
u_s: Server upload speed
d_min: Slowest client's download speed
As N increases -> distribution time increases linearly!
P2P Approach
All peers contribute to uploading:
D_p2p >= max(F/u_s, F/d_min, NF/(u_s + sum(u_i)))
sum(u_i): Total upload capacity of all peers
As N increases -> total upload capacity also increases!
-> Distribution time increases only logarithmically
Distribution time comparison (as N increases):
Time
^
| / Client-server (linear increase)
| /
| / ___
| / ____/ P2P (sub-linear)
| / ___/
|//
+---------------------> N (number of peers)
4.2 BitTorrent
The most widely used P2P file distribution protocol.
BitTorrent terminology:
- Torrent: The set of peers participating in file distribution
- Tracker: A server that tracks peers in the torrent
- Chunk: A piece of the file (typically 256KB)
Key Mechanisms
1. Rarest First:
A peer requests the rarest chunks from its neighbors first
-> Increases copies of rare chunks -> Improves availability
2. Tit-for-Tat:
Prioritizes sending data to the 4 peers providing the fastest data
-> Prevents free-riding
3. Optimistic Unchoking:
Every 30 seconds, randomly unchokes one additional peer
-> Gives new peers a chance to participate
5. Distributed Hash Table (DHT)
5.1 DHT Concept
A database that stores key-value pairs in a distributed manner across a P2P system.
Regular hash table:
key -> hash(key) -> bucket -> value
Distributed hash table:
key -> hash(key) -> responsible peer -> value
Each peer is responsible for a portion of the key space
5.2 Circular DHT
Peers arranged in a circle (0 to 2^n - 1):
0
/ \
15 1
/ \
14 2
| |
13 3
| |
12 4
\ /
11 5
\ /
10--9--8--7--6
Key k is assigned to the closest peer >= k
Example: Key 11 -> Peer 12 is responsible
Query Process
If Peer 3 wants to find the value for key 11:
Peer 3 -> Peer 4 -> Peer 5 -> ... -> Peer 12
Queries forwarded sequentially to successor peers
-> O(N) messages needed (inefficient)
Improvement with Shortcuts
Each peer maintains a few shortcuts:
Peer 3's shortcuts: Peer 4, Peer 8, Peer 14
Peer 3 -> Peer 8 -> Peer 12 (3 steps)
-> Reduced to O(log N) messages
6. Summary
Email system:
+-- SMTP: Push transfer between mail servers (port 25)
+-- POP3/IMAP/HTTP: Users read mail (Pull)
+-- 7-bit ASCII, extended via MIME
DNS:
+-- Hostname -> IP address translation
+-- Hierarchical distributed database
+-- Root -> TLD -> Authoritative DNS servers
+-- Iterative/recursive queries
+-- Caching for performance improvement
P2P:
+-- Self-scalability (more peers -> more capacity)
+-- BitTorrent: Chunk-based, Tit-for-Tat
+-- DHT: Distributed key-value store
7. Review Questions
Q1. What are the three types of DNS servers and their roles?
- Root DNS server: The top of the DNS hierarchy. Provides IP addresses of TLD servers.
- TLD (Top-Level Domain) server: Handles top-level domains like .com, .org, .kr. Provides IP addresses of authoritative DNS servers.
- Authoritative DNS server: Directly holds hostname-to-IP mappings for a specific organization and provides the final answer.
Q2. What is the key difference between SMTP and HTTP?
- HTTP: A Pull protocol. The client retrieves data from the server.
- SMTP: A Push protocol. The sending mail server pushes data to the receiving mail server.
- HTTP can directly transfer binary data, but SMTP only allows 7-bit ASCII.
- HTTP sends each object in a separate response, but SMTP includes all objects in a single message.
Q3. Why is P2P file distribution more efficient than client-server?
In P2P, peers that are downloading the file simultaneously upload to other peers as well. As the number of peers increases, the total upload capacity of the system also increases, so the distribution time grows sub-linearly rather than linearly.