Chapter-2
Application Layer
What is DNS?
• DNS is a hierarchical and distributed naming system that translates domain names into IP
addresses.
• DNS stands for Domain Name System
• It is like the phonebook of the Internet
• It converts: Website name → IP Address
Example:
[Link] → [Link]
→DNS changes website names into IP addresses so computers can find each other.
WHY DNS IS NEEDED?
Without DNS:
We would have to remember only numbers (IP addresses)
Example: [Link] instead of [Link]
With DNS:
We use easy names, computers use numbers
Real-Life Example:
Like searching a person’s name in your phone to get their number.
NAME SPACE – HIERARCHICAL NAME SPACE
What is a Name Space?
• A Name Space is the total collection of all names used on the Internet.
It includes:
All website names
All domain names
All subdomain names
All host (computer) names
Examples of names inside the DNS Name Space:
[Link]
[Link]
[Link]
[Link]
What is a Hierarchical Name Space?
• Hierarchical Name Space means that all DNS names are arranged in the form of a tree structure,
like a family tree.
It has:
Top level → Root
Middle level → Domains
Lower level → Subdomains and computers
This structure helps DNS:
➢ Search names easily
➢ Organize billions of websites properly
➢ Avoid name duplication
Example:
Level Name Meaning
Top . Root (top of DNS)
Next com Top-Level Domain
Next google Domain name
Last www Host / Subdomain
Why is DNS Hierarchical?
DNS uses hierarchy because:
• It makes the system scalable (works for billions of websites)
• It makes name searching faster
• It allows distributed control
• It avoids name conflicts
• It helps divide work among DNS servers
Example:
• If all website names were stored in one server, it would:
• Be very slow
• Crash easily
• Be impossible to manage
School Example DNS Example Meaning
Education Board Root (.) Top of the internet
School Type (.com, .in) Domain Type of website
School Name (google) Subdomain Website name
Class (www) Host Specific service
Student Computer Exact computer/server
DOMAIN NAME SPACE – LABEL, DOMAIN NAME, FQDN, PQDN
1. Label:
• A label is each individual part of a domain name.
• Labels are separated by dots (.)
• Each label can be up to 63 characters
[Link]
www → label
google → label
com → label
So, a domain name is made of multiple labels joined together.
2. Domain Name
• A domain name is a logical name given to a group of computers or servers on the Internet.
• It represents an administrative area under one control.
Examples:
[Link]
[Link]
[Link]
A domain name always consists of at least two labels.
3. FQDN – Fully Qualified Domain Name
• An FQDN is the complete and exact domain name that shows the full path from host to root.
• It ends with a dot (.), which represents the root.
Example:
[Link].
www → host
google → domain
com → top-level domain
. → root
4. PQDN – Partially Qualified Domain Name
• A PQDN is an incomplete domain name
• It does NOT include the root dot
Example:
[Link]
This is the form that normal users type, but technically it is not fully qualified.
Distribution of Domain Name Space:
DNS is called a distributed database system because domain information is not stored at one place. It
is distributed across many DNS servers worldwide.
1. Hierarchy of Name Servers:
DNS servers are arranged in a hierarchical order:
2. Zone
• A zone is a part of the domain name space that is managed by a specific DNS server.
• A zone contains:
• Domain names
• IP addresses
• Mail server details
Example:
[Link] is one zone
[Link] is another zone
One DNS server can manage one or more zones.
3. Root Server
• Root servers are the topmost DNS servers.
• They do not store IP addresses of websites, but they know:
• Which server handles .com
• Which server handles .in, .org, etc.
Example:
When a DNS request starts, it always begins with a root server if the IP is not cached.
4. Primary Name Server
• The primary server stores the original zone file.
• All updates and changes are done only on the primary server.
5. Secondary Name Server
• The secondary server is a backup of the primary server.
• It copies data from the primary server.
Used when:
Primary server fails
Load becomes too high
This provides reliability and availability in DNS.
DNS in Internet: Generic , Country and Inverse Domain:
1. Generic Domains (gTLD – Generic Top-Level Domains):
Domain Used For
.com Commercial
.org Organization
.edu Education
.gov Government
.net Network services
Examples:
• [Link]
• [Link]
• [Link]
2. Country Domains (ccTLD – Country Code Top-Level Domains)
These represent specific countries
Country Domain
India .in
USA .us
UK .uk
Japan .jp
Examples:
[Link]
[Link]
[Link]
They are used by national websites and government portals.
3. Inverse Domain (Reverse DNS)
Normally: Domain Name → IP Address
But in Inverse DNS : IP Address → Domain Name
Example: IP Address: [Link]
Domain Name: [Link]
Uses of Inverse DNS:
• Email verification
• Network troubleshooting
• Cyber security checks
What is DNS Resolution?
• DNS Resolution is the process of finding an IP address for a given domain name
“DNS resolution is the step-by-step process of converting a domain name into an IP address.”
What is a Resolver?
• A resolver is a DNS client.
• It is a software component that sends DNS queries on behalf of the user.
Where is the Resolver?
• Inside your computer, your mobile phone, your ISP’s DNS server
What does it do?
• Takes domain name from user
• Finds the correct IP address
• Returns it to the application (browser)
Example:
When you type [Link],
the resolver starts the DNS lookup process.
MAPPING NAMES TO ADDRESSES (Forward Lookup)
Converting domain name → IP address
This is the most common DNS operation
Why needed?
• Humans understand names
• Computers understand IP addresses
Example: [Link] → [Link]
Used in:
Web browsing
Email sending
Online streaming
“Forward lookup means finding IP address from a website name.”
MAPPING ADDRESSES TO NAMES (Reverse Lookup)
Converting IP address → domain name
Also called Reverse DNS lookup
Uses:
Email server verification
Network troubleshooting
Security checking
Example: [Link] → [Link]
Reverse lookup finds the domain name for a given IP address
RECURSIVE RESOLUTION
What is Recursive Resolution?
In recursive resolution, the resolver asks a DNS server:
“Please find the final answer for me.”
The DNS server does all the work and returns the final IP address.
Responsibility:
• DNS server is responsible for full search
Example Flow:
• Client → Local DNS server
• DNS server → Root server
• DNS server → TLD server (Top-Level Domain)
• DNS server → Authoritative server
• DNS server → Client (final IP)
ITERATIVE RESOLUTION
What is Iterative Resolution?
In iterative resolution, each DNS server gives the next server’s address, not the final answer.
Responsibility:
Resolver does the searching step by step
Example Flow:
Resolver → Root server
→ gets TLD server address
Resolver → TLD server
→ gets authoritative server address
Resolver → Authoritative server
→ gets IP address
“In iterative resolution, the resolver keeps asking different DNS servers.”
Recursive Resolution Iterative Resolution
DNS server finds the final IP address for the Client/resolver finds the IP address step by
client step
Client sends one request and waits for full Client sends multiple requests to different
answer servers
DNS server does all the searching work DNS server gives next server address only
Client effort is low Client effort is high
Used between client and local DNS server Used between DNS servers
What is DNS Caching?
• Caching means storing DNS results temporarily.
• Cached answers are reused to speed up DNS resolution.
Where caching happens?
• Browser
• Operating system
• Local DNS server
• ISP DNS server
Time Limit:
Each cached entry has a TTL (Time To Live)
Example:
First time: DNS lookup takes time
Second time: IP returned instantly from cache
“DNS caching reduces delay and network traffic.”
What is Electronic Mail?
Electronic Mail (E-mail) is a service that allows users to send and receive messages electronically
over a computer network.
It is one of the oldest and most widely used Internet applications.
E-mail allows users to exchange messages and files using Internet protocols.
E-mail Architecture:
Main Components of E-mail System
1. User Agent (UA)
2. Mail Server
3. SMTP (Simple Mail Transfer Protocol)
4. POP3 / IMAP (Mail Access Protocols)
E-mail architecture shows how a message travels from sender to receiver.
FIRST SCENARIO – SENDER AND RECEIVER ON SAME MAIL SERVER
• Sender and receiver belong to the same organization
• Both use the same mail server
Working:
• Sender writes mail using User Agent
• Mail is stored in receiver’s mailbox on same server
• Receiver reads mail using User Agent
Example:
student1@[Link] → student2@[Link]
SECOND SCENARIO – DIFFERENT MAIL SERVERS
• Sender and receiver are on different mail servers
• Internet is used
Working:
• Sender UA sends mail to sender’s mail server
• Sender’s server uses SMTP
• Mail is delivered to receiver’s mail server
• Receiver reads mail using UA
Example:
user@[Link] → user@[Link]
THIRD SCENARIO – WEB-BASED E-MAIL
• User accesses e-mail using a web browser
• No separate mail software needed
Working:
• User opens browser (Chrome)
• Logs into Gmail / Outlook
• Mail is sent and received through web interface
Example:
Gmail, Yahoo Mail, Outlook Web
FOURTH SCENARIO – MOBILE E-MAIL ACCESS
• User accesses e-mail using mobile device
• Uses Internet + mobile apps
Working:
• Mail app connects to mail server
• Uses IMAP / POP3 to receive mails
• Uses SMTP to send mails
Example:
Gmail app on Android / iPhone
USER AGENT (UA)
What is a User Agent?
• A User Agent (UA) is software that allows users to compose, send, read, and manage e-mails.
Examples:
Outlook
Thunderbird
Gmail (browser)
SERVICES OF USER AGENT
Main Services:
1. Compose mail
2. Read mail
3. Reply / Forward
4. Attach files
5. Store mails
6. Manage mailbox folders
TYPES OF USER AGENTS
1. Command-Based UA
Uses text commands
Old systems
2. GUI-Based UA
Uses windows, buttons, icons
Easy to use
3. Web-Based UA
Runs inside browser
No installation required
Examples:
Command: Pine
GUI: Outlook
Web: Gmail
What is MIME?
• MIME stands for “Multipurpose Internet Mail Extensions.”
• Originally, e-mail systems were designed to send only plain text (ASCII characters).
They could not send:
Images
Audio
Video
PDF
Word files
Non-English characters
MIME was introduced to overcome these limitations.
Why MIME is Needed?
Problems with Traditional E-mail:
• Only text messages allowed
• No attachments
• No images or videos
• No support for different languages
MIME Solves These Problems By:
• Allowing attachments
• Supporting multimedia content
• Supporting different character sets
• Sending multiple data types in one mail
Sending a resume (PDF) or photo through Gmail is possible only because of MIME.
How MIME Works
MIME does not replace SMTP.
Instead
SMTP sends the mail
MIME defines how the content is formatted
Working:
MIME converts non-text data into text format
SMTP transfers it safely
Receiver decodes it back to original form
“MIME prepares the mail; SMTP delivers the mail.”
Structure of a MIME E-mail
A MIME e-mail has two main parts:
MIME Header
Added to the normal e-mail header
It tells the receiver:
What type of data is sent
How to decode it
MIME Body
Contains encoded message or attachments
What is a Message Transfer Agent (MTA)?
• A Message Transfer Agent (MTA) is software responsible for sending e-mails from one mail server
to another.
• The most common MTA protocol is SMTP.
SMTP (Simple Mail Transfer Protocol)
Purpose:
• Transfers e-mail from sender’s mail server to receiver’s mail server
• Works on port 25 (or 587 for secure transfer)
Characteristics:
• Text-based protocol
• Push protocol (sender pushes mail)
• Uses TCP for reliable delivery
SMTP Working
1. Sender composes mail using User Agent
2. Mail is sent to sender’s mail server
3. SMTP connects to receiver’s mail server
4. Mail is transferred
5. Receiver retrieves mail later using POP/IMAP
SMTP Limitations :
• Cannot retrieve e-mails
• Cannot handle attachments alone
• Needs MIME for multimedia support
MESSAGE ACCESS AGENT (MAA)
What is a Message Access Agent?
• A Message Access Agent (MAA) allows users to read and manage received e-mails.
Common protocols:
• POP
• IMAP
SMTP sends mail, POP and IMAP receive mail.
POP (Post Office Protocol)
What is POP?
• POP is used to download e-mails from mail server to user’s device.
• Current version: POP3
How POP Works:
Client connects to mail server
E-mails are downloaded
Mails are usually deleted from server
Characteristics:
• Simple
• Offline reading possible
• One-device focused
Real-World Example:
Using Outlook on one computer to download mails.
IMAP (Internet Message Access Protocol)
What is IMAP?
• IMAP allows users to access e-mails directly on the server.
• E-mails remain on server.
How IMAP Works:
1. Client connects to server
2. Mails are read directly from server
3. Changes sync across devices
Characteristics:
• Supports multiple devices
• Folder synchronization
• Requires constant internet
Real-World Example:
Accessing Gmail on mobile, laptop, and tablet.
POP vs IMAP
POP IMAP
Downloads mails Reads mails on server
Deletes mails from server Keeps mails on server
One device Multiple devices
Simple Advanced
Offline access Online access
FILE TRANSFER – FTP INTRODUCTION
What is FTP?
• FTP (File Transfer Protocol) is used to transfer files between computers.
• Uses TCP for reliable communication.
TP – COMMUNICATION OVER CONTROL & DATA CONNECTION
Two Connections in FTP:
[Link] Connection
• Used for commands (login, directory, file request)
• Uses port 21
• Remains open throughout session
2. Data Connection
• Used for actual file transfer
• Created and closed for each transfer
Files type supported by FTP:
File Type Description
ASCII Text files
Binary Images, videos, PDFs
EBCDIC Used in mainframes
Data Structures in FTP:
Structure Meaning
File Structure Continuous stream of bytes
Record Structure Divided into records
Page Structure Divided into pages
FTP- Transmission Modes:
Mode Description
Most Commonly used → Stream Mode Continuous data flow
Block Mode Data sent in blocks
Data compressed before
Compressed Mode
sending