Professional Documents
Culture Documents
1
Advanced Computer Networks
Application Layer
Part_2
2
Web Proxy Caching
A Web cache—also called a proxy server—is a network entity
that satisfies HTTP requests on the behalf of an origin Web
server.
The Web cache has its own disk storage and keeps copies of
recently requested objects in this storage.
Objective: satisfy client request without involving origin server
resulting in reduced server & network load, low latency to
response
User sets browser: Web accesses via cache- Once a browser is
configured, each browser request for an object is first directed to the
Web cache
browser sends all HTTP requests to cache
object in cache => cache hit: returns object
else cache requests object from origin server, then returns object to
client
Cache acts as both client and server
3
Web Proxy Caching
4
Why Cache?
Reduce response time for client request.
Reduce traffic on an institution’s access link.
Low latency to response
5
Why WWW Caching?
6
Web Caching Hierarchy
national/international proxy cache
client
7
Conditional GET
The object housed in the Web server may have been
modified since the copy was cached at the client.
Fortunately, HTTP has a mechanism that allows a
cache to verify that its objects are up to date.
This mechanism is called the conditional GET.
An HTTP request message is a so-called conditional
GET message if
(1) the request message uses the GET method
and
(2) the request message includes an If-Modified-
Since: header line.
8
Conditional GET: client-side caching
If not modified
10
User-Server Interaction: Cookies
13
14
Example
As Susan continues to browse the Amazon
site, each time she requests a Web page, her
browser consults her cookie file, extracts her
identification number for this site, and puts a
cookie header line that includes the
identification number in the HTTP request.
Specifically, each of her HTTP requests to the
Amazon server includes the header line:
15
Cookies (continued)
Demerits
What cookies can bring: Cookies and privacy:
Authorization cookies permit sites to learn
Shopping carts (one-click a lot about you
shopping) Invasion of privacy
User session state You may supply name and e-
mail to sites
Web site can learn a lot
about a user and potentially
sell this information to a third
party.
Advertising companies
obtain info across sites
16
File Transfer Protocol (FTP)
FTP session, the user is sitting in front of one host (the
local host) and wants to transfer files to or from a remote
host.
FTP client process in the local host to establish a TCP
connection with the FTP server process in the remote host.
The most striking difference is that FTP uses two parallel
TCP connections to transfer a file, a control connection
and a data connection.
The control connection is used for sending control
information between the two hosts—information such as
user identification, password, commands to change remote
directory, and commands to “put” and “get” files. The data
connection is used to actually send a file.
17
FTP
18
File Transfer Protocol (FTP)
FTP client contacts FTP server at port 21, specifying TCP as transport
protocol
Client obtains authorization over control connection
Client browses remote directory by sending commands over control
connection.
When server receives a command for a file transfer, the server opens
a TCP data connection to client
After transferring one file, server closes connection.
1
File Transfer Protocol (FTP)
If, during the same session, the user wants to
transfer another file, FTP opens another data
connection.
Thus, with FTP, the control connection remains
open throughout the duration of the user session,
but a new data connection is created for each file
transferred within a session
Throughout a session, the FTP server must
maintain state about the user.
In particular, the server must associate the
control connection with a specific user account,
20
FTP commands
USER username: Used to send the user identification to the
server.
PASS password: Used to send the user password to the
server.
LIST: Used to ask the server to send back a list of all the
files in the current remote directory.
RETR filename: Used to retrieve (that is, get) a file from the
current directory of the remote host. This command causes
the remote host to initiate a data connection and to send the
requested file over the data connection.
STOR filename: Used to store (that is, put) a file into the
current directory of the remote host.
Each command is followed by a reply, sent from server to
client.
21
FTP responses
The replies are three-digit numbers, with an optional
message following the number.
This is similar in structure to the status code and
phrase in the status line of the HTTP response
message.
Sample return codes
331 Username OK, password required
125 data connection already open; transfer starting
425 Can’t open data connection
452 Error writing file
22
Electronic Mail
The application-layer protocols that are at the heart
of Internet e-mail.
Three major components:
User agents
• User agents allow users to read, reply to,
forward, save, and compose messages.
• e.g., Eudora, Outlook, Pine, Netscape
Messenger
Mail servers
• Incoming, outgoing messages
Simple Mail Transfer Protocol: SMTP
23
Electronic Mail
outgoing
When Alice is finished composing message queue
her message, her user agent sends user mailbox
user
the message to her mail server, agent
Then the message is placed in the mail user
server agent
mail server’s outgoing message
queue. SMTP mail
server user
When Bob wants to read a
SMTP agent
message, his user agent retrieves
the message from his mailbox in his SMTP user
mail
mail server. server agent
When Bob wants to access the user
messages in his mailbox, the mail agent
user
server containing his mailbox agent
authenticates Bob (with usernames
and passwords).
24
message queue and SMTP
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
SMTP is the principal 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.
25
SMTP
As with most application-layer protocols, SMTP
has two sides:
a client side, which executes on the sender’s
mail server, and
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.
26
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, bob@someschool.edu), 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
placed 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.
27
basic operation of SMTP
6. Bob invokes his user agent to read the message at his
convenience.
28
SMTP [RFC 2821]
Client’s SMTP mail server establishes a TCP connection
to the recipients SMTP server using Port 25
Three phases in messg. transfer
handshaking (greeting)
transfer of messages
closure
SMTP uses persistent connections
SMTP: push—the sending mail server
pushes the file to the receiving mail server.
HTTP: pull-- someone loads information on a Web
server and users use HTTP to pull the information from
the server at their convenience
29
Mail message format
30
Mail access protocols
SMTP SMTP access user
user
agent protocol agent
32
DNS: Domain Name System
Internet hosts:
IP address (32 bit) - used for addressing
datagrams
“name”, e.g., www.yahoo.com - used by humans
33
Distributed, Hierarchical Database
Root DNS Servers
TLD
com DNS servers ca DNS servers edu DNS servers
Servers
34
TLD and Authoritative Servers
Top-level domain (TLD) servers: responsible
for com, org, net, edu, etc, and all top-level
country domains uk, fr, ca, jp.
Authoritative DNS servers: organization’s
DNS servers, providing authoritative
hostname to IP mappings for organization’s
servers (e.g., Web and mail).
Can be maintained by organization or service
provider
35
Local Name Server
Each ISP (residential ISP, company,
university) has one.
Also called “default name server”
When a host makes a DNS query, query is
sent to its local DNS server
Acts as a proxy, forwards query into hierarchy.
Reduces lookup latency for commonly searched
hostnames
36
Recursive queries root DNS server
recursive query:
puts burden of name 2 3
resolution on 6
7
contacted name
TLD DNS server
server
heavy load?
local DNS server
iterated query: dns.poly.edu 5 4
contacted server
1 8
replies with name of
server to contact authoritative DNS server
“I don’t know this dns.cs.umass.edu
name, but ask this requesting host
cis.poly.edu
server”
gaia.cs.umass.edu
37
DNS: Root name servers
(recursive)
contacted by local name server that can not
resolve name
root name server:
contacts authoritative name server if name mapping
not known
gets mapping
returns mapping to local name server
38
DNS Infrastructure root DNS server
(iterative)
2
Host at cis.poly.edu 3
TLD DNS server
wants IP address for 4
gaia.cs.umass.edu
5
Infrastructure:
local DNS server
Client resolver dns.poly.edu
Local DNS server 7 6
1 8
Root DNS Server
Top-Level Domain
authoritative DNS server
DNS Server dns.cs.umass.edu
Authoritative DNS requesting host
Server cis.poly.edu
gaia.cs.umass.edu
39
DNS: caching and updating records
once (any) name server learns mapping, it caches
mapping
cache entries timeout (disappear) after some
time
40
DNS protocol, messages
DNS protocol : query and reply messages, both with
same message format
msg header
identification: 16 bit #
for query, reply to query
uses same #
41