Computer Networks Application Layer Application Layer

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Computer Networks

Part 5
Application Layer
Dr. Nesreen I Ziedan

Outline
Introduction
Addressing and requirements
Application protocols

HTTP
FTP
Mail
DNS

Computer Networks - Fall 2008

Introduction
A process is a program running in an end system
Processes running on the same end system
communicate with each other using interprocess
communication
Processes on different end systems communicate
with each other by exchanging messages
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

Computer Networks - Fall 2008

Processes Communicating Across a Network


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

Computer Networks - Fall 2008

Addressing Processes
In order for a process on one host to send a
message to a process on another host, the sending
process must identify the receiving process by
specifying
The name or address (IP in the Internet) of the host
The port number that specifies the identity of the
receiving process on the destination host

Popular application-layer protocols have been


assigned specific port numbers
When a developer creates a new network
application, the application must be assigned a new
port number
Computer Networks - Fall 2008

User Agent
The user agent is an interface between the user and
the network application
Example: a browser is a user agent that allows a
user to navigate the web, and also implements the
client side of the HTTP protocol
Thus, when activated, the browser is a process that, along
with providing an interface to the user, sends messages
into a socket

Computer Networks - Fall 2008

Application Layer Requirements


1. Data Loss:

Some applications, such as file transfer, require fully


reliable data transfer, i.e., no data loss
Other loss tolerant applications, such multimedia
applications, can tolerate some amount of data loss

2. Bandwidth:

bandwidth-sensitive applications (such as multimedia


applications) must be able to transmit at a certain rate
in order to be effective
Adaptive coding technique can be used to encode at a
rate that matches the currently available bandwidth
Elastic applications can make use of as much or as little
bandwidth as happens to be available (e.g. file transfer)

Computer Networks - Fall 2008

Application Layer Requirements


3. Timing:

Interactive real-time applications (e.g. Internet telephony


and multiplayer games) require tight timing constraints
on data delivery (end-to-end delay) in order to be
effective
For non-real-time applications, lower delay is always
preferable to high delay, but no tight constraint is placed
on the end-to-end delays

Computer Networks - Fall 2008

Hypertext Transfer Protocol (HTTP)


HTTP has a client side and a server side
A web browser is a user agent that implements the client
side of HTTP; it employs TCP as the underlying transport
A web server houses web objects, each addressable by a
URL, and implements the server side of HTTP
The default port is 80; servers listens on that port

A Web page consists of objects


Mostly an HTML file, as a base, with referenced objects

When a user requests a web page, the browser


sends request messages for the objects in the page
to the server that, in turn, responds with HTTP
response messages that contain the objects
The server does not maintain any state information about
clients  HTTP is a stateless protocol

Computer Networks - Fall 2008

HTTP Connections Types

Non-persistent connection: each TCP connection


transports exactly one request message from the
client and one response message from the server
If a requested web page contains referenced objects, each
object is transferred with a different TCP connection
TCP connection is established and closed for each object 
a connection does not persist for more than 1 object
For each connection, TCP buffers must be allocated and
TCP variables must be kept in both the client and server

Persistent connection: the server leaves the TCP


connection open after sending responses
Subsequent requests and responses between the same
client and server can be sent over the same connection
The server closes a connection when it is not used for a
predefined timeout interval

Computer Networks - Fall 2008

10

HTTP Non-Persistent Connections

An HTML file, with referenced objects, transfer steps


1. The client initiates a TCP connection to the server
2. The client sends a request message into the socket
associated with the established TCP connection
3. The server receives the request message via the socket
associated with the connection, retrieves the object from
its storage, encapsulates it in a response message, and
sends the response message into the TCP connection
4. The server tells TCP to close the connection
5. The client receives the response message, and TCP
closes the connection. The message indicates that the
encapsulated object is an HTML file. The client extracts
the file from the response message, analyze the HTML
file and finds references to some objects
6. The first 4 steps are repeated for each referenced object
Computer Networks - Fall 2008

11

HTTP Persistent Connections


Persistent connection without pipelining
The client issues a new request only when the previous
response has been received
After the server sends an object, the connection hangs
while it waits for another request to arrive  this hanging
wastes server resources

Persistent connection with pipelining


The client issues a request as soon as it encounters a
reference  the client can make back-to-back requests for
the referenced objects
When the server receives the requests, it can send the
objects back-to-back
The pipelined TCP connection hangs for a smaller fraction
of time
Computer Networks - Fall 2008

12

User-Server Interaction: Authentication & Cookies


A Web site may need to identify users as the server
may wish to restrict user access or serve content as
a function of the user identity
Authentication is identifying eligible users typically
by usernames and passwords
Cookies is a mechanism for sites to keep track of
users; they are used for many different purposes:
If a server requires authentication but doesn't want to
hassle a user with a username and password prompt
every time the user visits the site
If a server wants to remember a user's preferences so it
can provide targeted advertising during subsequent visits
If a user is shopping at a site, the server can use cookies
to keep track of the items that the user is purchasing
Computer Networks - Fall 2008

13

Web Caches (Proxy Servers)

A Web cache, or a proxy server, is a network entity


that keeps copies of recently requested objects
The browser establishes a connection to the proxy server
and sends an HTTP request to the Web cache
If the proxy has a copy of the object stored locally, it forwards
the object within an HTTP response message to the client
If the proxy does not have the object, it opens a TCP
connection to the origin server, and sends an HTTP request
for the object into the TCP connection
The origin server sends the object within an HTTP response
to the proxy
When the proxy 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 proxy)
Computer Networks - Fall 2008

14

Web Caches (Proxy Servers)

Benefits
Web caches can substantially reduce the response time
for client requests
Web caches can substantially reduce traffic on an
institution's access link to the Internet, and can also
substantially reduce web traffic in the Internet as a whole,
thereby improving performance for all applications
An Internet dense with web caches provides an
infrastructure for rapid distribution of content
Computer Networks - Fall 2008

15

File Transfer Protocol: FTP

FTP runs over TCP


The user interacts with FTP through an FTP user agent
The user first provides the remote hostname to the FTP client,
which establishes a TCP connection with the FTP server
The user then provides an identification & a password which
get sent over the TCP connection as part of FTP commands
Once the server has authorized the user, the user can transfer
files between the local and remote file systems
Computer Networks - Fall 2008

16

FTP

FTP uses two parallel TCP connections to transfer a file


A control connection is used for sending control
information between the two hosts
A data connection is used to actually send a file
Because FTP uses a separate control connection, FTP is
said to send its control information out-of-band

FTP sets up a control connection on server port 21


It remains open throughout the FTP session  persistent

FTP opens a data connection on server port 20


FTP sends exactly one file over the data connection and
then closes the data connection  non-persistent

Throughout a session, the FTP server must maintain


state info about the user  this significantly impedes
the total number of sessions that FTP can maintain
Computer Networks - Fall 2008

17

Electronic Mail in the Internet

The Internet mail system consists of


three components
Mail user agents, mail servers, & the
Simple Mail Transfer Protocol (SMTP)

Sending/receiving mails
A sender composes a
message, its mail user agents
sends the message to its mail
server, where the message is
placed in the outgoing
message queue
The message is sent by SMTP
over a TCP connection
The recipient mail user agent
obtains the message from its
mailbox on the mail server

Computer Networks - Fall 2008

18

SMTP

SMTP requires the body of all mail messages to be


in simple seven-bit ASCII
Binary multimedia data must be encoded to ASCII before
being sent over SMTP; it is decoded back to binary after
SMTP transport

Mail servers implement both the client and server


sides of the SMTP
SMTP does not use intermediate mail servers for
sending mail  SMTP TCP establishes a direct
connection between senders and receivers servers
SMTP is a push protocol: the sending mail server
pushes the file to the receiving mail server
HTTP is a pull protocol: information are loaded on a Web
server & HTTP is used to pull off this information

Computer Networks - Fall 2008

19

SMTP Message Transfer

The client SMTP attempts to establish a TCP


connection on port 25 to the server SMTP
If the server is down, the client tries again later

Once this connection is established, the server and


client perform SMTP handshaking
The SMTP client indicates the email address of the sender
and the email address of the recipient

The client then sends the message


The client repeats this process over the same TCP
connection if it has other messages to send to the
server; otherwise, it instructs TCP to close the
connection
SMTP TCP is a persistent connection
Computer Networks - Fall 2008

20

Mail Access Protocols

Mail servers must always be running and a


connected to the Internet
They are shared by many users and maintained by ISPs
Each user runs a mail user agent

Sending a mail between user agents


The senders user agent initiates an SMTP session with its
mail server and uploads the message
The senders mail server establishes a new SMTP session
with the receivers mail server and relays the message to it
If the receivers mail server is down, the senders mail
server holds the message and tries again later
An access pull protocol is used to transfer messages from
the receivers mail server to the recipients user agent
There are two popular mail access protocols: POP3 (Post
Office Protocol - Ver3) & IMAP (Internet Mail Access Protocol)
Computer Networks - Fall 2008

21

Browser-Based Email Services


Mail services such as Yahoo and Gmail
The user agent is an ordinary Web browser and the user
communicates with its mailbox on its mail server via HTTP
When a sender wants to send a message, the message is
sent from the senders browser to its mail server over
HTTP (not SMTP)
When a recipient wants to access the messages in its
mailbox, the messages are sent from recipients mail
server to its browser using HTTP (not POP3 or IMAP)
The mail server sends messages to, and receives
messages from, other mail servers using SMTP
Disadvantage: It can be slow, as the server is typically far
from the client and interaction with the server is done
through CGI scripts
Computer Networks - Fall 2008

22

The Internet's Directory Service - DNS


Each host is identified by a hostname & an IP address
A directory service translates hostnames to IP addresses

The Internets Domain Name System (DNS) is


A distributed database implemented in a hierarchy of
name servers, and
An application-layer protocol that allows hosts and name
servers to communicate to provide the translation service

The DNS protocol runs over UDP and uses port 53


DNS is employed by other application-layer
protocols (e.g. HTTP, SMTP and FTP) to translate
user supplied host names to IP addresses
DNS client side runs on the same machines that run
other application-layer protocols
Computer Networks - Fall 2008

23

DNS

A user request a URL www.aaa.com/index.html


The browser extracts the hostname from the URL and
passes the hostname to the DNS client
The DNS client sends a query containing the hostname to
a DNS server
The DNS client eventually receives a reply, which includes
the IP address for the hostname
The browser opens a TCP connection to the HTTP server
process located at that IP address
All IP datagrams sent from the client to server as part
of this connection will include this IP address

IP addresses are often cached in a "near by" DNS


name server
This reduces the DNS network traffic and average delay
Computer Networks - Fall 2008

24

DNS Other Services

Host aliasing: some hosts, mostly with complicated


hostnames, can have one or more alias names
DNS can be invoked by an application to obtain the
canonical hostname for a supplied alias hostname as well
as the IP address of the host

Mail server aliasing


Load Distribution among replicate servers
Busy sites are replicated over multiple servers, with each
server running on a different end system, and having a
different IP address
When clients make a DNS query for a name mapped to a
set of addresses, the server responds with the entire set of
IP addresses, but rotates the ordering of the addresses
within each reply  a client typically sends its HTTP
request message to the first listed IP address
Computer Networks - Fall 2008

25

You might also like