Application Layer
Application Layer
Application Layer
Application Layer
• Principles of Network Applications
• The Web and HTTP
• Electronic Mail in the Internet
• DNS—The Internet’s Directory Service
The network application is an application running on one host and
provide a communication to another application running on a
different host.
One do not need to write software that runs on network core devices,
such as routers or link-layer switches.
Security
Transport protocol can provide an application with one or more
security services.
For example, in the sending host, a transport protocol can encrypt all
data transmitted by the sending process, and in the receiving host, the
transport-layer protocol can decrypt the data before delivering the data
to the receiving process.
Transport Services Provided by the Internet
Application-Layer Protocols
An application-layer protocol defines:
The types of messages exchanged, for example, request messages and
response messages
The syntax of the various message types ( fields in the message).
The semantics of the fields (meaning of the information in the fields)
Rules for determining when and how a process sends messages and
responds to messages.
With persistent connections, the server leaves the TCP connection open
after sending a response.
Subsequent HTTP message between same client and server can be sent
over a single persistent TCP connection.
HTTP Message Format
Two types of HTTP messages:
• Request messages and
• Response messages
HTTP Request Message:
The Date: header line indicates the time and date when the HTTP
response was created and sent by the server.
The Server: header line indicates that the message was generated by
an Apache Web server; it is analogous to the User-agent.
The Last-Modified: indicates the time and date when the object was
created or last modified.
Although not all sites use cookies, most major portals, such as Yahoo,
e-commerce, such as Amazon sites make extensive use of cookies.
The Cookie is a small message from a web server passed to the user’s
browser when you visit a website.
HTTP has a mechanism that allows a cache to verify that its objects
are up to date. This mechanism is called the conditional GET.
The cache forwards the object to the requesting browser but also
caches the object locally. Importantly, the cache also stores the last-
modified date along with the object.
Third, one week later, another browser requests the same object via
the cache, and the object is still in the cache. Since, this object may
have been modified at the web server in the past week, the cache
performs an up-to-date check by issuing a conditional GET.
Specifically, the cache sends:
GET /fruit/kiwi.gif HTTP/1.1
Host: www.exotiquecuisine.com
If-modified-since: Wed, 7 Sep 2011 09:23:2
Not that the value of the If-modified-since: header line is exactly
equal to the value of the Last-Modified: header line that was sent by
the server one week ago.
This conditional GET is telling the server to send the object only if the
object has been modified since the specified date.
Suppose the object has not been modified since 7 Sep 2011 09:23:24.
Then, fourth, the web server sends a response message to the cache:
HTTP/1.1 304 Not Modified
Date: Sat, 15 Oct 2011 15:39:29
Server: Apache/1.3.0 (Unix)
(empty entity body)
We see that in response to the conditional GET, the web server still
sends a response message but does not include the requested object in
the response message.
Including the requested object would only waste bandwidth and
increase user-perceived response time, particularly if the object is
large.
Electronic Mail in the Internet
It is the internet’s most important and utilized applications.
User agents allow users to read, reply to, forward, save, and compose
messages.
Mail servers form the core of the e-mail infrastructure. Each recipient
has a mailbox located in one of the mail servers.
It uses the reliable data transfer service of TCP to transfer mail from
the sender’s mail server to the recipient’s mail server.
SMTP
SMTP – Simple Mail Transfer Protocol defined in RFC 5321, is at
the heart of internet electronic mail.
This restriction made sense in early 1980s and no one was e-mailing
large attachments or large image, audio, or video files.
But today, in the multimedia era, the 7-bit ASCII restriction is a bit of
a pain
To illustrate the basic operation of SMTP, Suppose Alice wants to
send Bob a simple ASCII message.
1. Alice invokes her user agent for e-mail, provides Bob’s e-mail
address (for example, [email protected]), composes a message,
and instructs the user agent to send the message.
2. Alice’s user agent sends the message to her mail server, where it is
places in a message queue
3. The client side of SMTP, running on Alice’s mail server, sees the
message in the message queue. It opens a TCP connection to an
SMTP server, running on Bob’s mail server.
4. After some initial SMTP handshaking, the SMTP client sends Alice’s
message into the TCP connection.
5. At Bob’s mail server, the server side of SMTP receives the message.
Bob’s mail server then places the message in Bob’s mailbox.
6. Bob invokes his user agent to read the message at his convenience.
Comparison with HTTP
Both protocols (HTTP and SMTP) are used to transfer files from one
host to another:
HTTP transfers files (also called objects) from a Web server to a Web
client (typically a browser);
SMTP transfers files (that is, e-mail messages) from one mail server
to another mail server.
SMTP HTTP
SMTP is used for mail services. HTTP is mainly used for data and
file transfer.
It uses port 25. It uses port 80.
It imposes a 7-bit ASCII restriction It does not impose a 7-bit ASCII
on the content to be transferred restriction. Can transfer
multimedia, hyperlinks, etc
SMTP transfers emails via Mail HTTP transfers files between the
Servers. Web server and the Web client.
SMTP is a persistent type of TCP It can use both Persistent and Non-
connection. persistent.
Has a smaller message size limit Has a larger message size limit
compared to HTTP. compared to SMTP.
Requires authentication for sending Does not require authentication for
emails. browsing web pages.
TCP UDP
To fetch the mail from mail server, receiver use mail access protocols.
There are two possible responses: +OK used by the server to indicate
that the previous command was fine; and
-ERR, used by the server to indicate that something was wrong with
the previous command.
Internet Mail Access Protocol (IMAP)
With POP3, once user has downloaded his messages to the local
machine, he can create mail folders and move the downloaded
messages into the folders.
User can then delete messages, move messages across folders, and
search for messages.
But this poses a problem for the nomadic user(someone who lives by
traveling from place to place) who would prefer to maintain a folder
hierarchy on a remote server that can be accessed from any computer.
This is not possible with POP3—the POP3 protocol does not provide
any means for a user to create remote folders and assign messages to
folders.
To solve this and other problems, the IMAP protocol was invented.
Like POP3, IMAP is a mail access protocol. It has many more
features than POP3, but it is also significantly more complex.
An IMAP server will associate each message with a folder; when a
message first arrives at the server, it is associated with the recipient’s
INBOX folder.
The recipient can then move the message into a new, user-created
folder, read the message, delete the message, and so on.
Web-Based E-Mail
More and more users today are sending and accessing their e-mail
through their Web browsers.
In this case user communicates with its remote mailbox via HTTP.