0% found this document useful (0 votes)
9 views

Application Layer Notes

Uploaded by

shiwanshshukla25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Application Layer Notes

Uploaded by

shiwanshshukla25
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 51

Application Layer Notes

1. Introduction to the Application Layer

The Application Layer is the topmost layer in both the OSI and TCP/IP models, where all the
applications operate. It provides the interface for end-user processes to access network services, making
it crucial for enabling communication between software applications on different devices.

AK
2.1 Traditional Paradigm: Client-Server

AY
The traditional paradigm in the application layer is known as the Client-Server Paradigm. In this
setup:

N
● Server Process: The server process is a continuously running application that waits for requests
from client processes. It serves multiple clients by providing specific services, such as web hosting, file

LP
transfer, or email.
● Client Process: The client process initiates the connection to the server, requesting specific

needed.

KA
services. Unlike the server, the client process runs temporarily and is active only when a service is

Example: Consider a telephone directory service. The directory center (server) is always
N
available to provide phone numbers to subscribers (clients) who call in for information. The server must
SA

be continuously running, while the clients only connect when they need the service.
BY
S
TE
O
N
N

Figure 1: Client-Server Communication Example


C

(Reference: Data Communications and Networking by Behrouz A. Forouzan)

2.2 Peer-to-Peer Paradigm

In the Peer-to-Peer (P2P) Paradigm, there is no dedicated server that remains active all the time.
Instead, each participant (peer) can act as both a client and a server, sharing the responsibilities equally.

● Dynamic Role: A peer can provide a service at one time and request a service at another. It is
also possible for a peer to provide and receive services simultaneously.
● Example: Phone communication is inherently peer-to-peer, where neither party waits passively
for the other to initiate communication. Similarly, in a file-sharing scenario over the Internet, users can
share files directly with each other without the need for a central server.

AK
AY
N
Figure 2: Peer-to-Peer Communication Example

LP
(Reference: Data Communications and Networking by Behrouz A. Forouzan)

3. Client-Server Programming
KA
In the client-server paradigm, communication at the application layer occurs between two running
N
application programs, known as processes:
SA

● Client Process: Initiates communication by sending requests to the server. The client’s lifetime
is finite, ending once it has completed its transactions with the server.
BY

● Server Process: Responds to client requests, processes them, and sends back the results. The
server’s lifetime is theoretically infinite, as it remains active to handle incoming requests.

4. Application Programming Interface (API)


S
TE

To enable communication between processes, a set of instructions known as an Application


Programming Interface (API) is used. An API serves as the interface between the application layer
O

processes and the operating system, facilitating the execution of network functions like opening
connections, transmitting data, and closing connections.
N

● Functionality: APIs allow processes to communicate with the underlying network protocols
N

embedded in the operating system.


C

● Common APIs: The most widely used APIs include the Socket Interface, Transport Layer
Interface (TLI), and STREAM.

4.1 Socket Interface

The Socket Interface is a widely used API developed in the early 1980s at UC Berkeley as part of the
UNIX operating system. It provides a set of instructions for establishing communication between the
application layer and the operating system.
● Function: Sockets act as endpoints in the communication process, allowing a client process and
a server process to exchange data.
● Example: In programming languages like C, C++, or Java, sockets are used to create
communication channels between processes, similar to how data is read from or written to files or
devices.

5. Socket Addresses

In a client-server communication model, both the client and server need specific addresses, known as
Socket Addresses, to establish a connection.

AK
● Local Socket Address: For the server, the local socket address is determined by the operating

AY
system, which includes the server's IP address and the assigned port number.
● Remote Socket Address: The remote socket address is the address of the client requesting
service. The server identifies this address when a client initiates a connection.

N
● IP and Port: Socket addresses consist of an IP address to identify the host and a port number to

LP
identify the specific application process on that host.

KA
N
HyperText Transfer Protocol (HTTP)
SA

Introduction to HTTP
BY

HyperText Transfer Protocol (HTTP) is the foundational protocol used for transmitting web pages
on the World Wide Web. It defines how requests and responses are formatted and transmitted between
S

clients and servers.


TE

● HTTP Client: The entity that initiates the request, typically a web browser or other application.
● HTTP Server: The entity that processes the request and returns the corresponding response,
O

usually a web server.


N

HTTP operates on port 80 by default and uses the services of TCP (Transmission Control Protocol),
which provides a reliable, connection-oriented communication channel.
N

Connection Types in HTTP


C

HTTP connections can be categorized into two main types:

1. Non-Persistent Connections

In a non-persistent connection, a new TCP connection is established for each request-response pair.
This approach, while straightforward, can result in significant overhead due to the repeated establishment
and termination of connections.
Steps in Non-Persistent Connection:

1. The client opens a TCP connection to the server.


2. The client sends an HTTP request over this connection.
3. The server processes the request and sends back an HTTP response.
4. The server then closes the TCP connection.
5. The client reads the data until the end-of-file (EOF) marker is encountered, then closes its end of
the connection.

Example: If a web page contains multiple resources (e.g., images), and all resources are hosted on the

AK
same server, the client must establish a separate connection for each resource. For a page with N images,
this would require N + 1 connections.

AY
Drawbacks of Non-Persistent Connections:

N
● High overhead due to the repeated establishment and termination of connections.
● Increased server load as multiple buffers and resources are required to handle the numerous

LP
connections.

KA
N
SA
BY
S
TE
O
N
N

Fig3: Nonpersistent connection


C

2. Persistent Connections

Persistent connections, introduced in HTTP/1.1, allow a single TCP connection to remain open for
multiple requests and responses, reducing the overhead associated with non-persistent connections.

Features of Persistent Connections:

● The connection remains open after the initial request/response, allowing the client to send
multiple requests without needing to re-establish the connection.
● The server can close the connection at the client's request or after a timeout period.
● Time and resource consumption are reduced, as only one set of buffers and variables is needed
per connection.
● The round-trip time (RTT) for connection establishment and termination is saved, enhancing
performance.

AK
AY
N
LP
KA
N
SA

Fig4: Persistent connection.


BY

RTT (Round Trip Time): RTT is the time taken for a packet to travel from the client to the server and
back again. Persistent connections help minimize the RTT by reducing the number of connections that
need to be established and terminated.
S
TE

Example of Persistent Connection: In a scenario where a client requests a webpage containing


multiple resources (e.g., images), only one connection establishment and termination are required, but
O
N
N
C
the requests for the images are sent separately over the same connection.

AK
AY
N
LP
KA
N
SA
BY
S
TE

HTTP Messages
O

HTTP defines two types of messages:


N

1. Request Messages
2. Response Messages
N
C

Both types of messages follow a structured format.


AK
AY
N
LP
KA
N
SA

1. HTTP Request Message


BY

An HTTP request message is composed of several parts:

● Request Line: The first line of the request, which includes three fields:
S

○ Method: The action the client wants to perform (e.g., GET, POST).
TE

○ URL: The Uniform Resource Locator, which specifies the resource being requested.
○ Version: The HTTP version being used (e.g., HTTP/1.1).
O

Example:
N

GET /index.html HTTP/1.1


Request Header Lines: These lines provide additional information about the request. Each header line
N

consists of a name, a colon, a space, and a value.


C

Example:
Host: www.example.com
User-Agent: Mozilla/5.0

● Message Body: This optional part of the request is used to send data to the server, often used
with methods like POST or PUT.

Common HTTP Methods:

● GET: Requests data from a specified resource. The request body is typically empty.
● HEAD: Similar to GET, but only the headers are returned, not the body. Used to check if a
resource is available or modified.
● POST: Submits data to be processed to a specified resource.
● PUT: Uploads a representation of the specified resource.
● DELETE: Removes the specified resource.
● OPTIONS: Returns the HTTP methods that the server supports.
● TRACE: Echoes back the received request, used for debugging.
● CONNECT: Converts the request connection to a transparent TCP/IP tunnel, typically used
with SSL.

AK
2. HTTP Response Message

AY
An HTTP response message consists of several parts:

● Status Line: The first line of the response, which includes three fields:

N
○ Version: The HTTP version (e.g., HTTP/1.1).
○ Status Code: A three-digit code indicating the result of the request (e.g., 200 for OK).

LP
○ Status Phrase: A textual description of the status code.

KA
Example:
HTTP/1.1 200 OK
Response Header Lines: These lines provide additional information about the response. Similar to
N
request headers, each line consists of a name, a colon, a space, and a value.
SA

Example:
Content-Type: text/html
Content-Length: 1234
BY

● Message Body: The body of the response, which contains the requested resource (e.g., HTML
document, image, etc.).
S

Common HTTP Status Codes:


TE

● 1xx: Informational: Request received, continuing process (e.g., 100 Continue).



O

2xx: Success: The request was successfully received, understood, and accepted (e.g., 200 OK,
201 Created).
N

● 3xx: Redirection: Further action needs to be taken to complete the request (e.g., 301 Moved
Permanently, 302 Found).
N

● 4xx: Client Error: The request contains bad syntax or cannot be fulfilled (e.g., 400 Bad
C

Request, 404 Not Found).


● 5xx: Server Error: The server failed to fulfill a valid request (e.g., 500 Internal Server Error,
503 Service Unavailable).

Cookies

● Cookies are small text files sent by a web server to the browser. They help maintain state and user
preferences across different web sessions.
● Cookies are an essential mechanism in modern web applications, enabling servers to maintain a session
with a client over multiple requests. The World Wide Web was originally designed as a stateless
system, where each interaction between a client (browser) and server was isolated. However, as web
applications evolved, the need to store information about clients across multiple requests emerged.

Here's a deeper explanation of their lifecycle:

Purpose:

● Session Management (e.g., user logins).


● Personalization (e.g., language or theme preferences).
● Tracking and Analytics (e.g., browsing habits for targeted advertising).

AK
Purpose of Cookies

AY
Cookies are small pieces of data sent from a server to a client and stored on the client’s device. They
allow the server to remember information about the client across multiple requests. Here are common

N
purposes for cookies:

LP
● E-commerce: Cookies track items added to a shopping cart across different pages of a website.
● Portals: Cookies store a user's preferences, such as chosen pages or personalized settings.
● Restricted Access: Websites requiring login credentials store session data in cookies to identify
returning users.
● KA
Advertising: Cookies are used by advertising agencies to track user behavior and deliver
N
targeted ads.
SA

How Cookies Work

The lifecycle of a cookie involves three key steps:


BY

1. Creation: When a client (browser) sends an HTTP request to a server, the server generates a
cookie containing client-related information, such as an ID, domain name, or other session data.
S

2. Storage: The server includes the cookie in the response sent to the client. The client browser
TE

then stores this cookie in its cookie directory, organized by domain name.
3. Usage: On subsequent requests to the same server, the client sends the stored cookie back to the
server, allowing the server to recognize the returning client and retrieve the relevant information.
O

Example of Cookie Usage


N
N
C
AK
AY
N
LP
KA
N
SA
BY

In an e-commerce setting, suppose a user is shopping for toys on a website like BestToys.com:
S

● When the user first selects a toy, the server generates a shopping cart ID (e.g., 12343) and sends
it in a cookie.
TE

● As the user adds more items, the server updates the cookie with the new selections.
● When the user checks out, the server retrieves the final cookie with all selected items, calculates
O

the total, and processes the payment.



N

If the user returns later, the cookie with ID 12343 is sent to the server, and the server can reload
the user's previous shopping cart and preferences.
N

Security and Privacy Concerns


C

Cookies can store sensitive information, which raises privacy concerns. For example, cookies used by
advertising agencies can track user behavior across different websites, profiling users without their
explicit consent. Many modern browsers now offer options to block third-party cookies, and regulations
such as GDPR in Europe mandate stricter rules for cookie usage.

Web Caching: Proxy Servers


● A caching proxy server stores copies of frequently requested web resources, reducing load times and
bandwidth consumption by serving cached content instead of fetching it from the origin server.
● Proxy servers serve as intermediaries between clients and web servers. They store cached copies of web
pages or other content to reduce load times, conserve bandwidth, and improve overall web performance.

What is a Proxy Server?

A proxy server is a computer system that caches responses from web servers and serves those cached
responses to clients when requested again. It acts as both a client (fetching resources from the server) and
a server (providing resources to clients).

Benefits of Proxy Servers

AK
1. Reduced Load on Servers: By serving cached content, proxy servers can reduce the number of
requests that reach the original web server.

AY
2. Decreased Network Traffic: A proxy server can store frequently accessed content, preventing
redundant data transfer.

N
3. Improved Response Time (Latency): Cached content can be served faster, reducing the time
clients wait for a response.

LP
How Caching Proxy Servers Work:


● KA
Step 1: When a user requests a resource, the proxy server checks if it’s cached.
Step 2: If the cached version is available and valid, the proxy sends the resource without
N
contacting the origin server.
SA

● Step 3: If not cached or expired, the proxy fetches the resource, serves it to the user, and caches
it for future use.

Types of Caching Proxy Servers:


BY

1. Forward Proxy: Handles requests from clients to the web, caching resources for multiple
clients.
S

2. Reverse Proxy: Sits between the internet and the web server, caching responses for faster client
TE

access.

Cache-Control Headers in HTTP:


O
N

● The Cache-Control header is used to specify caching policies for both HTTP requests and
responses.
N

● It controls how responses are stored, fetched, and revalidated by caches.


C

If-Modified-Since & Last-Modified in HTTP:

1. If-Modified-Since:
○ A request header used by the client to ask if the resource has been modified since a specific
date.
○ If the resource has not changed, the server responds with 304 Not Modified.
○ Helps in reducing unnecessary data transfer.
2. Last-Modified:
○ A response header indicating when the resource was last modified.
○ Clients use this value in subsequent requests through If-Modified-Since to check for updates.

Example Flow:

● The server sends Last-Modified in a response.


● The client includes If-Modified-Since in the next request to check if the resource has

How Proxy Servers Work

1. When a client requests a resource, the request is first sent to the proxy server.

AK
2. If the proxy has a cached copy of the requested resource, it returns the cached response without
contacting the original server.

AY
3. If the proxy doesn’t have the resource, it forwards the request to the original web server, fetches
the response, caches it, and then serves it to the client.

N
Example of Proxy Server Usage

LP
In a large organization, a proxy server may be installed on the local area network (LAN). When
employees request web pages, the proxy server first checks if the requested page is cached:


KA
If available, the cached page is served to the employee without the need to contact the external
web server.
N
● If unavailable, the proxy forwards the request to the original server on the internet, retrieves the
page, and then caches it for future use.
SA

Proxy Server Hierarchy


BY

Proxy servers can be placed at multiple levels:

1. Client-Level Proxy: A proxy server can be configured directly on a client machine, typically to
S

cache frequently visited pages locally.


2. LAN-Level Proxy: A proxy server within a company network reduces traffic going to and from
TE

the internet for all devices within the network.


3. ISP-Level Proxy: Internet Service Providers (ISPs) may use proxy servers to serve cached
O

content to their customers, reducing bandwidth usage and speeding up response times.
N

Cache Update Strategies


N

A key challenge for proxy servers is determining how long to keep cached content before refreshing it.
C

Common strategies include:

● Time-Based Expiration: Some websites (e.g., news sites) change their content at regular
intervals, such as daily. A proxy can be set to refresh its cache after a specified period, like 24 hours.
● Conditional Requests: Proxies may send a conditional request to the original server, asking if the
cached content has changed. If unchanged, the proxy continues to use the cached copy.

Security and Control with Proxy Servers

Proxy servers can also offer additional security benefits, such as:
● Content Filtering: Companies or organizations can configure proxies to block access to certain
websites.
● Anonymity: Proxy servers can anonymize client requests, masking the client's IP address when
accessing external servers.

Introduction to DNS

Introduction: The Domain Name System (DNS) is a hierarchical and decentralized


system that is essential for the functioning of the internet. It translates human-readable

AK
domain names (such as www.example.com) into machine-readable IP addresses (such as
192.168.1.1). This conversion allows users to access websites, send emails, and utilize

AY
other online services without memorizing complex numerical IP addresses.

Why DNS is Important: Since humans prefer easy-to-remember names over long

N
numerical IP addresses, DNS acts as a phonebook for the internet. Every time a user

LP
types a domain name into their browser, the DNS system finds the corresponding IP
address to connect them to the correct server. Without DNS, users would have to
manually type in IP addresses, making internet navigation highly inefficient.

Working of DNS KA
N
SA
BY
S
TE
O
N

The DNS system maps hostnames to IP addresses, and the following six steps illustrate
N

how this process works, particularly in the context of a file transfer:


C

1. User Input:
The user provides the hostname (e.g., ftp.example.com) to the file transfer client.
2. DNS Query Initiation:
The file transfer client forwards the provided hostname to the DNS client on the
user's machine.
3. DNS Client Request:
Every computer, upon booting, knows the address of at least one DNS server. The
DNS client sends a query to this known DNS server, requesting the IP address for
the file transfer server using the hostname.
4. DNS Server Response:
The DNS server processes the query and responds with the IP address
corresponding to the requested file transfer server hostname.
5. IP Address Delivery:
The DNS client receives the IP address from the DNS server and passes it back to
the file transfer client.
6. File Transfer:
The file transfer client then uses the provided IP address to establish a connection
with the file transfer server, enabling the transfer of files.

AK
AY
N
DNS Communication: UDP vs. TCP

LP
DNS can use either UDP or TCP to communicate, depending on the type of request or

KA
the size of the response. Here's a breakdown of when each protocol is used:

DNS over UDP (User Datagram Protocol)


N
UDP is the primary transport layer protocol for DNS queries. It is preferred because of its
SA

lower overhead, making it faster and more efficient for small, quick transactions.

● Standard Queries: Most DNS lookups, such as when a user wants to resolve a
BY

domain name to its IP address, are performed over UDP. This is because these
queries usually involve small data packets and do not require the reliability of
TCP.
S

● Port Number: DNS queries typically use port 53 for communication over UDP.
TE

● Why UDP? UDP is connectionless, meaning no handshake is needed, which


reduces the delay in query/response communication. Additionally, most DNS
responses are small (under 512 bytes), making UDP a suitable choice.
O
N
N

DNS over TCP (Transmission Control Protocol)


C

TCP is used in DNS for specific types of transactions where reliability and data integrity
are more critical than speed.

● Zone Transfers: When DNS servers need to transfer large sets of DNS data
between them (such as during a Zone Transfer), TCP is used to ensure that the
entire dataset is transferred correctly. This is common during AXFR (Full Zone
Transfer) or IXFR (Incremental Zone Transfer).
● Long Responses: When a DNS response exceeds 512 bytes, such as for DNSSEC
(DNS Security Extensions) records or responses containing a large number of IP
addresses, the DNS server switches from UDP to TCP to guarantee complete and
reliable delivery. TCP is a connection-oriented protocol, ensuring all data is
delivered accurately.
● Port Number: Like UDP, DNS over TCP also uses port 53.

1. DNS Structure and Components

Key Components of DNS

AK
1. DNS Protocols:
○ UDP for Queries:

AY
■ Most DNS queries are made using UDP on port 53, as it is faster and
efficient for small transactions.
○ TCP for Larger Transactions:

N
■ When DNS responses exceed 512 bytes or involve zone transfers
(like AXFR and IXFR), TCP is used for reliable delivery.

LP
DNS Name Space
KA
N
The DNS name space ensures that every machine and IP address has a unique,
SA

unambiguous name.

Types of Name Spaces:


BY

1. Flat Name Space:


○ Names are assigned as sequences of characters without any internal
structure.
S

○ Disadvantage: It is unsuitable for large systems (like the internet) because


TE

it would need to be centrally controlled to avoid name duplication.


2. Hierarchical Name Space:
○ Each name is made up of several parts, which can represent organizations,
O

departments, or resources.
N

○ Advantage: Decentralized control allows each organization to manage its


own part of the name, ensuring uniqueness even when some parts are
N

similar.
C

○ Structure: Central authority manages the higher levels (e.g., .com), while
individual organizations control lower levels (e.g., example.com).

Domain Name Space

To support a hierarchical structure, the DNS uses an inverted tree structure called the
Domain Name Space.
1. Labels:
○ Each node in the DNS tree has a label, a string with up to 63 characters.
○ The root node’s label is a null string (empty).
○ Child nodes must have unique labels to guarantee the uniqueness of domain
names.
2. Domain Names:
○ A domain name is a sequence of labels separated by dots (e.g.,
www.example.com).
○ Domain names are read from the node to the root, with the last label being

AK
the root (represented by a dot).
■ Fully Qualified Domain Name (FQDN): A domain name that ends
with a dot (e.g., www.example.com.).

AY
■ Partially Qualified Domain Name (PQDN): A domain name that
doesn’t end with a dot (e.g., www.example).

N
LP
Domain and Zone

1. Domain:
KA
○ A domain represents a subtree in the DNS hierarchy. For example, in the
N
domain example.com, “example” is a second-level domain under the
top-level domain .com.
SA

○ Domains can be further divided into subdomains (e.g., mail.example.com).


2. Zone:
○ A zone is the portion of the domain name space that a specific DNS server
BY

is responsible for managing.


○ Example: If a DNS server manages example.com and its subdomains, it
controls the example.com zone unless it delegates some of its authority
S

(like subdomains) to other servers.


TE

Distribution of Name Space


O

● Storing all DNS information on a single server would be inefficient and unreliable.
N

To solve this problem, the DNS name space is distributed among many DNS
servers.
N

Hierarchy of Name Servers:


C

● Root Servers:
○ The root level of DNS servers controls the top of the DNS hierarchy,
represented by a dot (.).
● TLD Servers:
○ These servers manage top-level domains (TLDs) like .com, .org, and
country codes like .us, .uk.
● Authoritative Servers:
○ These servers are responsible for specific domains (e.g., example.com) and
provide authoritative responses for them.

Zone and Authority

● Zone: The part of the DNS namespace that a DNS server has authority over is
called a zone.
● Authority and Delegation: If a DNS server divides its domain into subdomains,
the responsibility for those subdomains can be delegated to other servers.
However, the original server still retains some oversight of the zone.

AK
AY
N

LP
KA
N
SA
BY
S
TE
O
N

The diagram you uploaded illustrates the hierarchical structure of the Domain Name
N

System (DNS), breaking down how domains and zones are organized from the root level
down to subdomains. Here's an explanation of the diagram step by step:
C

1. Root Domain (.)

● At the very top of the hierarchy is the Root Domain, represented by a single dot
(.).
● This is the starting point for all domain name lookups and forms the base of the
DNS tree.
● All other domain names in DNS are subdomains of the root domain.
2. Top-Level Domains (TLDs)

● Directly under the root domain, we have Top-Level Domains (TLDs) such as:
○ .com
○ .edu
○ .arpa
● Each TLD represents a high-level domain, where:
○ .com is generally for commercial entities.
○ .edu is typically for educational institutions.

AK
○ .arpa is used for technical infrastructure purposes.
● Each TLD is part of its own zone. For example, the .com zone contains all the
domains directly under the .com TLD.

AY
3. Second-Level Domain (example.com)

N
● Moving down from the TLD level, we see the domain example.com under the

LP
.com zone.
● The domain example.com is a second-level domain, which is a direct child of the
.com TLD.

KA
● The example.com domain also forms its own zone (example.com zone), which
holds the information about any subdomains beneath it.
N
4. Subdomains (a.example.com, b.example.com, c.example.com)
SA

● Under the example.com domain, we have several subdomains:


○ a.example.com
BY

○ b.example.com
○ c.example.com
● Each of these subdomains can belong to its own zone.
S

○ a.example.com zone
TE

○ b.example.com zone
○ c.example.com zone
● These subdomains are children of the example.com zone, but they have their own
O

zones that manage further sub-subdomains or configurations specific to them.


N

5. Zones and Domains


N

● Domains represent names or labels (e.g., example.com or a.example.com),


C

whereas zones represent areas of authority or control for DNS records.


● A zone is the portion of the domain name space that is managed by a specific DNS
server. A domain can be part of multiple zones, as demonstrated in the diagram.
● For example, example.com belongs to the .com zone, but it also manages its own
example.com zone for subdomains like a.example.com.

DNS Servers Overview:

1. Root Servers:
○ A Root Server is at the top of the DNS hierarchy and whose zone consists
of the entire DNS tree.
○ It does not store specific domain information but delegates authority to
other servers, keeping references to them.
○ There are more than 13 root servers, distributed worldwide, covering the
whole domain name space. These servers direct queries to TLD servers.
○ Root servers are identified as a.root-servers.net to m.root-servers.net.

AK
2. Primary and Secondary Servers:
○ Primary Server:

AY
■ A server responsible for creating, maintaining, and updating the
zone file for which it has authority.

N
■ It stores the zone file on its local disk and loads all information from
this disk.

LP
■ The primary server is the only server that can make updates to the
zone file and distribute them to secondary servers.
○ Secondary Server:

KA
■ A server that transfers a copy of the zone information from a
primary or another secondary server.
N
■ It stores the file on its local disk but relies on the primary server for
SA

updates.
■ Updates to the zone file must be made on the primary server, which
then sends the updated version to the secondary.
3. DNS in the Internet:
BY

DNS operates on different platforms, and on the Internet, the domain name space
is divided into three sections:
○ Generic Domains:
S

■ Define registered hosts based on their generic behavior.


TE

■ Each node in the tree represents a domain, and the first level
includes seven possible three-character labels, which indicate the
O

type of organization.
■ Examples of TLDs in this section: .com, .org, .net.
N

○ Country Domains:
■ Similar to generic domains but use two-character country codes
N

instead of organizational abbreviations.


C

■ Examples: .in for India, .us for the United States.


■ Some countries use more specific designations; for example, India
may use state abbreviations (e.g., ca.in for a specific region).
○ Inverse Domains:
■ Used for mapping an IP address to a domain name.
■ This is also called PTR (Pointer) query, where a client sends an IP
address to be mapped back to a domain name.
4. TLD Servers:
○ Manage Top-Level Domains (TLDs) like .com, .org, and .edu.
○ Handle queries for domains under their specific TLD and direct them to
authoritative DNS servers for second-level domains.
○ TLDs are categorized into:
■ Generic TLDs (gTLDs): For general use (e.g., .com, .org, .net).
■ Sponsored TLDs (sTLDs): Restricted to specific organizations
(e.g., .edu, .gov).
■ Country Code TLDs (ccTLDs): Specific to countries (e.g., .in, .us,
.uk).
■ New gTLDs: Custom, newer domains (e.g., .shop, .tech).

AK
5. Primary Root Server:
○ The primary root server is the main server responsible for maintaining the
original, authoritative copy of the DNS root zone file.

AY
○ It manages updates and distributes these updates to secondary root servers.
○ Example: One of the primary root servers is a.root-servers.net.

N
6. Secondary Root Server:
○ A secondary root server is a replica of the primary root server.

LP
○ It holds a copy of the DNS root zone file and helps distribute the
information globally, providing redundancy.

KA
○ Secondary servers help balance the load, ensuring efficiency and
availability.
7. Authoritative DNS Servers:
N
○ Store the DNS records for specific domains and provide the final answer,
SA

such as the IP address of the requested domain.




BY

DNS Resolution Process

DNS resolution is the process of converting a domain name into its corresponding IP
S

address. The steps of DNS resolution are as follows:


TE

3.1 User Query


O

● A user enters a domain name (e.g., www.example.com) in their web browser.


N

● The browser sends a query to the local DNS resolver, which is usually provided
by the user's ISP.
N

Understanding DNS resolution is key to comprehending how domain names are


C

translated into IP addresses. There are two primary methods for DNS resolution:

● Recursive Resolution
● Iterative Resolution

Note:

● A DNS client is the component that initiates the request to resolve a domain name.
● A DNS resolver is the system or server that handles the query, performs the
lookup, and returns the result to the client.

1. Recursive DNS Resolution

1.1 Definition

In recursive DNS resolution, the DNS resolver takes full responsibility for resolving the

AK
requested domain name. It queries multiple DNS servers until the final answer (IP
address) is obtained and then returns it to the client. In this method, the client sends a

AY
single request to the resolver, and the resolver performs all the necessary queries on
behalf of the client.

N
LP
1.2. Detailed Explanation and Steps

KA
N
SA
BY

DNS Resolution Process


S
TE

1. Client Request:

1.1. Initiation:
O
N

● A client (e.g., web browser) initiates a DNS query to obtain the IP address for a
domain name (e.g., www.example.com).
N

● The query is sent to a recursive DNS resolver, which is typically provided by the
ISP or configured manually.
C

2. Resolver Cache Check:

2.1. Cache Verification:

● The recursive resolver first checks its cache to see if it already has the IP address
for the requested domain.
● If cached: The resolver returns the IP address to the client immediately.
● If not cached: The resolver proceeds with further queries to other DNS servers.
3. Query to Root DNS Server:

3.1. Root Server Query:

● If the information is not cached, the resolver sends a query to a root DNS server.
● The query requests information about the top-level domain (TLD) server
responsible for the domain.
● Response: The root server responds with the IP address of the appropriate TLD
server (e.g., for .com domains).

AK
4. Query to TLD DNS Server:

4.1. TLD Server Query:

AY
● The resolver then sends a query to the TLD DNS server for the domain (e.g.,

N
.com).
● The query asks for the authoritative DNS server responsible for the specific

LP
domain (e.g., example.com).
● Response: The TLD server provides the IP address of the authoritative DNS

KA
server for example.com.

5. Query to Authoritative DNS Server:


N
5.1. Authoritative Server Query:
SA

● The resolver queries the authoritative DNS server for the exact IP address of
www.example.com.
BY

● Response: The authoritative server returns the IP address associated with


www.example.com.
S

6. Returning the Result:


TE

6.1. Caching and Response:


O

● The resolver caches the IP address for future requests, respecting the
Time-To-Live (TTL) value.
N

● The resolver sends the IP address back to the client.


N

7. Client Accesses the Website:


C

7.1. Website Connection:

● The client (e.g., browser) uses the IP address to establish a connection to the web
server hosting www.example.com.
● The client retrieves and displays the website content.

Example Walkthrough
Scenario: A user wants to access www.example.com.

1. The browser sends a DNS query for www.example.com to the recursive resolver.
2. The resolver checks its cache and finds no record.
3. The resolver queries a root DNS server.
4. The root server responds with the address of the .com TLD server.
5. The resolver queries the .com TLD server.
6. The TLD server responds with the address of the authoritative server for
example.com.
7. The resolver queries the authoritative server, which returns the IP address

AK
93.184.216.34.
8. The resolver caches this result and returns the IP address to the browser.

AY
9. The browser connects to 93.184.216.34 and loads the website.

N
LP
Key Characteristics of Recursive Resolution

1. Simplicity for Clients: Clients send a single request and receive a complete
answer.
KA
2. Resolver Load: The recursive resolver handles all queries and responses.
3. Caching Efficiency: Results are cached by the resolver to improve efficiency for
N
subsequent requests.
SA

4. Performance: Generally faster for clients due to the resolver handling the
majority of the work.
BY
S

2. Iterative DNS Resolution


TE
O
N

2. Iterative DNS Resolution


N

2.1. Definition
C

Iterative DNS resolution is a process where the DNS resolver returns the best answer it
currently has, which may be a referral to another DNS server. In this method, the client
itself is responsible for querying each DNS server in sequence until it obtains the final IP
address.

2.2. Detailed Explanation and Steps


AK
1. Client Request to Local DNS Resolver:
○ The client sends an iterative query to the local DNS resolver requesting the

AY
IP address of a domain (e.g., www.example.com).
2. Local Resolver Cache Check:

N
○ The local resolver checks its cache for the requested record.
○ If cached: The resolver returns the IP address to the client.

LP
○ If not cached: The resolver provides the client with a referral to a root
DNS server.

KA
3. Client Query to Root DNS Server:
○ The client sends a query to the root DNS server for www.example.com.
○ Response: The root server replies with a referral to the appropriate TLD
N
DNS server (e.g., for .com).
SA

4. Client Query to TLD DNS Server:


○ The client queries the TLD DNS server for www.example.com.
○ Response: The TLD server provides a referral to the authoritative DNS
BY

server for example.com.


5. Client Query to Authoritative DNS Server:
○ The client queries the authoritative DNS server for www.example.com.
○ Response: The authoritative server returns the IP address 93.184.216.34.
S

6. Client Uses IP Address:


TE

○ The client uses the received IP address to connect to the web server and
access the website.
O

○ The client may also cache the result for future use.
N

2.3. Example Walkthrough


N

Scenario: A user wants to access www.example.com.


C

1. The user's computer sends an iterative DNS query to the local DNS resolver.
2. The local resolver lacks the information and refers the client to a root DNS server.
3. The client queries the root DNS server, which refers it to the .com TLD server.
4. The client queries the .com TLD server, which refers it to the authoritative server
for example.com.
5. The client queries the authoritative server, which returns the IP address
93.184.216.34.
6. The client connects to 93.184.216.34 and loads the website.
2.4. Key Characteristics of Iterative Resolution

● Client Responsibility: The client handles multiple queries and follows referrals
until the final answer is obtained.
● Reduced Resolver Load: The local DNS resolver performs minimal work,
primarily providing referrals.
● Potentially Slower for Client: The process can be slower, as the client may not
have the same caching capabilities and network efficiency as a dedicated resolver.
● Less Common: Iterative queries are less common in typical client-server

AK
interactions on the internet.

AY
N
LP
KA
N
SA
BY
S
TE
O

DNS Caching
N

Definition: DNS caching is a mechanism used to speed up DNS resolution by


N

temporarily storing the results of DNS queries. This reduces the need for repeated queries
C

to authoritative DNS servers, thereby improving efficiency and reducing network load.

How DNS Caching Works:

1. Query Handling:
○ Each time a DNS server receives a query for a domain name that is not in
its cache, it searches its database or queries other DNS servers to resolve
the domain name.
○ When a DNS server receives a response from another server, it stores this
information in its cache memory before sending it to the client.
2. Cache Utilization:
○ If a subsequent query for the same domain name is made, the DNS server
can use the cached information to resolve the request quickly, without
needing to query other servers.
○ To indicate that the response is from the cache and not from an authoritative
source, the server marks the response as "unauthoritative."
3. Efficiency and Issues:
○ Speed: Caching speeds up DNS resolution by reducing the time needed to
retrieve domain information from authoritative servers.

AK
○ Potential Problems: Long cache durations can lead to outdated
information being served if DNS records change. To address this, DNS
employs two main techniques:

AY
■ Time to Live (TTL):
■ The authoritative DNS server includes a TTL value in the

N
DNS record. TTL specifies the duration (in seconds) that the
information can be cached.

LP
■ Once the TTL expires, the cached information is considered
invalid, and the DNS resolver must query the authoritative

KA
server again for updated information.
■ Example: A TTL of 3600 seconds (1 hour) means that the
DNS record will be cached for 1 hour before requiring a fresh
N
query.
SA

■ TTL Counter:
■ Each DNS server maintains a TTL counter for each cached
record. The cache is periodically checked, and records with
BY

expired TTLs are purged to ensure that only current


information is stored.

Example of DNS Resolution Process with Caching:


S
TE

1. User Request:
○ A user enters www.example.com into their web browser.
2. Local Resolver Query:
O

○ The browser sends a query to the local DNS resolver, which may be
N

provided by the user's ISP.


3. Cache Check:
N

○ The local resolver checks its cache. If the IP address for www.example.com
C

is found, it returns it to the browser.


○ If not found in cache: The resolver queries one of the root DNS servers.
4. Root Server Response:
○ The root DNS server responds with the IP address of the TLD server
responsible for .com domains.
5. TLD Server Query:
○ The resolver queries the .com TLD server, which responds with the IP
address of the authoritative DNS server for example.com.
6. Authoritative Server Query:
○ The resolver queries the authoritative DNS server for www.example.com,
which returns the IP address 93.184.216.34.
7. Result Caching and Return:
○ The resolver caches the IP address 93.184.216.34 and returns it to the
browser.
8. Website Access:
○ The browser connects to 93.184.216.34 and loads the website
www.example.com.

AK
Summary:

● Caching: Speeds up DNS resolution by storing query results temporarily.

AY
● TTL: Determines how long DNS records are cached before requiring a fresh
query.
● Efficiency: Reduces load on DNS servers and speeds up response times.

N
● Updating Records: Ensures updated information by expiring outdated cache

LP
entries based on TTL values.

In DNS, a Resource Record (RR) can be conceptually represented as a tuple consisting of several fields.

KA
Here's the general structure of a DNS Resource Record (RR) as a tuple:

(Name, Type, Class, TTL, Data Length, Data)


N
SA

Breakdown of the Tuple:

1. Name: The domain name (e.g., example.com).


BY

2. Type: The type of resource record (e.g., A, AAAA, MX, CNAME).


3. Class: The class of the record, typically IN (Internet).
4. TTL (Time to Live): The duration (in seconds) for which the record can be
S

cached.
5. Data Length: The length of the data field (this is implicit in some descriptions).
TE

6. Data: The actual information, such as an IP address, mail server, or alias.


O

Example Tuple for an A Record:


N

For an A record that maps example.com to 93.184.216.34: ("example.com", A, IN,


86400, 4, "93.184.216.34")
N
C

● Name: example.com
● Type: A (IPv4 address)
● Class: IN (Internet)
● TTL: 86400 seconds (1 day)
● Data Length: 4 (since an IPv4 address is 4 bytes)
● Data: 93.184.216.34 (the IPv4 address)

Each type of DNS resource record (e.g., MX, AAAA, CNAME) will have similar tuples
but with different data formats depending on the type.
5 . Types of DNS Records

AK
AY
N
LP
A (Address) Record

KA
● Purpose: Maps a domain name to an IPv4 address.
● Example: www.example.com → 192.0.2.1
N
● Explanation: This record allows a browser to locate a website by converting a
SA

human-readable domain name into a machine-readable IPv4 address. When a user


types www.example.com, the DNS system uses the A record to find the
corresponding IP address and establish a connection.
BY

AAAA Record

● Purpose: Maps a domain name to an IPv6 address.


S

● Example: www.example.com → 2001:0db8:85a3::8a2e:0370:7334


TE

● Explanation: Similar to the A record, but for IPv6 addresses. With the growing
adoption of IPv6, this record helps locate websites that are hosted on servers with
O

IPv6 addresses.
N

CNAME (Canonical Name) Record


N

● Purpose: Redirects one domain name to another canonical domain name.


● Example: blog.example.com → www.example.com
C

● Explanation: This record allows you to alias a subdomain to another domain


name. For instance, if blog.example.com is set as a CNAME for
www.example.com, any queries for blog.example.com will be redirected to
www.example.com, simplifying DNS management and ensuring consistency.

MX (Mail Exchange) Record

● Purpose: Specifies the mail server responsible for receiving email messages for a
domain.
● Example: example.com → mail.example.com
● Explanation: Directs email traffic to the appropriate mail server. MX records
include priority levels to determine which mail server should be used first. Lower
numbers indicate higher priority. If the primary server is unavailable, the
secondary server will handle the email.

NS (Name Server) Record

● Purpose: Identifies the authoritative DNS servers for a domain.


● Example: example.com → ns1.example.com

AK
● Explanation: Specifies which DNS servers are responsible for managing the DNS
records of a domain. These servers hold the authoritative data for the domain and

AY
handle queries from other DNS servers.

TXT Record

N
● Purpose: Stores arbitrary text, often used for verification or to define security

LP
policies like SPF.
● Example: example.com → v=spf1 include:_spf.google.com ~all

KA
● Explanation: Provides a flexible way to include various types of information. For
instance, TXT records can be used for domain verification by services like
Google, or to set SPF (Sender Policy Framework) rules to prevent email spoofing.
N
SA

SOA (Start of Authority) Record

● Purpose: Contains administrative information about the domain, including the


primary name server and the contact email of the domain administrator.
BY

● Example: Information about example.com


● Explanation: The SOA record provides essential data for DNS zone management,
including the primary name server, administrative contact, and various timers
S

related to zone transfers and cache refreshes. It helps manage the authoritative
TE

DNS information for the domain.

6. DNS Message Format


O
N
N
C
AK
AY
N
LP
DNS messages are exchanged between clients and servers to perform DNS queries and responses. The DNS
message format includes the following sections:

1.
○ KA
Header: Contains fields such as identification, flags, and counts of various sections in the message.
ID: A 16-bit identifier assigned by the client.
N
○ Flags: Indicate whether the message is a query or response, and other control flags.
○ Counts: Number of entries in the question, answer, authority, and additional sections.
SA

2. Question Section: Contains the domain name being queried, the record type (e.g., A, MX), and the
class (usually IN for internet).
3. Answer Section: Contains the resource records that answer the query, including domain names,
BY

types, classes, TTLs, and data (e.g., IP addresses).


4. Authority Section: Provides authoritative name servers for the domain being queried.
5. Additional Section: Contains additional information to help the resolver, such as IP addresses of the
S

authoritative name servers.


TE
O

DNS Connections
N

● Protocols Used:
N

○ UDP: Used for DNS queries and responses smaller than 512 bytes.
○ TCP: Used when the response size exceeds 512 bytes.
C

● Port: Both UDP and TCP use port 53.

DNS Registrars

● Role: Add new domains to the DNS database.


● Process:
○ Verify domain name uniqueness.
○ Enter domain details into DNS.
● Registration Example:
○ Domain Name: ws.wonderful.com
○ IP Address: 200.200.200.5
● Registrar Information: Available at http://www.intenic.net

DDNS (Dynamic Domain Name System)

● Purpose: Dynamically update DNS records (e.g., adding/removing hosts,


changing IP addresses).
● Process:
○ Update primary DNS server with new information.

AK
○ Notify secondary servers (active or passive).
○ Active Notification: Primary server informs secondary servers directly.

AY
○ Passive Notification: Secondary servers periodically check for updates.
● Security: DDNS may use authentication mechanisms to prevent unauthorized

N
changes.

LP
DNS Security

● Importance: Critical for web access and email functionality.


● Common Attacks:
KA
○ Confidentiality: Attacker reads DNS responses to gather user information.
N
Prevented by ensuring DNS message confidentiality.
○ Authentication and Integrity: Attacker intercepts and alters DNS
SA

responses. Prevented by message origin authentication and integrity checks.


○ Denial-of-Service (DoS): Attacker floods DNS server, causing crashes.
Mitigated by caching systems and provisions against DoS attacks.
BY

● DNSSEC:
○ Function: Provides message origin authentication and integrity using
digital signatures.
S

○ Limitations: Does not ensure message confidentiality or specific protection


TE

against DoS attacks.

Example of DNS Resolution Process


O
N

Scenario:
N

A user wants to visit www.example.com. Here’s a step-by-step breakdown of how DNS


resolution works:
C

1. User Request:
○ Action: The user opens their web browser and enters www.example.com.
○ Purpose: The browser needs the IP address associated with
www.example.com to connect to the server.
2. DNS Query Initiation:
○ Action: The browser first checks its local cache to see if it already has the
IP address for www.example.com.
○ Purpose: If the IP address is not cached, the browser sends a request to the
local DNS resolver (often provided by the user’s ISP).
3. DNS Resolver Contacts DNS Server:
○ Action: The DNS resolver queries a DNS server to find the IP address for
www.example.com.
○ Purpose: The DNS server, often maintained by the ISP, is responsible for
finding the IP address. It uses UDP port 53 for this query.
4. Root DNS Server Query:
○ Action: If the DNS server does not have the IP address in its cache, it

AK
queries a root DNS server using UDP port 53.
○ Purpose: The root server responds with the IP address of the Top-Level
Domain (TLD) server responsible for .com domains.

AY
5. TLD DNS Server Query:
○ Action: The DNS resolver queries the .com TLD server using UDP port 53.

N
○ Purpose: The TLD server responds with the IP address of the authoritative
DNS server for example.com.

LP
6. Authoritative DNS Server Query:
○ Action: The DNS resolver queries the authoritative DNS server for

KA
example.com using UDP port 53.
○ Purpose: This server provides the IP address for www.example.com.
7. Response to Browser:
N
○ Action: The DNS resolver sends the IP address back to the browser using
SA

UDP port 53.


○ Purpose: The browser can now use the IP address to connect to the web
server.
BY

8. Connecting to the Web Server:


○ Action: The browser uses the IP address to send an HTTP request to the
web server hosting www.example.com over TCP port 80 (HTTP) or TCP
S

port 443 (HTTPS).


○ Purpose: The web server processes the request and sends the requested
TE

web page back to the browser.


9. Displaying the Website:
O

○ Action: The browser receives the web page from the server and displays it
to the user.
N

○ Purpose: The user can now view and interact with the website
N

Example of DNS in Action: HTTP and DNS Working Together


C

1. Typing a Domain Name:

● Action: You enter www.example.com into your web browser.

2. DNS Resolution:

● Process: The browser sends a query to DNS to resolve www.example.com into


its IP address.
● Outcome: DNS provides the IP address of the web server hosting
www.example.com.

3. HTTP Request:

● Action: With the IP address, the browser sends an HTTP request to the web server
at that address.

4. Website Delivery:

AK
● Process: The web server responds with the requested web page.
● Outcome: The browser displays the web page to the user.

AY
Summary:

N
● DNS translates domain names into IP addresses.
● HTTP requests and retrieves content from the web server.

LP
● This process ensures users can access websites efficiently using human-readable
domain names.

Content Delivery Network (CDN)


KA
N
Definition: A Content Delivery Network (CDN) is a network of geographically
distributed servers that collaborate to deliver web content and media to users efficiently
SA

based on their geographic location. The main goal of a CDN is to reduce latency and
enhance the performance of content delivery by caching it closer to end-users.
BY

Key Features:

1. Geographic Distribution:
S

○ Description: Servers are strategically located across various global


TE

locations.
○ Benefit: Ensures content is delivered from the nearest server to the user,
minimizing latency.
O

2. Caching:
N

○ Description: Static content (e.g., images, videos, CSS, JavaScript) is stored


on CDN servers.
N

○ Benefit: Speeds up access to frequently requested content and reduces the


load on the origin server.
C

3. Load Balancing:
○ Description: Distributes incoming traffic across multiple servers.
○ Benefit: Prevents any single server from becoming overwhelmed,
improving reliability and performance.
4. Security:
○ Description: Includes features like DDoS protection and secure
connections.
○ Benefit: Enhances security by protecting against attacks and ensuring
secure data transmission.

Benefits:

1. Improved Load Times:


○ Description: Faster content delivery due to proximity to users.
○ Benefit: Enhances user experience by reducing load times.
2. Reduced Server Load:
○ Description: Offloads traffic from the origin server to CDN servers.

AK
○ Benefit: Decreases the burden on the origin server, improving overall
server performance.

AY
3. Increased Availability:
○ Description: Higher reliability and uptime due to the distributed nature of
servers.

N
○ Benefit: Ensures consistent access to content even during traffic spikes or

LP
server failures.

Examples:

● Cloudflare
● Akamai
KA
N
● Amazon CloudFront
SA

DNS and CDN Relationship


BY

Domain Name System (DNS):

Definition: The Domain Name System (DNS) translates human-readable domain names
(e.g., www.example.com) into IP addresses that computers use to identify each other on
S

the network.
TE

Role:
O

● Description: Acts as the Internet's phonebook, directing traffic to the appropriate


N

servers based on domain names.


● Function: Resolves domain names to IP addresses, ensuring users are directed to
N

the correct server.


C

CDN Integration with DNS:

1. DNS Resolution:
○ Description: When a user requests content, the DNS resolves the domain
name to an IP address.
○ Benefit: The IP address may point to a CDN server rather than the origin
server, optimizing content delivery.
2. CDN Caching:
○ Description: Once directed by DNS, the CDN server caches and delivers
the content.
○ Benefit: Improves load times and reduces latency by serving content from
the closest server.

Differences:

1. Function:
○ DNS: Resolves domain names to IP addresses.
○ CDN: Delivers content from servers closer to the user.

AK
2. Scope:
○ DNS: Used for domain resolution across the Internet.

AY
○ CDN: Focuses on optimizing content delivery and performance.

Summary:

N
● DNS: Directs traffic to the correct servers by translating domain names to IP

LP
addresses.
● CDN: Enhances content delivery performance by caching and serving content

KA
from distributed servers closer to users.
N
SA

Email

Email is one of the earliest and most widely used network applications, allowing users to
send and receive messages electronically. This service is essential for communication in
BY

both personal and professional settings.

Components of an Email System


S
TE

An email system consists of three main components:

1. User Agent (UA): Provides the interface for users to send and receive messages.
O

2. Message Transfer Agent (MTA): Responsible for transferring messages between


N

servers using the Simple Mail Transfer Protocol (SMTP).


3. Message Access Agent (MAA): Allows users to retrieve messages from the server
N

using protocols like IMAP and POP.


C

➢ When the Sender and Receiver are on the Same System


If both the sender and receiver use the same email system, only two User Agents are
required, with no need for MTAs.

➢ When the Sender and Receiver are on Different Systems


For different systems, two User Agents, two pairs of MTAs (client and server), and two
MAAs (client and server) are needed.

Working of an Email System

AK
AY
N
LP
KA
N
SA

1. Sending a Message:
BY

○ The sender (e.g., Alice) uses a User Agent (UA) to compose and send an
email.
○ The mail server queues the message using a spool and sends it through the
S

Internet using an MTA.


TE

2. Transferring the Message:


○ A pair of Message Transfer Agents (client and server) facilitates the
O

transfer over the Internet.


○ The MTA server must always be running to accept incoming connections,
N

while the client is triggered when there is a message to send.


3. Receiving the Message:
N

○ The receiver (e.g., Bob) uses their User Agent to read the message.
C

○ Bob retrieves the message from the mail server using a Message Access
Agent (MAA), such as IMAP or POP.

User Agent (UA)

A User Agent (UA) is software that simplifies the process of sending, receiving, and
managing emails. It comes in two types:
AK
1. Command-driven UAs: Early email systems where users interacted through

AY
text-based commands (e.g., mail, pine, elm).
2. GUI-based UAs: Modern interfaces with graphical components (e.g., Outlook,

N
Eudora) that allow users to interact via mouse and keyboard.

LP
Message Transfer Agent (MTA)

The Message Transfer Agent (MTA) handles the actual transmission of emails. The

KA
MTA client sends the email, and the MTA server receives it. The standard protocol used
for this communication is SMTP (Simple Mail Transfer Protocol).
N
Message Access Agent (MAA)
SA

The Message Access Agent (MAA) enables users to retrieve emails from a mailbox.
Popular protocols include POP3 and IMAP.
BY

Email Address Format


S

An email address consists of two parts: userid@domain


TE
O
N
N
C

● userid: Identifies the sender or recipient.


● domain: Refers to the server that handles the email.

Email Message Format

An email consists of:

1. Email message consists of two parts: header and body.


2. Each header line contains a type and value separated by a colon (:).
3. Some important header fields include:
● From: Identifies the sender of the message.
● To: Contains the email address of the recipient(s).
● Subject: Describes the purpose of the message.
● Date: Timestamp indicating when the message was transmitted.
4. The header is separated from the body by a blank line.
5. The body contains the actual message or content\

AK
AY
N
LP
KA
SMTP (Simple Mail Transfer Protocol)

Introduction
N
● SMTP (Simple Mail Transfer Protocol) is the standard protocol for transferring
SA

email between hosts in the TCP/IP protocol suite.


● SMTP is not responsible for the format or content of messages but handles the
process of sending the messages.
BY

● It operates based on information from the message header (envelope) and ignores
the message body (contents).
S

Components of SMTP
TE

SMTP operates using two main components:


O

1. User Agents (UA):


○ Prepares the message and encloses it in an envelope (message header).
N

○ The message is generated by the user in the form of a header and body.
2. Mail Transfer Agent (MTA):
N

○ Transfers the mail across the internet from the source to the destination.
C

○ Relays: SMTP also allows the use of relay MTAs, which help relay the
mail between different servers across the internet.
AK

AY
SMTP Workflow

N
1. The user creates an email using a User Agent.

LP
2. The message consists of:
○ A header, which includes the recipient’s email address and additional
information.

KA
○ A message body, containing the actual content of the email.
3. The created message is queued and passed to an SMTP Sender program, which
N
initiates the transfer of the email using SMTP.
SA

SMTP Commands and Responses

The operation of SMTP involves the exchange of commands and responses between the
BY

SMTP sender and the SMTP receiver.

1. Commands:
S

○ Sent by the SMTP client (MTA client) to the SMTP server (MTA server).
○ Each command consists of a keyword followed by zero or more
TE

arguments.
○ SMTP defines 14 commands for communication.
O
N
N
C
AK
AY
N
LP
2. Responses: KA
○ Sent by the SMTP server to the SMTP client.
N
○ Responses consist of a three-digit code, optionally followed by additional
SA

text.
BY
S
TE
O
N
N
C
AK
AY
N
LP
KA
N
SA

Basic SMTP Operation


BY

SMTP operates in three phases:


S

1. Connection Setup
TE

2. Mail Transfer
3. Connection Termination
O

1. Connection Setup
N

● The SMTP sender establishes a TCP connection with the receiver when it has
messages to deliver.
N
C

Steps involved:

1. The sender initiates a TCP connection with the target host (receiver).
2. Once the connection is established, the receiver identifies itself with a "Service
Ready" message.
3. The sender then identifies itself with the HELO command.
4. The receiver responds with an "OK" message, acknowledging the sender’s
identity.
5. If the mail service on the destination is unavailable, the receiver replies with
"Service Not Available", and the process terminates.

AK
AY
N
2. Mail Transfer

LP
Once the connection is established, the SMTP sender can send one or more emails.

Steps in Mail Transfer:


KA
N
1. The MAIL command identifies the sender (originator) of the message.
2. One or more RCPT commands are used to identify the recipients of the message.
SA

3. The DATA command transfers the message text (the actual content of the email).
BY

3. Connection Termination

Once the email(s) are transferred, the SMTP sender closes the connection in two steps:
S
TE

1. The sender sends a QUIT command and waits for a response from the receiver.
2. The TCP connection is then closed:
O

○ The sender initiates the TCP close.


○ The receiver initiates its own TCP close after sending the reply to the
N

QUIT command.
N
C
SMTP Limitations

1. No Binary File Support: Cannot transmit executables or binary objects.


2. 7-bit ASCII Restriction: Cannot handle 8-bit national language characters.
3. Message Size Limit: Some servers reject large messages.
4. Inconsistent ASCII to EBCDIC Translation: Causes translation issues between
systems.
5. Non-Standard Implementations: Can lead to issues like:
○ Altered carriage return/linefeed.
○ Truncated long lines.

AK
○ Removed trailing whitespace.
○ Padded lines.

AY
○ Tabs converted to spaces.

N
Multipurpose Internet Mail Extension (MIME)

LP
Introduction to MIME

● SMTP Overview: Simple Mail Transfer Protocol (SMTP) provides a basic service

KA
for sending emails across the internet. However, it has limitations, especially when
dealing with multimedia content and non-ASCII text.
● MIME Overview: Multipurpose Internet Mail Extension (MIME) is an extension
N
of SMTP designed to overcome these limitations. MIME enhances the basic email
SA

service by enabling the transmission of multimedia content (like images, audio,


video) and non-ASCII text (like characters from different languages) over the
email system.
BY

Limitations of Traditional Email Systems


S

● ASCII Format Restriction: Traditional email systems were designed to send


messages only in ASCII format, which limits communication to plain text in
TE

English. This restriction makes it difficult to send messages in other languages


such as French, Chinese, etc.
O

● Inability to Send Multimedia: Without MIME, sending non-text files like


images, audio, and video is impossible. MIME addresses this by allowing these
N

types of files to be sent as email attachments.


N

Features of MIME
C

MIME extends the capabilities of the email system in several ways:

● Multiple Attachments: Allows sending multiple attachments within a single


message.
● Unlimited Message Length: Removes the limitation on the length of email
messages.
● Support for Various Character Sets: Enables the use of character sets other than
ASCII, which supports international languages.
● Rich Text Support: Facilitates the inclusion of rich text in emails, such as
different layouts, fonts, and colors.
● Binary Attachments: Permits sending binary files (e.g., executable files, images,
audio, and video) as attachments. These files can be divided into smaller parts if
needed.

MIME Process

● Conversion to 7-bit ASCII: MIME converts non-ASCII data into 7-bit Network
Virtual Terminal (NVT) ASCII before sending the message and converts it back

AK
upon receipt. This ensures compatibility with systems that may only support 7-bit
ASCII.

AY
N
LP
KA
N
SA
BY

MIME Headers
S

MIME uses specific headers to describe the content of the message and the encoding
TE

used. Important MIME headers include:

1. MIME-Version: Indicates the MIME version being used, commonly 1.1.


O

2. Content-Type: Specifies the type of content in the message, such as text/html for
N

HTML documents, image/jpeg for JPEG images, or application/pdf for PDF files.
3. Content-Transfer-Encoding: Defines the encoding scheme used to convert the
N

message content into a transferable format. Common encoding schemes include


base64 and quoted-printable.
C

4. Content-ID: Provides a unique identifier for the message or attachment, often


used when referencing attachments in the body of an email.
5. Content-Description: Offers a brief description of the content within the message
body, useful for providing context to the recipient.

MIME Content Types

MIME supports a variety of content types, each designed to handle different kinds of
data. There are seven major types with various subtypes:
1. Text: For text data, such as text/plain or text/html.
2. Image: For image files, such as image/jpeg or image/png.
3. Audio: For audio files, such as audio/mpeg.
4. Video: For video files, such as video/mp4.
5. Application: For binary data or application-specific files, such as application/pdf
or application/zip.
6. Multipart: Used when a message includes multiple types of content. For example:
○ Multipart/mixed: Indicates a message containing different types of content
in a specific order, like a combination of text and attachments.

AK
7. Message: Used for encapsulating email messages within another message, such as
message/rfc822.

AY
Each piece of content in a multipart message has its own headers describing the type and
format.

N
MIME Encoding Formats

LP
MIME uses various encoding formats to convert binary data into the ASCII character set,
enabling it to be transmitted via email. The main encoding formats used in MIME are:

KA
1. 7-bit: The default format, used for simple text messages that don't require
accented characters.
N
2. 8-bit: Allows the inclusion of extended characters, such as those in non-English
SA

languages.
3. Quoted-printable: Ideal for text that primarily uses 7-bit characters but
occasionally includes 8-bit characters, like accented characters.
BY

4. Base64: Used for encoding binary files, such as images and executables, as it
converts binary data into a text format suitable for email transmission.
5. Binary: Directly transfers binary data without conversion; however, it's not
S

commonly recommended due to potential compatibility issues.


TE

MIME is also flexible enough to use third-party encoding formats, including:


O

● BinHex: An Apple-specific format for encoding binary data.


● Uuencode: A format used for encoding data on UNIX systems for transfer
N

between UNIX machines.


● Xencode: A method for converting binary data into a text format, often used in
N

older systems.
C

These encoding formats ensure that even complex data types can be reliably sent via
email, regardless of the recipient's system.

Internet Mail Access Protocol (IMAP)

Overview:

● IMAP is an Application Layer protocol that enables email clients to access


messages stored on a remote mail server. It allows users to manage their emails
directly on the server, which is especially useful when accessing the same mailbox
from multiple devices.

Key Features:

● Client/Server Protocol: IMAP operates over TCP on port 143 and facilitates
communication between an email client and a remote mail server.
● Simultaneous Access: Multiple clients can access the same mailbox at the same
time. IMAP keeps track of changes made by different clients, ensuring consistency
across devices.

AK
● Remote Access: Emails stored on an IMAP server can be managed from various
devices without the need to transfer messages or files between them.

AY
IMAP Modes:

N
1. Offline: Users download emails to their local device and work offline.
2. Online: Users interact with emails directly on the server, similar to managing

LP
local files but stored remotely.
3. Disconnected Operation: Users download selected emails to a cache for offline

KA
access and later synchronize with the server.

IMAP Operations:
N
SA

● Client Commands: Common commands include LOGIN, AUTHENTICATE,


SELECT, EXAMINE, CLOSE, and LOGOUT.
● Server Responses: Responses include OK (success), NO (permission denied), and
BAD (invalid command).
BY

● Message Retrieval: When fetching a message, the server responds in MIME


format, allowing for selective fetching of message parts.
● Flags: Flags such as SEEN, ANSWERED, DELETED, and RECENT indicate the
S

status of messages.
TE

IMAP4:
O

● The latest version, IMAP4, introduces additional features:


N

○ Preview email headers before downloading.


○ Search within emails for specific content.
N

○ Partially download emails, useful for large multimedia files.


C

○ Create, delete, or rename mailboxes and folders on the server.

Advantages of IMAP:

● Server Storage: Primary storage is on the server, enabling remote management


and access from multiple devices.
● Folder Hierarchy: Supports a full hierarchy of remote folders and multiple
inboxes.
● Message Status: Tracks and supports user-defined message statuses.
● Selective Fetching: Allows for the retrieval of specific parts of a message,
minimizing data transfer.
● Server-based Search: Efficient searching without needing to download all data.

Extensibility:

● IMAP can be extended to support non-email data types, such as netnews and
document storage.

Post Office Protocol (POP3)

AK
Overview:

AY
● POP3 (Post Office Protocol version 3) is an application-layer protocol used by
email clients to retrieve emails from a remote server over a TCP/IP connection. It

N
typically uses TCP port 110.

LP
Versions:

● POP2: The earlier version, standardized in the mid-1980s, requires SMTP for
sending messages.
KA
● POP3: The current version, which can be used with or without SMTP, offering
N
simpler implementation and supporting offline access.
SA

Key Features:

● Simplified Protocol: POP3 is straightforward, making it easier to implement and


BY

use.
● Offline Access: POP3 downloads messages from the server to the local device,
allowing users to access their emails without needing a constant internet
S

connection.
TE

● Single Mailbox: POP3 allows only one mailbox per account on the server, with no
support for folders.
● Modes of Operation:
O

1. Delete Mode: Emails are deleted from the server after they are
N

downloaded, suitable for permanent devices where emails are saved locally.
2. Keep Mode: Emails remain on the server after being read, allowing
N

retrieval from different devices later.


C

Limitations:

● No Search Facility: POP3 does not support searching within messages on the
server.
● Single Mailbox Concept: Unlike IMAP, POP3 treats the mailbox as a single
storage unit, with no folder hierarchy.
● Non-Mail Data: POP3 is not suitable for handling non-mail data types.

POP3 Operations:
● Connection: The client connects to the POP3 server using TCP on port 110.
● Authentication: The client sends a username and password to access the mailbox
and retrieve messages.

POP3 Commands:

● UID: Opens the connection to the server.


● STAT: Displays the number of messages in the mailbox.
● LIST: Provides a summary of the messages.
● RETR: Retrieves a selected message from the mailbox.

AK
● DELE: Deletes a specified message from the server.
● RSET: Resets the session to its initial state.

AY
● QUIT: Logs off the session and closes the connection.

N
LP
KA
N
SA
BY
S
TE
O
N
N
C
Advantages of IMAP over POP

1. More Powerful and Complex:


○ IMAP offers more advanced features and greater flexibility compared to

AK
POP, making it a more robust solution for managing emails.
2. Email Header Preview:

AY
○ Users can preview email headers before downloading the full message,
allowing them to decide which emails to download.
3. Search Capability:

N
○ IMAP enables users to search for specific content within emails on the
server before downloading, which is not possible with POP.

LP
4. Partial Download:
○ IMAP allows users to download only parts of an email (e.g., just the text

bandwidth.
5. Mailbox Management:
KA
without attachments), which is particularly useful in scenarios with limited
N
○ Users can create, delete, or rename mailboxes directly on the mail server,
SA

offering better organization and management of emails.


BY

Q.Briefly explain the working of an E-mail Application with the help of neat block
diagram showing functional blocks like UA, MTA, MAA, Mail-Box, Message-Queue.
S

A: n email application involves several key components that work together to send, store, and retrieve
emails. Here's a brief explanation of each component and how they interact, along with a simple block
TE

diagram to illustrate the process.


O

Functional Blocks:
N

1. User Agent (UA):


○ The User Agent is the email client used by the user to compose, send, and
N

receive emails. Examples include applications like Microsoft Outlook,


C

Mozilla Thunderbird, or webmail interfaces like Gmail.


2. Message Transfer Agent (MTA):
○ The MTA is responsible for transferring emails from the sender's mail
server to the recipient's mail server. It routes the email across the internet
using protocols like SMTP (Simple Mail Transfer Protocol).
3. Message Access Agent (MAA):
○ The MAA allows the recipient to retrieve emails from their mailbox on the
mail server. Protocols like IMAP (Internet Message Access Protocol) or
POP3 (Post Office Protocol) are used here.
4. Mail-Box:
○ The Mail-Box is a storage location on the recipient's mail server where
incoming emails are stored until they are retrieved by the recipient. It
contains separate folders or directories for each user's emails.
5. Message Queue:
○ The Message Queue temporarily holds outgoing or incoming emails until
they are successfully delivered or retrieved. This ensures that emails are not
lost if the server is busy or temporarily unavailable.

AK
AY
N
LP
KA
N
SA
BY

- If question is asked as give example to explain email the write below ans:->
The diagram illustrates the process of email transfer from one user (Alice) to another (Bob) using the
S

components involved in email transmission, including User Agents (UA), Message Transfer Agents
TE

(MTA), and Message Access Agents (MAA). Here’s a step-by-step explanation:


O

Step-by-Step Process:
N

1. User Agent (UA) Client (Alice) - Step 1:


○ Alice composes an email using a User Agent (UA), which is typically an
N

email client like Outlook or Thunderbird. The email is then sent to the Mail
C

Transfer Agent (MTA) client.


2. MTA Client (Alice) - Step 2:
○ The MTA client receives the email from the UA and sends it to the MTA
server on Alice’s mail server. This process often happens over a Local Area
Network (LAN) or Wide Area Network (WAN).
3. MTA Server (Alice) - Step 3:
○ The MTA server on Alice's side temporarily stores the email in a queue or
spool until it can be sent over the internet to the recipient's mail server.
4. MTA Server (Alice) to MTA Server (Bob) - Step 4 & 5:
○ The email is transferred from Alice’s MTA server to Bob’s MTA server
over the Internet. This is the core function of the MTA, which uses
protocols like SMTP (Simple Mail Transfer Protocol) to relay the message.
5. MTA Server (Bob) - Step 6:
○ Once the email reaches Bob’s mail server, the MTA server stores the email
in the recipient’s mailbox.
6. Mail Access Agent (MAA) Client (Bob) - Step 7 & 8:
○ Bob’s email client (User Agent) connects to the MAA client, which
interacts with the mail server to retrieve the email from Bob’s mailbox.

AK
7. User Agent (UA) Client (Bob) - Step 9:
○ Bob receives the email through his User Agent, completing the email
transfer process.

AY
Summary of Components:

N
● UA (User Agent): The application used by the user to send and receive emails.

LP
● MTA (Message Transfer Agent): Responsible for routing and transferring the
email from the sender's mail server to the recipient's mail server.
● MAA (Message Access Agent): Handles the retrieval of emails from the mail
server for the recipient.
KA
N
SA
BY
S
TE
O
N
N
C

You might also like