Web caches
Goal: satisfy client requests without involving origin server
user configures browser to
point to a (local) Web cache Web
cache
browser sends all HTTP client
origin
requests to cache server
• if object in cache: cache
returns object to client
• else cache requests object
client
from origin server, caches
received object, then
returns object to client
Application Layer: 2-41
Web caches (aka proxy servers)
Web cache acts as both Why Web caching?
client and server
reduce response time for client
• server for original
requesting client request
• client to origin server • cache is closer to client
reduce traffic on an institution’s
server tells cache about
object’s allowable caching in access link
response header: Internet is dense with caches
• enables “poor” content providers
to more effectively deliver content
Application Layer: 2-42
Browser caching: Conditional GET
client server
Goal: don’t send object if browser
HTTP request msg
has up-to-date cached version If-modified-since: <date> object
not
• no object transmission delay (or use
modified
of network resources) HTTP response
before
HTTP/1.0
Client: specify date of browser- 304 Not Modified <date>
cached copy in HTTP request
If-modified-since: <date>
server: response contains no HTTP request msg
If-modified-since: <date> object
object if browser-cached copy is modified
up-to-date: HTTP response after
HTTP/1.0 200 OK <date>
HTTP/1.0 304 Not Modified <data>
Application Layer: 2-43
Application layer: overview
P2P applications
Principles of network video streaming and content
applications distribution networks
Web and HTTP socket programming with
E-mail, SMTP, IMAP UDP and TCP
The Domain Name System
DNS
Application Layer: 2-44
E-mail user
agent
Three major components: mail user
server
user agents agent
mail servers SMTP mail user
server agent
simple mail transfer protocol: SMTP SMTP
User Agent SMTP user
agent
mail
server
a.k.a. “mail reader” user
composing, editing, reading mail messages agent
user
e.g., Outlook, iPhone mail client agent
outgoing
outgoing, incoming messages stored on message queue
server user mailbox
Application Layer: 2-45
E-mail: mail servers user
agent
mail servers: mail user
server agent
mailbox contains incoming
messages for user SMTP mail user
server agent
message queue of outgoing (to be SMTP
sent) mail messages
SMTP user
SMTP protocol between mail mail
server
agent
servers to send email messages user
agent
client: sending mail server user
“server”: receiving mail server agent
outgoing
message queue
user mailbox
Application Layer: 2-46
SMTP RFC (5321) “client”
SMTP server
“server”
SMTP server
uses TCP to reliably transfer email message
initiate TCP
from client (mail server initiating connection
connection) to server, port 25 RTT
TCP connection
direct transfer: sending server (acting like client) initiated
to receiving server
three phases of transfer 220
• SMTP handshaking (greeting) SMTP HELO
handshaking
• SMTP transfer of messages 250 Hello
• SMTP closure
command/response interaction (like HTTP) SMTP
• commands: ASCII text transfers
• response: status code and phrase time
Application Layer: 2-47
Scenario: Alice sends e-mail to Bob
1) Alice uses UA to compose e-mail 4) SMTP client sends Alice’s message
message “to”
[email protected] over the TCP connection
2) Alice’s UA sends message to her 5) Bob’s mail server places
mail server using SMTP; message the message in Bob’s
placed in message queue mailbox
3) client side of SMTP at mail server 6) Bob invokes his user
opens TCP connection with Bob’s mail agent to read message
server
1 user mail user
mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Application Layer: 2-48
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <
[email protected]>
S: 250
[email protected]... Sender ok
C: RCPT TO: <
[email protected]>
S: 250
[email protected] ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
Application Layer: 2-49
SMTP: observations
comparison with HTTP: SMTP uses persistent
connections
HTTP: client pull
SMTP requires message
SMTP: client push (header & body) to be in
both have ASCII command/response 7-bit ASCII
interaction, status codes SMTP server uses
CRLF.CRLF to determine
HTTP: each object encapsulated in its end of message
own response message
SMTP: multiple objects sent in
multipart message
Application Layer: 2-50
Mail message format
SMTP: protocol for exchanging e-mail messages, defined in RFC 5321
(like RFC 7231 defines HTTP)
RFC 2822 defines syntax for e-mail message itself (like HTML defines
syntax for web documents)
header lines, e.g., header
blank
• To: line
• From:
• Subject:
these lines, within the body of the email body
message area different from SMTP MAIL FROM:,
RCPT TO: commands!
Body: the “message” , ASCII characters only
Application Layer: 2-51
Retrieving email: mail access protocols
user
e-mail access user
SMTP SMTP protocol
agent agent
(e.g., IMAP,
HTTP)
sender’s e-mail receiver’s e-mail
server server
SMTP: delivery/storage of e-mail messages to receiver’s server
mail access protocol: retrieval from server
• IMAP: Internet Mail Access Protocol [RFC 3501]: messages stored on server, IMAP
provides retrieval, deletion, folders of stored messages on server
HTTP: gmail, Hotmail, Yahoo!Mail, etc. provides web-based interface on
top of STMP (to send), IMAP (or POP) to retrieve e-mail messages
Application Layer: 2-52
Application Layer: Overview
P2P applications
Principles of network video streaming and content
applications distribution networks
Web and HTTP socket programming with
E-mail, SMTP, IMAP UDP and TCP
The Domain Name System
DNS
Application Layer: 2-53
DNS: Domain Name System
people: many identifiers: Domain Name System (DNS):
• SSN, name, passport # distributed database implemented in
Internet hosts, routers: hierarchy of many name servers
• IP address (32 bit) - used for application-layer protocol: hosts, DNS
addressing datagrams servers communicate to resolve
• “name”, e.g., cs.umass.edu - names (address/name translation)
used by humans
• note: core Internet function,
Q: how to map between IP implemented as application-layer
address and name, and vice protocol
versa ?
• complexity at network’s “edge”
Application Layer: 2-54
DNS: services, structure
DNS services: Q: Why not centralize DNS?
hostname-to-IP-address translation single point of failure
traffic volume
host aliasing
distant centralized database
• canonical, alias names
maintenance
mail server aliasing
load distribution A: doesn‘t scale!
• replicated Web servers: many IP Comcast DNS servers alone:
addresses correspond to one 600B DNS queries/day
name Akamai DNS servers alone:
2.2T DNS queries/day
Application Layer: 2-55
Thinking about the DNS
humongous distributed database:
~ billion records, each simple
handles many trillions of queries/day:
many more reads than writes
performance matters: almost every
Internet transaction interacts with
DNS - msecs count!
organizationally, physically decentralized:
millions of different organizations
responsible for their records
“bulletproof”: reliability, security
Application Layer: 2-56
DNS: a distributed, hierarchical database
Root DNS Servers Root
… …
.com DNS servers .org DNS servers .edu DNS servers Top Level Domain
… … … …
yahoo.com amazon.com pbs.org nyu.edu umass.edu
DNS servers DNS servers DNS servers DNS servers DNS servers Authoritative
Client wants IP address for www.amazon.com; 1st approximation:
client queries root server to find .com DNS server
client queries .com DNS server to get amazon.com DNS server
client queries amazon.com DNS server to get IP address for www.amazon.com
Application Layer: 2-57
DNS: root name servers
official, contact-of-last-resort by
name servers that can not
resolve name
Application Layer: 2-58
DNS: root name servers
official, contact-of-last-resort by
name servers that can not 13 logical root name “servers”
worldwide each “server” replicated
resolve name many times (~200 servers in US)
incredibly important Internet
function
• Internet couldn’t function without it!
• DNSSEC – provides security
(authentication, message integrity)
ICANN (Internet Corporation for
Assigned Names and Numbers)
manages root DNS domain
Application Layer: 2-59
Top-Level Domain, and authoritative servers
Top-Level Domain (TLD) servers:
responsible for .com, .org, .net, .edu, .aero, .jobs, .museums, and all top-level
country domains, e.g.: .cn, .uk, .fr, .ca, .jp
Network Solutions: authoritative registry for .com, .net TLD
Educause: .edu TLD
authoritative DNS servers:
organization’s own DNS server(s), providing authoritative hostname to IP
mappings for organization’s named hosts
can be maintained by organization or service provider
Application Layer: 2-60
Local DNS name servers
when host makes DNS query, it is sent to its local DNS server
• Local DNS server returns reply, answering:
• from its local cache of recent name-to-address translation pairs (possibly out
of date!)
• forwarding request into DNS hierarchy for resolution
• each ISP has local DNS name server; to find yours:
• MacOS: % scutil --dns
• Windows: >ipconfig /all
local DNS server doesn’t strictly belong to hierarchy
Application Layer: 2-61
DNS name resolution: iterated query
root DNS server
Example: host at engineering.nyu.edu
wants IP address for gaia.cs.umass.edu 2
3
TLD DNS server
Iterated query: 1 4
contacted server replies 8 5
with name of server to requesting host at local DNS server
contact engineering.nyu.edu dns.nyu.edu
gaia.cs.umass.edu
“I don’t know this name, 7 6
but ask this server”
authoritative DNS server
dns.cs.umass.edu
Application Layer: 2-62
DNS name resolution: recursive query
root DNS server
Example: host at engineering.nyu.edu
wants IP address for gaia.cs.umass.edu 2 3
7 6
Recursive query: 1 TLD DNS server
puts burden of name 8
resolution on requesting host at local DNS server
5 4
engineering.nyu.edu dns.nyu.edu
contacted name gaia.cs.umass.edu
server
heavy load at upper authoritative DNS server
levels of hierarchy? dns.cs.umass.edu
Application Layer: 2-63
Caching DNS Information
once (any) name server learns mapping, it caches mapping,
and immediately returns a cached mapping in response to a
query
• caching improves response time
• cache entries timeout (disappear) after some time (TTL)
• TLD servers typically cached in local name servers
cached entries may be out-of-date
• if named host changes IP address, may not be known Internet-
wide until all TTLs expire!
• best-effort name-to-address translation!
Application Layer: 2-64
DNS records
DNS: distributed database storing resource records (RR)
RR format: (name, value, type, ttl)
type=A type=CNAME
name is hostname name is alias name for some “canonical”
value is IP address (the real) name
www.ibm.com is really servereast.backup2.ibm.com
type=NS value is canonical name
name is domain (e.g., foo.com)
value is hostname of
type=MX
authoritative name server for value is name of SMTP mail
this domain server associated with name
Application Layer: 2-65
Getting your info into the DNS
example: new startup “Network Utopia”
register name networkuptopia.com at DNS registrar (e.g., Network
Solutions)
• provide names, IP addresses of authoritative name server (primary and
secondary)
• registrar inserts NS, A RRs into .com TLD server:
(networkutopia.com, dns1.networkutopia.com, NS)
(dns1.networkutopia.com, 212.212.212.1, A)
create authoritative server locally with IP address 212.212.212.1
• type A record for www.networkuptopia.com
• type MX record for networkutopia.com
Application Layer: 2-66
DNS security
DDoS attacks Spoofing attacks
bombard root servers with intercept DNS queries,
traffic returning bogus replies
• not successful to date DNS cache poisoning
• traffic filtering RFC 4033: DNSSEC
authentication services
• local DNS servers cache IPs of TLD
servers, allowing root server
bypass
bombard TLD servers
• potentially more dangerous
Application Layer: 2-67