Unit 5
Unit 5
Application Layer
• Having finished all the preliminaries, we now come to the layer where all the applications are
found.
• The layers below the application layer are there to provide transport services, but they do not
do real work for users.
• However, even in the application layer there is a need for support protocols, to allow the
applications to function
Application Layer
DNS – The Domain Name System
• Although programs theoretically could refer to Web pages, mailboxes, and other resources by
using the network (e.g., IP) addresses of the computers on which they are stored, these
addresses are hard for people to remember.
• Also, browsing a company’s Web pages from 128.111.24.41 means that if the company moves
the Web server to a different machine with a different IP address, everyone needs to be told
the new IP address.
• Consequently, high-level, readable names were introduced in order to decouple machine
names from machine addresses.
• since the network itself understands only numerical addresses, some mechanism is required to
convert the names to network addresses.
Application Layer
DNS – The Domain Name System
• Well before many millions of PCs were connected to the Internet, everyone involved with it
realized that this approach could not continue to work forever.
• For one thing, the size of the file would become too large.
• However, even more importantly, host name conflicts would occur constantly unless names
were centrally managed, something unthinkable in a huge international network due to the
load and latency.
• To solve these problems, DNS (Domain Name System) was invented in 1983.
• It has been a key part of the Internet ever since.
Application Layer
DNS – The Domain Name System
• The essence of DNS is the invention of a hierarchical, domain-based naming scheme and a
distributed database system for implementing this naming scheme.
• It is primarily used for mapping host names to IP addresses but can also be used for other
purposes.
Application Layer
DNS – The DNS Name Space
• The top of the naming hierarchy is managed by an organization called ICANN (Internet
Corporation for Assigned Names and Numbers).
• ICANN was created for this purpose in 1998, as part of the maturing of the Internet to a
worldwide, economic concern.
• Conceptually, the Internet is divided into over 250 top-level domains, where each domain
covers many hosts.
• Each domain is partitioned into subdomains, and these are further partitioned, and so on.
• All these domains can be represented by a tree, as shown in Fig.
Application Layer
DNS – The DNS Name Space
Application Layer
DNS – The DNS Name Space
• The leaves of the tree represent domains that have no subdomains (but do contain machines,
of course).
• A leaf domain may contain a single host, or it may represent a company and contain thousands
of hosts.
Application Layer
DNS – The DNS Name Space
• The top-level domains come in two flavors: generic and
countries.
• The generic domains, listed in Fig., include original domains from
the 1980s and domains introduced via applications to ICANN.
• Other generic top-level domains will be added in the future.
• The country domains include one entry for every country, as
defined in ISO 3166.
• Internationalized country domain names that use non Latin
alphabets were introduced in 2010. These domains let people
name hosts in Arabic, Cyrillic, Chinese, or other languages
Application Layer
DNS – The DNS Name Space
• Getting a second-level domain, such as
name-of-company.com, is easy.
• The top-level domains are run by registrars appointed
by ICANN.
• Getting a name merely requires going to a corresponding registrar (for com in this case) to
check if the desired name is available and not somebody else’s trademark.
• If there are no problems, the requester pays the registrar a small annual fee and gets the
name.
Application Layer
SMTP – Simple Mail Transfer Protocol
• The architecture of the email system is shown in Fig.
• It consists of two kinds of subsystems: the user agents, which allow people to read and send
email, and the message transfer agents, which move the messages from the source to the
destination.
• We will also refer to message transfer agents informally as mail servers.
Application Layer
SMTP – Simple Mail Transfer Protocol
• The user agent is a program that provides a graphical interface, or sometimes a text- and
command-based interface that lets users interact with the email system.
• It includes a means to compose messages and replies to messages, display incoming messages,
and organize messages by filing, searching, and discarding them.
• The act of sending new messages into the mail system for delivery is called mail submission.
Application Layer
SMTP – Simple Mail Transfer Protocol
• The message transfer agents are typically system processes.
• They run in the background on mail server machines and are intended to be always available.
• Their job is to automatically move email through the system from the originator to the
recipient with SMTP (Simple Mail Transfer Protocol).
• This is the message transfer step.
Application Layer
SMTP – Simple Mail Transfer Protocol
• Basically, in SMTP the actual transfer of the mail is done through the message transfer agent
(MTA).
• Hence, to send the mail, the system must have the client MTA and similarly, to receive the
mail, the system must have the server MTA.
• Using the SMTP protocol, a TCP connection to the SMTP server is opened and then the client
sends the email across the TCP connection.
• As soon as the server listens for the TCP connection from any client the connection is
established on port 25 and the connection becomes successful hence the clients can send or
receive the email immediately.
Application Layer
SMTP – Simple Mail Transfer Protocol
Components of SMTP
There are four components in the SMTP:
• Mail User Agent (MUA)
• Mail Submission Agent (MSA)
• Mail Transfer Agent (MTA)
• Mail Delivery Agent (MDA)
Application Layer
SMTP – Simple Mail Transfer Protocol
Working of Simple Mail Transfer Protocol (SMTP)
• A sender drafts the mail and hits the send button.
• Once an SMTP server is established, email clients can connect and communicate with the
server.
• As the sender has pressed the send button, this triggers the email client to open an SMTP
connection to the server to make a connection so that it can send the emails.
• Now, the SMTP client uses various commands available in the SMTP to communicate with the
server and to transfer the data like the mail address of the sender.
Application Layer
SMTP – Simple Mail Transfer Protocol
Working of Simple Mail Transfer Protocol (SMTP)
• Then the Mail Transfer Agent(MTA) ensures that both the mail addresses are from the same
email domain.
• If they are the same, it sends the email.
• But if not, the server uses the DNS(Domain Name System) to identify the recipient's domain,
and then it'll send it to the right server.
Application Layer
SMTP – Simple Mail Transfer Protocol
Comman
Description
d
This command is used for beginning the email-sending process and is used to identify the
HELO user and full domain name. It is the beginning of the conversation in which the server
sends a HELO command back with its domain name.
This command is used to initiate the message transfer and identifies the originator of the
MAIL mail. From this command, the server resets everything and is ready to accept the email
address and after accepting, it'll reply with the 250 OK code.
This command identifies the recipient of the mail and again the SMTP server responds
RCPT
with the same code.
DATA This command triggers the transfer of data between the client and the server.
After the email has been sent, the client sends this command to quit the server and if it is
QUIT
closed successfully, the server will reply with a 221 code.
To abort or cancel the mail transaction, this command is used. This doesn't close the
RSET connection but it does reset everything and removes all the previous data about the mail
and the email addresses.
Application Layer
HTTP – Hyper Text Transfer Protocol
• Have you thought about what happens when we enter a URL (Uniform Resource Locator) in the
browser to visit a website?
• The browser fetches the IP address corresponding to the entered URL using DNS (Domain
Name System). Once the browser gets the IP address corresponding to the entered URL, the
browser sends a request to the server at the backend (along with the IP address of the website)
to fetch the webpage of the website.
• In return, the browser receives a response from the server and this response contains the
HTML (Hypertext Markup Language) information of the webpage.
• These requests and responses that are sent follow a protocol which is called HTTP (Hypertext
Transfer Protocol).
Application Layer
HTTP – Hyper Text Transfer Protocol
How Does Hypertext Transfer Protocol Work?
Below is a step-by-step discussion of how the Hypertext transfer protocol works.
1. Extracting the IP address of a URL (Uniform Resource Locator)
• In our browser, we enter the URL address of the website we want to visit.
• Once we enter the URL address of the website, the browser with the help of the DNS extracts
the IP address corresponding to the URL address that is entered.
• The DNS contains the mapping of the URLs along with their corresponding IP addresses.
Application Layer
HTTP – Hyper Text Transfer Protocol
How Does Hypertext Transfer Protocol Work?
2. Sending request to the server to access the webpage and receiving response
• Once we get the IP address of the website, the browser sends an HTTP request to the server to
extract the HTML webpage corresponding to the IP address.
• This request is sent over PORT 80 using TCP.
• Once the server receives this HTTP request, it responds back with an HTTP response.
• This HTTP response consists of the information related to the HTML page corresponding to the
IP address of the website.
Application Layer
HTTP – Hyper Text Transfer Protocol
How Does Hypertext Transfer Protocol Work?
3. Receiving HTTP response and displaying the webpage
• The browser receives the HTML information for the website along with the response and
hence, it processes and displays the HTML page on the browser.
• Finally, the users can see an HTML page for the URL that they entered.
Application Layer
HTTP – Hyper Text Transfer Protocol
What is in an HTTP Request?
• In order to fetch the webpage corresponding to a given IP address, the browser sends a
request (called as HTTP request) to the web server.
• An HTTP request consists of 3 parts i.e. a request line, request headers, and request body.
Application Layer
HTTP – Hyper Text Transfer Protocol
What is in an HTTP Request?
Request Line
An HTTP request-line consists of 3 parts which are discussed below.
1.Request Method A request method defines what type of request is needed to send to the web
server. For example, if we want to fetch something from the web server, we use a GET request
method. If we want to send something from the client to the web server, we use POST request
method.
2.Request URI It is the the URI of the website/destination we want to reach. For example
"http://google.com/".
3.HTTP Version It states the version of the HTTP we are using. For example HTTP 1.0, HTTP 1.1.
Application Layer
HTTP – Hyper Text Transfer Protocol
What is in an HTTP Request?
Request Headers
• Request headers contain additional information about the resource/data that is to be fetched
from the web server.
• For example, if we want the data in the plaintext format, we can specify that information in
the HTTP headers.
• We can also specify the information related to the client using headers like the browser it is
using etc.
• We can send more than one HTTP header along with an HTTP request to specify the additional
information that is to be sent along with an HTTP request.
Application Layer
HTTP – Hyper Text Transfer Protocol
What is in an HTTP Request?
Request Body
• It is an optional part of an HTTP request.
• If there is a requirement to send some data along with an HTTP request, we send that data
along with the HTTP Body.
• For example: If we want to send the details of a user which is taken through a form at the
client side to the web server, we can send this data in the HTTP body.
Application Layer
HTTP – Hyper Text Transfer Protocol
What is in an HTTP Response?
Application Layer
HTTP – Hyper Text Transfer Protocol
What is in an HTTP Response?
Response Headers
• The response headers are used to specify the additional information related to the response
data and the server.
Response Body
• It is an optional part of the HTTP response. The data which is requested by the client using the
HTTP request is sent from server to client by keeping it inside the response body.
Application Layer
HTTP – Hyper Text Transfer Protocol
Status Code
An HTTP status code is a three-digit code that specifies the status of the HTTP response. Some of
the commonly seen HTTP status codes along with their description are given below.