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

Chapter 3 Application Layer

The document discusses the application layer and application layer protocols. It defines what an application layer protocol is and provides examples of application layer protocols like HTTP and SMTP. It explains that an application layer protocol defines how processes communicate by exchanging messages and passing data. It also discusses key concepts like client-server model, addressing processes, user agents, and HTTP requests.

Uploaded by

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

Chapter 3 Application Layer

The document discusses the application layer and application layer protocols. It defines what an application layer protocol is and provides examples of application layer protocols like HTTP and SMTP. It explains that an application layer protocol defines how processes communicate by exchanging messages and passing data. It also discusses key concepts like client-server model, addressing processes, user agents, and HTTP requests.

Uploaded by

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

ECE 303 Communication Networks

Chapter 3
Application Layer
DR. SHUVABRATA BANDOPADHAYA
Application Layer
For a network application's software/ process is distributed among two or more end systems (i.e., host
computers).

For example, with the Web there are two pieces of software that communicate with each other:

1. Browser software in the user's host (PC, Mac or workstation), and


2. Web server software in the Web server.

Processes on two different end systems communicate with each other by exchanging messages across the
computer network.

1. A sending process creates and sends messages into the network;


2. A receiving process receives these messages and possibly responds by sending messages back.

Networking applications have application-layer protocols that define the format and order of the messages
exchanged between processes, as well as the actions taken on the transmission or receipt of a message.

BANASTHALI 2
Network application and application protocols
An application-layer protocol is only one piece (albeit, a big piece) of a network application.

Ex 1:

 The Web is a network application that allows users to obtain "documents" from Web
servers on demand.
 The Web application consists of many components, including a standard for document
formats (i.e., HTML), Web browsers (e.g., Google chrome and Internet Explorer), Web
servers (e.g., Apache, Microsoft and Netscape servers), and an application-layer protocol.
 The Web's application-layer protocol, HTTP (the HyperText Transfer Protocol, defines how
messages are passed between browser and Web server.
 Thus, HTTP is only one piece (albeit, a big piece) of the Web application.

BANASTHALI 3
Ex 2
 Internet electronic mail has many components, including mail servers that house user
mailboxes, mail readers that allow users to read and create messages, a standard for
defining the structure of an email message (i.e., MIME) and application-layer protocols.
 The application layer protocol defines:
1. how messages are passed between servers,
2. how messages are passed between servers and mail readers, and
3. how the contents of certain parts of the mail message (e.g., a mail message header) are to
be interpreted.
 The principal application-layer protocol for electronic mail is SMTP (Simple Mail Transfer
Protocol.
 Thus, SMTP is only one piece (albeit, a big piece) of the email application
BANASTHALI 4
What application layer protocol defines?
An application layer protocol defines how an application's processes, running on
different end systems, pass messages to each other. In particular, an application
layer protocol defines:
 the types of messages exchanged, e.g., request messages and response
messages;
 the syntax of the various message types, i.e., the fields in the message and
how the fields are delineated;
 the semantics of the fields, i.e., the meaning of the information in the fields;
 rules for determining when and how a process sends messages and responds
to messages.
BANASTHALI 5
Processes Communicating Across a Network
The two processes communicate with each other by sending and receiving
messages through their sockets.
A socket is the interface between the application layer and the transport layer
within a host.

BANASTHALI 6
Cont.
A process's socket can be thought of as the process's door: a process sends messages
into, and receives message from, the network through its socket.
When a process wants to send a message to another process on another host, it shoves
the message out its door.
The process assumes that there is a transportation infrastructure on the other side of
the door that will transport the message to the door of the destination process.
It is also referred to as the API (application programmers’ interface) as the socket is
the programming interface with which networked applications are built in the Internet.
The application developer has control of everything on the application-layer side of the
socket but has little control of the transport-layer side of the socket

BANASTHALI 7
Addressing Processes
To send a message by a process on one host to a process on another host, the sending
process must identify the receiving process.

To identify the receiving process, one must typically specify two pieces of information:

i. Name or address of the host machine: Globally unique IP address


ii. Port number: An identifier that specifies the identity of the receiving process on the
destination host.
 Each application process needs a unique port number using which two processes in
distinct hosts can communicate.
 Popular application-layer protocols have been assigned specific port numbers. (Ex: HTTP:
80; SMTP: 25)
 When a developer creates a new network application, the application must be assigned a
new port number. BANASTHALI 8
User Agents
The user agent is an interface between the user and the network application.

Example:

For Web applications, the user agent is a browser such as Google chrome or Microsoft
Explorer.

The browser allows a user to view Web pages, to navigate in the Web, to provide input to
forms, to interact with Java applets, etc.

The browser implements the client side of the HTTP protocol.

i. It provides interface to users


ii. It provides interface to transport layer via socket.

BANASTHALI 9
Client-server model:

• The client-server model describes how a


server provides resources and services to
one or more clients.
• When a client requests a connection to a
server, the server can either accept or
reject the connection.
• If the connection is accepted, the server
establishes and maintains a connection
with the client over a specific protocol.
• The server serves a specific client by
receiving request from the client via the
protocol and responds with the needful
content
10
• This is the foundation for data communication for the World Wide Web
(i.e. internet).
• It is an application-level protocol for distributed, collaborative,
hypermedia information systems.
• HTTP functions as a request–response protocol in the client–server
computing model.
• HTTP has four versions — HTTP/0.9, HTTP/1.0, HTTP/1.1, and
HTTP/2.0. Today the version in common use is HTTP/1.1 and the future
HTTP: will be HTTP/2.0.

11
• Basically, HTTP is a TCP/IP based communication
protocol, that is used to deliver data (HTML files, image
files, query results, etc.) on the World Wide Web.
• The default port is TCP 80, but other ports can be used
as well.
• HTTP specification specifies how clients' request data

HTTP will be constructed and sent to the server, and how


the servers respond to these requests.
Protocol • The HTTP client initiates an HTTP request and after a
request is made, the client waits for the response.
Basics: • The server processes the request and sends a response
back after which client disconnect the connection.
• So, client and server know about each other during
current request-response cycle only.
• Further requests are made on new connection like
client and server are new to each other.

12
HTTP Request
Format:

13
• It begins with a method token, followed by the
Request-URI and the protocol version, and
ending with CRLF.
• The elements are separated by space SP
characters.
HTTP
Request-Line = Method SP
Request Request-URI SP HTTP-Version CRLF
Line:

14
Request Method:
It indicates the method to be performed on the resource identified by the given Request-URI.

] Method and Description

1 GET

The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only
retrieve data and should have no other effect on the data.

2 HEAD
Same as GE but transfers the status line and header section only.

3 POST
A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.

4 PUT
Replaces all current representations of the target resource with the uploaded content.

5 DELETE
Removes all current representations of the target resource given by a URI.

15
Uniform Resource Indicator (URI))

• A URI is used to uniquely identify a resource over the


web. URL has the following syntax: • Example
http://www.nowhere123.com/docs/index.html,
protocol://hostname:port/path-and-file-name
Protocol: HTTP;
• There are 4 parts in a URI: Hostname: www.nowhere123.com.
Port number: not specified (default TCP port 80 for
HTTP )
1. Protocol: The application-level protocol used
The path and file name: "/docs/index.html".
by the client and server, e.g., HTTP, FTP, and
telnet.
• Other examples of URL are:
2. Hostname: The DNS domain name (e.g.,
www.nowhere123.com) or IP address (e.g.,
192.128.1.2) of the server. ftp://www.ftp.org/docs/test.txt
3. Port: The TCP port number that the server is mailto:[email protected]
listening for incoming requests from the clients. news:soc.culture.Singapore
4. Path-and-file-name: The name and location of telnet://www.nowhere123.com/
the requested resource, under the server
document base directory.

16
• The request headers are in the form of name:value
pairs.
• Multiple values, separated by commas, can be
specified.

request-header-name: request-header-
Request value1, request-header-value2, ...

Header: • Examples of request headers are:

Host: www.xyz.com
Connection: Keep-Alive
Accept: image/gif, image/jpeg, */*
Accept-Language: us-en, fr, cn
17
HTTP Request Example:

18
HTTP Response:
• When this request message reaches the server, the server can take either one of these actions:

1. The server interprets the request received, maps the request into a file under the server's document
directory, and returns the file requested to the client.
2. The server interprets the request received, maps the request into a program kept in the server, executes the
program, and returns the output of the program to the client.
3. The request cannot be satisfied, the server returns an error message.
Example of a HTTP Respond:
HTTP/1.1 200 OK
Date: Sun, 18 Oct 2009 08:56:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Sat, 20 Nov 2004 07:16:26 GMT
ETag: "10000000565a5-2c-3e94b66c2e680“
Accept-Ranges: bytes
Content-Length: 44
Connection: close Content-Type: text/html
X-Pad: avoid browser bug

<html><body><h1>It works!</h1></body></html>
19
HTTP Request-Response Cycle

20
 A cache is both a server and a client at the same time.
 When it receives requests from and sends responses to a browser, it is a server.
 When it sends requests to and receives responses from an origin server it is a client

BANASTHALI 21
Working of HTTP process via proxy:
 The browser establishes a TCP connection to the
proxy server and sends an HTTP request for the
object to the Web cache.
 The Web cache checks to see if it has a copy of
the object stored locally. If it does, the Web
cache forwards the object within an HTTP
response message to the client browser.
 If the Web cache does not have the object, the Web cache opens a TCP connection to the origin
server.
 The Web cache then sends an HTTP request for the object into the TCP connection. After
receiving this request, the origin server sends the object within an HTTP response to the Web
cache.
 When the Web cache receives the object, it stores a copy in its local storage and forwards a
copy, within an HTTP response message, to the client browser (over the existing TCP connection
between the client browser and the Web cache)

BANASTHALI 22
Advantages:
1. It reduces the response time by serving many requests locally.
2. It significantly reduces internet traffic by serving most of the HTTP requests
3. Additional security has been introduced at proxy server

BANASTHALI 23
Cooperative Caching
 Multiple Web caches, located at different places in the Internet, can
cooperate and improve overall performance.
 For example, an institutional cache can be configured to send its HTTP
requests to a cache in a backbone ISP at the national level.
 In this case, when the institutional cache does not have the requested object
in its storage, it forwards the HTTP request to the national cache.
 The national cache then retrieves the object from its own storage or, if the
object is not in storage, from the origin server.
 The national cache then sends the object (within an HTTP response message)
to the institutional cache, which in turn forwards the object to the requesting
browser.
BANASTHALI 24
 Whenever an object passes through a cache (institutional or national), the cache
leaves a copy in its local storage.
 The advantage of passing through a higher-level cache, such as a national cache, is
that it has a larger user population and therefore higher hit rates.
BANASTHALI 25
Electronic Mail in the Internet
Electronic mail (email) is one of the most popular Internet applications.

Email is asynchronous in nature i.e.


-- people send and read messages when it is convenient for them, without having
to coordinate with other peoples' schedules.

Electronic mail is fast, easy to distribute, and inexpensive.

Modern electronic mail messages can include hyperlinks, HTML formatted text,
images, sound and even video.
BANASTHALI 26
It has three major components:
1. User agents
2. Mail servers
3. Simple Mail Transfer Protocol
(SMTP).

High-level view of the Internet mail system


BANASTHALI 27
Alice sending message to Bob

 User agents for email is the mail readers that allow users to read, reply to, forward,
save, and compose messages.

 When Alice is finished composing her message, her user agent sends the message to
her mail server.

 The message is placed in the mail server's outgoing message queue.

 In its turn, the mail server of Alice sends the massage to Bob’s mail server.

 When Bob wants to read a message, his user agent obtains the message from his
mailbox in his mail server.
BANASTHALI 28
 Mail servers form the core of the e-mail infrastructure.

 Each recipient, such as Bob, has a mailbox located in one of the mail servers.

 Bob's mailbox manages and maintains the messages that have been sent to him.

 A typical message starts its journey in the sender's user agent, travels to the sender's mail server,
and then travels to the recipient's mail server, where it is deposited in the recipient's mailbox.

 When Bob wants to access the messages in his mailbox, the mail server containing the mailbox
authenticates Bob (with user names and passwords).

 Alice's mail server must also deal with failures in Bob's mail server.

 If Alice's server cannot deliver mail to Bob's server, Alice's server holds the message in a message
queue and attempts to transfer the message later.

 Reattempts are often done every 30 minutes or so; if there is no success after several days, the
server removes the message and notifies the sender (Alice) with an email message.
BANASTHALI 29
Simple Mail Transfer Protocol (SMTP)
It is the principle application-layer protocol for Internet electronic mail.
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 has two sides:
i. a client side which executes on the sender's mail server, and
ii. a server side which executes on the recipient's mail server.
Both the client and server sides of SMTP run on every mail server.
When a mail server sends mail (to other mail servers), it acts as an SMTP client.
When a mail server receives mail (from other mail servers) it acts as an SMTP server.

BANASTHALI 30
Basic operation of SMTP
Alice invokes her user agent for email, provides Bob's email
address (e.g., [email protected]), composes a message
and instructs the user agent to send the message.
Alice's user agent sends the message her mail server,
where it is placed in a message queue.
The client side of SMTP, running on Alice's mail server, sees
the message in the message queue. It opens a TCP
connection to a SMTP server, running on Bob's mail server.

 After some initial SMTP handshaking, the SMTP client sends Alice's message into the TCP
connection.
 At Bob's mail server host, the server side of SMTP receives the message. Bob's mail server then
places the message in Bob's mailbox.
 Bob invokes his user agent to read the message at his convenience.

BANASTHALI 31
Some additional points:
Port number of SMTP: 25
SMTP does not use intermediate mail servers for sending mail, even when the
two mail servers are located at opposite ends of the world.
If Alice's server is in Hong Kong and Bob's server is in Mobile, Alabama, the TCP
"connection" is a direct connection between the Hong Kong and Mobile servers.
In particular, if Bob's mail server is down, the message remains in Alice's mail
server and waits for a new attempt. The message does not get placed in some
intermediate mail server.
After connection is established, the server and client perform some
application-layer handshaking.

BANASTHALI 32
Difference between HTTP & SMTP
HTTP is principally a pull protocol –
•someone loads information on a Web server and users use HTTP to pull the
information off the server at their convenience.
•In particular, the TCP connection is initiated by the machine that wants to
receive the file.
On the other hand, SMTP is primarily a push protocol –
•the sending mail server pushes the file to the receiving mail server.
•In particular, the TCP connection is initiated by the machine that wants to send
the file.

BANASTHALI 33
Mail Access Protocols

Once SMTP delivers the message from Alice's mail server to Bob's mail server, the
message is placed in Bob's mailbox.

The mailbox resides in a shared mail server that is always running. A mail server is
typically maintained by ISP.

Bob (the recipient) executes his user agent on the his local PC to retrieve the message
from he mailbox.

A protocol is needed to allow the user agent and the mail server to communicate.

Bob reads the message from his mailbox on his own suitable time.
As obtaining the messages is a pull operation and SMPT is a push type protocol, it is not
suitable for this operation.

Hence, a special access Protocols are introduced that transfers the messages from Bob's
mail server to the local PC.

There are currently two popular mail access protocols:
1.POP3 (Post Office Protocol - Version 3) and
2.IMAP (Internet Mail Access Protocol).
BANASTHALI 34
E-mail protocols and their communicating entities

BANASTHALI 35
Mail Message Formats
A mail consists
1. a header part followed by A typical message header looks like this:
2. a body part. From: [email protected]
Exact format for mail header lines as well
To: [email protected]
their semantic interpretations is specified in Subject: Searching for the
RFC 822. meaning of life.
Every header must have a
From: header line and After the message header, a blank line follows
To: header line then the message body (in ASCII) follows.
Subject: header line (optional)

BANASTHALI 36
MIME Extension for Non-ASCII Data
MIME: Multipurpose Internet Mail Extensions
The message headers described in RFC 822 are satisfactory for sending ordinary ASCII text.
But not sufficiently rich enough for multimedia messages (e.g., messages with images, audio
and video) or for carrying non-ASCII text formats (e.g., characters used by languages other than
English).
To send content different from ASCII text, the sending user agent must include additional
headers in the message.
These extra headers are defined in [RFC 2045] and [RFC 2046], the MIME extension to [RFC
822].
Two key MIME headers for supporting multimedia are
1. Content-Type: header and
2.Content-Transfer-Encoding: header.

BANASTHALI 37
Content-Type: header
It allows the receiving user agent to take an
appropriate action on the message.

Ex: by indicating that the message body


contains a JPEG image, the receiving user
agent can direct the message body to a JPEG
decompression routine.

Content-Transfer-Encoding: header
It alerts the receiving user agent that the message body has been ASCII encoded and
need to be converted into its original non-ASCII form

BANASTHALI 38
It might look like this:
Suppose Alice wants to send Bob a JPEG image.
To do this: From: [email protected]
1. Alice invokes her user agent for email, To: [email protected]
2. Specifies Bob's email address, Subject: Picture
3. Specifies the subject of the message, and MIME-Version: 1.0
4. Inserts the JPEG image into the message body of the Content-Transfer-Encoding:base64
message. Content-Type: image/jpeg
5. After finish of message composition, Alice clicks on base64 encoded data .....
"Send". .........................
......base64 encoded data
6. Alice's user agent then generates a MIME message,

 When Bob reads his mail with his user agent, his user agent operates on this same MIME message.
 When Bob's user agent observes the Content-Transfer-Encoding: base64 header
line, it proceeds to decode the base64-encoded message body.
 The Content-Type: image/jpeg header indicates to Bob's user agent that the message
body (after base64 decoding) should be JPEG decompressed.

BANASTHALI 39

You might also like