You are on page 1of 41

Advanced Computer Networks

 Book: Computer Networking, A top down


approach featuring the Internet by James F
Kurose & Keith W Ross

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?

Assume: cache is “close” to


client (e.g., in same
network)
 Smaller response time:
cache “closer” to client
 Decrease traffic to distant
servers
 Link out of institutional/local
ISP network often bottleneck

6
Web Caching Hierarchy
national/international proxy cache

regional proxy cache

local proxy cache


(e.g., local ISP,
University)

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

 Goal: don’t send object if client client server


has up-to-date cached version HTTP request msg
 client: specify date of cached If-modified-since:
<date>
object
copy in HTTP request not
If-modified-since: <date> modified
HTTP response
 server: response contains no HTTP/1.0
object if cached copy is up-to- 304 Not Modified
date:
HTTP/1.0 304 Not Modified HTTP request msg
If-modified-since:
<date> object
modified
HTTP response
HTTP/1.0 200 OK
<data>
9
Example
 If modified, the sever response is;

 If not modified

10
User-Server Interaction: Cookies

 It is often desirable for a Web site to identify


users, either because the server wishes to
restrict user access or because it wants to
serve content as a function of the user
identity.
 For these purposes, HTTP uses cookies.
Cookies, defined in [RFC 6265], allow sites to
keep track of users.
 Most major commercial Web sites use
cookies today.
11
Cookies: keeping “state”
o Cookie technology has four components
o Four components:
1) Cookie header line in the HTTP response message
2) Cookie header line in HTTP request message
3) Cookie file kept on user’s host and managed by user’s
browser
4) back-end database at Web site
Example:
 Suppose Susan, who always accesses the Web using Internet Explorer
from her home PC, contacts Amazon.com for the first time.
 Let us suppose that in the past she has already visited the eBay site.
 When initial HTTP requests arrives at site, site creates a unique ID and
creates an entry in backend database for ID
12
Example continued
 When Susan’s browser receives the HTTP
response message, it sees the Set cookie:
header.
 The browser then appends a line to the special
cookie file that it manages.
 This line includes the hostname of the server
and the identification number in the Set-
cookie: header

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

SMTP: Protocol for exchanging


email msgs header
blank
RFC 5322: standard for text
line
message format:
 Header lines, e.g.,
To:
body

 From:
 Subject:
 Body
 the “message”, ASCII
characters only
 Example

30
Mail access protocols
SMTP SMTP access user
user
agent protocol agent

sender’s mail receiver’s mail


server server
 SMTP is a push protocol. How will a user access emails?
 Mail access protocol: There are currently a number of popular mail
access protocols that do retrieval from server;
 POP: Post Office Protocol [RFC 1939]
• Users can’t create folders on mail server
 IMAP: Internet Mail Access Protocol [RFC 1730]
• more features (more complex)
• manipulation of stored msgs on server
 HTTP: Hotmail , Yahoo! Mail, etc.
31
POP3
 POP3 is an extremely simple mail access protocol
 POP3, is used to transfer mail from the recipient’s mail
server to the recipient’s user agent.
 POP3 begins when the user agent (the client) opens a TCP
connection to the mail server (the server) on port 110
 POP3 Three phases:
 Authorization: the user agent sends a username and a
password
 Transaction: the user agent retrieves messages;
 Update: quit command, ending the POP3 session;

32
DNS: Domain Name System

Internet hosts:
 IP address (32 bit) - used for addressing
datagrams
 “name”, e.g., www.yahoo.com - used by humans

DNS: provides translation between host name


and IP address
 distributed database implemented in hierarchy
of many name servers
 Distributed for scalability & reliability

33
Distributed, Hierarchical Database
Root DNS Servers

TLD
com DNS servers ca DNS servers edu DNS servers
Servers

yahoo.com amazon.com ucalgary.ca usask.ca poly.edu umass.edu


DNS servers DNS servers DNS servers DNS servers DNS servers DNS servers

 Root servers and TLD servers typically do not


contain hostname to IP mappings; they contain
mappings for locating authoritative 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

You might also like