Chapter 7
(Week 13)
The Application Layer
ANDREW S. TANENBAUM
COMPUTER NETWORKS
FOURTH EDITION
PP. 579-611
BLM431 Computer Networks 1
Dr.Refik Samet
PREVIOUS LAYERS
• THE PURPOSE OF THE PHYSICAL
LAYER IS TO TRANSPORT A RAW BIT
STREAM FROM ONE MACHINE TO
ANOTHER.
• THE MAIN TASK OF THE DATA LINK
LAYER IS TO TRANSFORM A RAW
TRANSMISSION FACILITY INTO A
LINE THAT APPEARS FREE OF
UNDETECTED TRANSMISSION
ERRORS TO THE NETWORK LAYER.
BLM431 Computer Networks 2
Dr.Refik Samet
• THE NETWORK LAYER IS CONCERNED
WITH GETTING PACKETS FROM THE
SOURCE ALL THE WAY TO THE
DESTINATION.
• THE TRANSPORT LAYER’S TASK IS
TO PROVIDE RELIABLE, COST-
EFFECTIVE DATA TRANSPORT
FROM SOURCE MACHINE TO
DESTINATION MACHINE,
INDEPENDENTLY OF THE PHYSICAL
NETWORK OR NERWORKS
CURRENTLY IN USE.
BLM431 Computer Networks 3
Dr.Refik Samet
The Application Layer
• Layers below the application
layer are there to provide reliable
transport, but they do not do real
work for users.
• In this chapter we will study
some real network applications.
BLM431 Computer Networks 4
Dr.Refik Samet
The Application Layer
• In the application layer there is also need
for support protocols, to allow the
applications to function.
• One of them is DNS which handles
naming within the Internet.
• Three real applications:
1. Electronic Mail
2. The World Wide Web
3. Multimedia
BLM431 Computer Networks 5
Dr.Refik Samet
The Application Layer’s topics
7.1. DNS – The Domain Name System
7.2. Electronic Mail
7.3. The World Wide Web
7.4. Multimedia
7.5. Summary
BLM431 Computer Networks 6
Dr.Refik Samet
7.1. DNS – The Domain Name System
• 7.1.1. The DNS Name Space
• 7.1.2. Resource Records
• 7.1.3. Name Servers
BLM431 Computer Networks 7
Dr.Refik Samet
7.1. DNS – The Domain Name System
• Network addresses (e.g., IP) are hard
for people to remember.
• Also, sending e-mail to
tana@128.111.24.41 means that if
Tana’s ISP moves the mail server to a
different machine with different IP
address, her e-mail address has to
change. BLM431 Computer Networks 8
Dr.Refik Samet
7.1. DNS – The Domain Name System
• Consequently, ASCII names were
introduced to decouple machine names
from machine addresses.
• In this way, Tana’s address might be
something like tana@art.ucsb.edu.
• Nevertheless, network itself understand
only numerical addresses, so some
mechanism is required to convert the
ASCII srtings to network addresses.
BLM431 Computer Networks 9
Dr.Refik Samet
7.1. DNS – The Domain Name System
• DNS (Domain Name System) solves this
problem.
• The essence of DNS is the invention of a
hierarchical, domain-based naming scheme
and a distributed database system for
implementing this naming scheme.
• DNS is primarily used for mapping host names
and e-mail destinations to IP addresses but can
also be used for other purposes.
BLM431 Computer Networks 10
Dr.Refik Samet
7.1. DNS – The Domain Name System
• DNS is used as follows.
• To map a name onto an IP address, an
application program calls a library
procedure called the resolver, passing it
the name as a parameter.
BLM431 Computer Networks 11
Dr.Refik Samet
7.1. DNS – The Domain Name System
• Resolver sends a UDP packet to a local
DNS server, which then looks up the
name and returns the IP address to the
resolver, which then returns it to the
caller.
• Armed with the IP address, the program
can then establish a TCP connection with
the destination or send it UDP packets.
BLM431 Computer Networks 12
Dr.Refik Samet
7.1.1. The DNS Name Space
• Internet is divided into over 200 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.
BLM431 Computer Networks 13
Dr.Refik Samet
7.1.1. The DNS Name Space
A portion of the Internet domain name space.
BLM431 Computer Networks 14
Dr.Refik Samet
7.1.1. 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.
• The top-level domains come in two
flavors: generic and countries.
BLM431 Computer Networks 15
Dr.Refik Samet
7.1.1. The DNS Name Space
• Top-level general-purpose domains:
• Commercial (com)
• Educational institutions (edu)
• Governments (gov)
• Certain international organizations (int)
• Armed forces (mil)
• Network providers (net)
• Nonprofit organizations (org)
BLM431 Computer Networks 16
Dr.Refik Samet
7.1.1. The DNS Name Space
• Business (biz) – 2000, ICANN
• Information (inf) – 2000, ICANN
• Peaple’s names (name) – 2000, ICANN
• Professions (pro) – 2000, ICANN
• Aerospace industry (aero) - by request
• Co-operatives (coop) - by request
• Museums (museum) - by request, etc
BLM431 Computer Networks 17
Dr.Refik Samet
7.1.1. The DNS Name Space
• In general, getting a second-level domain,
such as name-of-company.com, is easy.
• It requires going to a registrar for the
corresponding top-level domain (com in
this case) to check if the desired name is
available and not somebody’s trademark.
• If there are no problems, the register pays
a small annual fee and gets the name.
BLM431 Computer Networks 18
Dr.Refik Samet
7.1.1. The DNS Name Space
• Each domain is named by the path upward
from it to the root.
• The components are separated by periods
(pronounced “dot”).
• eng.sun.com is the engineering
department at Sun Microsystems.
• eng/sun/com is UNIX-style
BLM431 Computer Networks 19
Dr.Refik Samet
7.1.1. The DNS Name Space
• Domain names are case insensitive, so
edu, Edu, and EDU mean the same thing.
• Component names can be up to 63
characters long, and full path names must
not exceed 255 characters.
•
BLM431 Computer Networks 20
Dr.Refik Samet
7.1.1. The DNS Name Space
• Domains can be inserted into the tree in
two different ways.
• cs.yale.edu
• cs.yale.ct.us
• Most organization in the United States are
under a generic domain, and most outside
the United States are under the domain of
their country.
BLM431 Computer Networks 21
Dr.Refik Samet
7.1.1. The DNS Name Space
• Each domain controls how it allocates the
domains under it.
• For example, Japon has domains ac.jp and
co.jp that mirror edu and com
• The Netherlands does not make this
distinction and puts all organization
directly under nl
BLM431 Computer Networks 22
Dr.Refik Samet
7.1.1. The DNS Name Space
• Thus, all three of the following are
university computer science departments:
• cs.yale.edu (Yale University, in the US)
• cs.vu.nl (Vrije Universiteit, in the Netherl)
• cs.keio.ac.jp (Keio University, in Japan)
• Naming follows organizational
boundaries, not physical networks.
BLM431 Computer Networks 23
Dr.Refik Samet
7.1.2. Resource Records
• Every domain, whether it is a single host
or a top-level domain, can have a set of
resource records associated with it.
• For a single host, the most common
resource record is just its IP address, but
many other kinds of resource records also
exist.
BLM431 Computer Networks 24
Dr.Refik Samet
7.1.2. Resource Records
• When a resolver gives a domain name to
DNS, what it gets back are the resource
records associated with that name.
• Thus, the primary function of DNS is to
map domain names onto resource
records.
BLM431 Computer Networks 25
Dr.Refik Samet
7.1.2. Resource Records
• A resource record is a five-tuple.
• Resource records are presented as ASCII
text, one line per resource record.
• The format we will use is as follows:
• Domain_name Time_to_live Class
Type Value
BLM431 Computer Networks 26
Dr.Refik Samet
7.1.2. Resource Records
• Domain_name
• It tells the domain to which this record
applies.
• Normally, many records exist for each
domain and each copy of the database
holds information about multiple
domains.
• This field is thus the primary search key
used to satisfy queries.
BLM431 Computer Networks 27
Dr.Refik Samet
7.1.2. Resource Records
• Time_to_live
• It gives an indication of how stable the
record is.
• Information that is highly stable is
assigned a large value, such as 86400
(the number of seconds in 1 day).
• Information that is highly volatile is
assigned a small value, such as 60 (1
minute). BLM431 Computer Networks 28
Dr.Refik Samet
7.1.2. Resource Records
• Class
• For Internet information, it is always IN.
• Type
• It tells what kind of record this is
• The most important types are listed in
following figure.
BLM431 Computer Networks 29
Dr.Refik Samet
7.1.2. Resource Records
The principal DNS resource records types.
BLM431 Computer Networks 30
Dr.Refik Samet
7.1.2. Resource Records
• Value
• This field can be a number, a domain
name, or an ASCII string.
• The semantics depend on the record type.
• Following figure depicts part of a
database for the cs.vu.nl domain shown
on slide number 12.
BLM431 Computer Networks 31
Dr.Refik Samet
7.1.2. Resource Records
A portion of a possible DNS database for cs.vu.nl.
BLM431 Computer Networks 32
Dr.Refik Samet
7.1.3. Name Servers
• In theoty at least, a single name server
could contain the entire DNS database
and respond to all queries about it.
• In practice, this server would be so
overloaded as to be useless.
• Futhermore, if it ever went down, the
entire Internet would be crippled.
BLM431 Computer Networks 33
Dr.Refik Samet
7.1.3. Name Servers
• To avoid the problems associated
with having only a single source of
information, the DNS name space is
divided into nonoverlapping zones.
• One possible way to divide the name
space on slide 12 is shown in
following figure.
BLM431 Computer Networks 34
Dr.Refik Samet
7.1.3. Name Servers
Part of the DNS name space showing the division into zones.
BLM431 Computer Networks 35
Dr.Refik Samet
7.1.3. Name Servers
How a resolver looks up a remote name in eight steps.
BLM431 Computer Networks 36
Dr.Refik Samet
7.2. Electronic Mail
• Electronic mail, or e-mail, like other forms
of communication, has its own
conventions and style.
• e-mail is very informal and has a low
threshold of use.
• e-mail is full of jargon
• Many people also use litle ASCII symbols
called smileys or emoticons in their e-
mail… BLM431 Computer Networks 37
Dr.Refik Samet
7.2. Electronic Mail
Some smileys. They will not be on the final exam :-).
BLM431 Computer Networks 38
Dr.Refik Samet
7.2. Electronic Mail
• The first e-mail systems simply consisted
of file transfer protocols, with the
convention that the first line of each
message (i.e., file) contained the
recipient’s address.
BLM431 Computer Networks 39
Dr.Refik Samet
7.2. Electronic Mail
• Some of the complaints were as follows:
a) Sending a message to a group of people
was inconvenient.
b) Messages had no internal structure,
making computer processing difficult.
c) The sender never knew if a message
arrived or not.
d) It was not possible to create and send
messages containing a mixture of text,
drawings, facsimile, and voice, etc.
BLM431 Computer Networks 40
Dr.Refik Samet
7.2. Electronic Mail
• 1982 – RFC 821 (transmission protocol)
and RFC 822 (message format)
• 1984 – X.400
• After two decades of competition, e-mail
systems based on RFC 822 are widely
used.
BLM431 Computer Networks 41
Dr.Refik Samet
7.2. Electronic Mail
• Architecture and Services
• The User Agent
• Message Formats
• Message Transfer
• Final Delivery
BLM431 Computer Networks 42
Dr.Refik Samet
7.2.1. Architecture and Services
• What e-mail systems can do and how they
are organized?
• There are two subsystems in e-mail
systems
a) User agents allow people to read and send
e-mail.
b) Message transfer agents move messages
from the source to the destination.
BLM431 Computer Networks 43
Dr.Refik Samet
7.2.1. Architecture and Services
e-mail systems support five basic
functions
• Composition
• Transfer
• Reporting
• Displaying
• Disposition
BLM431 Computer Networks 44
Dr.Refik Samet
7.2.1. Architecture and Services
A few of advanced features:
• Mailboxes
• Mailing list
• Carbon copies
• Blind carbon copies
• Etc.
BLM431 Computer Networks 45
Dr.Refik Samet
7.2.1. Architecture and Services
• A key idea in e-mail systems is the
distinction between the envelope and its
contents.
• The envelope encapsulates the message
• It contains all the information needed
for transporting the message, such as the
destination address, priority, and
security level, all of which are distinct
from the message itself.
BLM431 Computer Networks 46
Dr.Refik Samet
7.2.1. Architecture and Services
• Message inside the envelope consists of
two parts:
• The header and the body
• The header contains control information
for the user agents.
• The body is entirely for the human
recipient.
BLM431 Computer Networks 47
Dr.Refik Samet
7.2.1. Architecture and Services
Envelopes and messages.BLM431
(a) Computer
PaperNetworks
mail. (b) Electronic mail.
48
Dr.Refik Samet
7.2.2. The User Agent
• A user agent is normally a program
(sometimes called a mail reader) that
accepts a variety of commands for
composing, receiving, and replying to
message, as well as for manipulating
mailboxes.
BLM431 Computer Networks 49
Dr.Refik Samet
7.2.2. The User Agent
• SENDING E-MAIL
• To send an e-mail message, a user must
provide the message, the destination address,
and possiply some other parameters,
• The message can be produced with a free-
standing text editor, a word processing
program, etc
• Most e-mail systems support mailing lists, so
that a user can send same message to a list of
people with a single command.
BLM431 Computer Networks 50
Dr.Refik Samet
7.2.2. The User Agent
• READING E-MAIL
• Typically, when a user agent is started up, it
looks at the user’s mailbox for incoming e-
mail before displaying anything on the
screen.
• Then it may announce the number of
messages in the mailbox or display a one-
line summary of each one and wait for a
command.
BLM431 Computer Networks 51
Dr.Refik Samet
7.2.2. Reading E-mail
An example display of the contents of a mailbox.
BLM431 Computer Networks 52
Dr.Refik Samet
7.2.3 Message Formats – RFC 822
• Messages consist of :
• a primitive envelope,
• some number of header fields,
• a blank line,
• and then message body
BLM431 Computer Networks 53
Dr.Refik Samet
7.2.3 Message Formats – RFC 822
• Each header field consists of a single line of
ASCII text containing the field name, a
colon, and, for most fields, a value.
• In normal usage, the user agent builds a
message and passes it to the message transfer
agent, which then uses some of the header
fields to construct the actual envelope.
BLM431 Computer Networks 54
Dr.Refik Samet
7.2.3 Message Formats – RFC 822
RFC 822 header fields related to message transport.
BLM431 Computer Networks 55
Dr.Refik Samet
Message Formats – RFC 822 (2)
Some fields used in the RFC 822 message header.
BLM431 Computer Networks 56
Dr.Refik Samet
MIME – Multipurpose Internet Mail
Extensions
•In the early days of the ARPANET, e-
mail consisted exclusivly of text
messages written in English and
expressed in ASCII.
•For this environment, RFC 822 did the
job completely: it specified the headers
but left the content entirely up to the
users.
BLM431 Computer Networks 57
Dr.Refik Samet
MIME – Multipurpose Internet Mail
Extensions
Problems with international languages:
• Languages with accents
(French, German).
• Languages in non-Latin alphabets
(Hebrew, Russian).
• Languages without alphabets
(Chinese, Japanese).
• Messages not containing text at all
(audio or images).
BLM431 Computer Networks 58
Dr.Refik Samet
MIME – Multipurpose Internet Mail
Extensions
•A solution was proposed in RFC 1341 and
updated in RFCs 2045-2049.
•This solution, called MIME (Multipurpose
Internet Mail Extensions) is now widely
used.
•The basic idea of MIME is to continue to
use the RFC 822 format, but to add
srtucture to the message body and define
encoding rules for non-ASCII messages.
BLM431 Computer Networks 59
Dr.Refik Samet
MIME (2)
RFC 822 headers added by MIME.
BLM431 Computer Networks 60
Dr.Refik Samet
MIME (3)
The MIME types and subtypes defined in RFC 2045.
BLM431 Computer Networks 61
Dr.Refik Samet
MIME (4)
A multipart message containing enriched
BLM431 Computer and audio alternatives.
Networks 62
Dr.Refik Samet
7.2.4. Message Transfer
•The message transfer system is concerned
with relaying messages from the originator
to the recipient.
•The simplest way to do this is to establish
a transport connection from the source
machine to the destination machine and
then just transfer the message.
BLM431 Computer Networks 63
Dr.Refik Samet
7.2.4. Message Transfer
•SMTP – The Simple Mail Transfer
Protocol
•Within the Internet, e-mail is delivered by
having the source machine establish a TCP
connection to port 25 of the destination
machine.
•Listening to this port is an e-mail daemon
that speaks SMTP.
BLM431 Computer Networks 64
Dr.Refik Samet
7.2.4. Message Transfer
•This daemon accepts incoming
connections and copies messages from
them into the appropriate mailboxes.
•If a message cannot be delivered, an error
report containing the first part of the
undeliverable message is returned to the
sender.
BLM431 Computer Networks 65
Dr.Refik Samet
7.2.4. Message Transfer
•SMTP is a simple ASCII protocol.
•After establishing the TCP connection to
port 25, the sending machine, operating as
the client, waits for the receiving machine,
operating as the server, to talk first.
BLM431 Computer Networks 66
Dr.Refik Samet
7.2.4. Message Transfer
•The server starts by sending a line of text
giving its identity and telling whether it is
prepared to receive mail.
•If it is not, the client releases the
connection and tries again later.
BLM431 Computer Networks 67
Dr.Refik Samet
7.2.4. Message Transfer
•If the server is willing to accept e-mail,
the client announces whom the e-mail is
coming from and whom it is going to.
•If such a recipient exists at the
destination, the server gives the client the
go-ahead to send the message.
BLM431 Computer Networks 68
Dr.Refik Samet
7.2.4. Message Transfer
•Then the client sends the message and the
server acknowledges it.
•No checksums are needed because TCP
provides a reliable byte stream.
•If there is more e-mail, that is now sent.
•When all the e-mail has been exchanged
in both directions, the connection is
released. BLM431 Computer Networks
Dr.Refik Samet
69
Message Transfer
Transferring a message
from
elinore@abc.com to
carolyn@xyz.com.
BLM431 Computer Networks 70
Dr.Refik Samet
7.2.5. Final Delivery
•What happens when Elinor wants to send
Carolyn e-mail and Carolyn is not
currently on-line?
•Elinor cannot establish a TCP connection
to Carolyn and thus cannot run the SMTP
protocol.
BLM431 Computer Networks 71
Dr.Refik Samet
7.2.5. Final Delivery
•One solution is to have a message transfer
agent on an ISP machine accept e-mail for
its customers and store it in their
mailboxes on an ISP machine.
•Since this agent can be on-line all the
time, e-mail can be sent to it 24 hours a
day.
BLM431 Computer Networks 72
Dr.Refik Samet
7.2.5. Final Delivery - POP3
•How does the user get the e-mail from the
ISP’s message transfer agent?
•The solution to this problem is to create
another protocol that allows user transfer
agents (on client PCs) to contact the
message transfer agent (on ISP’s machine)
and allow e-mail to be copied from the ISP
to the user.
•POP3 – Post Office Protocol Version 3
BLM431 Computer Networks
Dr.Refik Samet
73
7.2.5. Final Delivery
(a) Sending and reading mail when the receiver has a permanent
Internet connection and the user agent runs on the same machine as
the message transfer agent. (b) Reading e-mail when the receiver has
a dial-up connection to an ISP.
BLM431 Computer Networks 74
Dr.Refik Samet
7.2.5. Final Delivery - POP3
Using POP3BLM431
to fetch three messages.
Computer Networks 75
Dr.Refik Samet
7.2.5. Final Delivery - IMAP
•IMAP – Internet Message Access Protocol
•IMAP assumes that all the e-mail will remain
on the server indefinitely in multiple
mailboxes.
•But POP3 basically assumes that the user will
clear out the mailbox on every contact and
work off-line after that.
•IMAP – provides extensive mechanisms for
reading message or even parts of messages.
BLM431 Computer Networks 76
Dr.Refik Samet
IMAP
A comparison of POP3 and IMAP.
BLM431 Computer Networks
Dr.Refik Samet
77