Lecture 11 Application layer
-
Upload
hemang-kothari -
Category
Education
-
view
1.155 -
download
0
description
Transcript of Lecture 11 Application layer
Application Layer
End of Saga
Content
• Domain Name Service• Electronic Mail• World Wide Web
DNS
• What is DNS?• What services does it provide?• How does it operate?• Message format• Types of messages
What is DNS?
• DNS is a host name to IP address translation service
• DNS is– a distributed database implemented in a hierarchy
of name servers– an application level protocol for message
exchange between clients and servers
Why DNS?
• It is easier to remember a host name than it is to remember an IP address.
• An name has more meaning to a user than a 4 byte number.
• Applications such as FTP, HTTP, email, etc., all require the user to input a destination.
• The user generally enters a host name.• The application takes the host name supplied by the
user and forwards it to DNS for translation to an IP address.
DNS Services
• Besides the address translation service, DNS also provides the following services:– Host aliasing: a host with a complicated name can
have one or more aliases that are simpler to remember , e.g., relay1.west-coast.media.com -> media.com. The longer name is the canonical hostname, the shorter the alias hostname.
DNS Services (cont’d)
– Mail server aliasing: same as above, aliases can exist for long canonical host names.
– Load Balancing: a set of servers can have one name mapped onto several machines. DNS provides the full list of names to the end user’s application which generally takes the first one in the list. DNS rotates the names on the list.
How does it work?
• DNS works by exchanging messages between client and server machines.
• A client application will pass the destination host name to the DNS process (in Unix referred to as the gethostbyname() routine) to get the IP address.
• The application then sits and waits for the response to return.
DNS
Why not centralize DNS?• single point of failure• traffic volume• distant centralized database• maintenance
doesn’t scale!
Root DNS Servers
com DNS servers org DNS servers edu DNS servers
poly.eduDNS servers
umass.eduDNS servers
yahoo.comDNS servers
amazon.comDNS servers
pbs.orgDNS servers
Distributed, Hierarchical Database
Client wants IP for www.amazon.com; 1st approx:• client queries a 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
DNS: Root name servers• 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
13 root name servers worldwide
b USC-ISI Marina del Rey, CAl ICANN Los Angeles, CA
e NASA Mt View, CAf Internet Software C. Palo Alto, CA (and 36 other locations)
i Autonomica, Stockholm (plus 28 other locations)
k RIPE London (also 16 other locations)
m WIDE Tokyo (also Seoul, Paris, SF)
a Verisign, Dulles, VAc Cogent, Herndon, VA (also LA)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MDj Verisign, ( 21 locations)
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.– Network Solutions maintains servers for com TLD– Educause for edu TLD
• Authoritative DNS servers: – organization’s DNS servers, providing authoritative
hostname to IP mappings for organization’s servers (e.g., Web, mail).
– can be maintained by organization or service provider
Local Name Server
• does not strictly belong to hierarchy• each ISP (residential ISP, company, university)
has one.– also called “default name server”
• when host makes DNS query, query is sent to its local DNS server– acts as proxy, forwards query into hierarchy
DNS Queries
• Recursive:– The client machine sends a request to the local name
server, which, if it does not find the address in its database, sends a request to the root name server, which, in turn, will route the query to an intermediate or authoritative name server. Note that the root name server can contain some hostname to IP address mappings. The intermediate name server always knows who the authoritative name server is.
DNS Queries (cont’d)
• Iterative:– The local server queries the root server. If address
not in its database, will have the name/address of an intermediate or authoritative name server and forward that information to the local name server so that it can directly communicate with the intermediate or authoritative name server. This is to prevent the overloading of the root servers that handle millions of requests.
DNS: caching and updating records
• once (any) name server learns mapping, it caches mapping– cache entries timeout (disappear) after some time– TLD servers typically cached in local name servers
• Thus root name servers not often visited
• update/notify mechanisms under design by IETF– RFC 2136– http://www.ietf.org/html.charters/dnsind-charter.html
Operation of DNS
• DNS uses caching to increase the speed with which it does the translation.
• The DNS data is stored in the database in the form of resource records (RR). The RRs are directly inserted in the DNS messages.
• The RRs are a 4 tuple that consist of: {name, value, type, TTL}.
Resource RecordsDNS: distributed db storing resource records (RR)
o Type=NSo name is domain (eg., foo.com)
o value is hostname of authoritative name server for this domain
RR format: (name, value, type, ttl)
o Type=Ao name is hostnameo value is IP address
o Type=CNAMEo name is alias name for some
“canonical” (the real) name, eg., www.ibm.com is really servereast.backup2.ibm.com
o value is canonical name
o Type=MXo value is name of mailserver
associated with name
Summary
• DNS provides a mechanism for maintaining the user friendliness of the Internet by hiding some of the operational details.
• DNS servers have to be created manually. Recently an update protocol was introduced that allows DNS to exchange data for additions and deletions.
E - Mail
• Electronic mail is among the most widely available application services. Each user, who intends to participate in email communication, is assigned a mailbox, where out-going and incoming messages are buffered, allowing the transfer to take place in the background.
Electronic Mail
Three major components:
user agents mail reader composing, editing,
reading mail messages mail servers
mailbox contains incoming messages for user
message queue of outgoing (to be sent) mail messages
simple mail transfer protocol: SMTP to send email messages
between mail servers
user mailbox
outgoing message queue
mailserver
useragent
useragent
useragent
mailserver
useragent
useragent
mailserver
useragent
SMTP
SMTP
SMTP
Electronic Mail: SMTP [RFC 2821]
uses TCP to reliably transfer email message from client to server, port 25
direct transfer: sending server to receiving server three phases of transfer
handshaking (greeting) transfer of messages closure
command/response interaction commands: ASCII text response: status code and phrase
messages must be in 7-bit ASCII
Scenario: Alice sends message to Bob1) Alice uses UA to compose message and “to”
[email protected]) Alice’s UA sends message to her mail server; message
placed in message queue3) Client side of SMTP opens TCP connection with Bob’s
mail server4) SMTP client sends Alice’s message over the TCP
connection5) Bob’s mail server places the message in Bob’s mailbox6) Bob invokes his user agent to read message
useragent
mailserver
mailserver user
agent
1
2 3 4 56
Mail message format
SMTP: protocol for exchanging email msgsRFC 822: standard for text message format:
header lines, e.g., To: From: Subject:different from SMTP commands!
body the “message”, ASCII characters only
header
body
blankline
Message format: multimedia extensions
MIME: multimedia mail extension, RFC 2045, 2056 additional lines in msg header declare MIME content
type
From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg
base64 encoded data ..... ......................... ......base64 encoded data
multimedia datatype, subtype,
parameter declaration
method usedto encode data
MIME version
encoded data
Mail access protocols
SMTP: delivery/storage to receiver’s server Mail access protocol: retrieval from server
POP: Post Office Protocol [RFC 1939]• authorization (agent <-->server) and download
IMAP: Internet Mail Access Protocol [RFC 1730]• more features (more complex)• manipulation of stored msgs on server
HTTP: gmail, Hotmail, Yahoo! Mail, etc.
useragent
sender’s mail server
useragent
SMTP SMTP accessprotocol
receiver’s mail server
Most Common Scenario
Web based E-mail
Post Office Protocol - 3
POP3 and IMAP
More about POP3• Previous example uses “download and delete” mode.• Bob cannot re-read e-mail if he changes client• “Download-and-keep”: copies of messages on different clients• POP3 is stateless across sessionsIMAP• Keep all messages in one place: the server• Allows user to organize messages in folders• IMAP keeps user state across sessions:
– names of folders and mappings between message IDs and folder name
WWW & HTTP
Web and HTTPFirst some jargon• Web page consists of objects• Object can be HTML file, JPEG image, Java applet, audio
file,…• Web page consists of base HTML-file which includes
several referenced objects• Each object is addressable by a URL• Example URL:
www.someschool.edu/someDept/pic.gif
host name path name
WWW Architecture
HTTP overview
HTTP: hypertext transfer protocol• Web’s application layer protocol• client/server model
– client: browser that requests, receives, “displays” Web objects
– server: Web server sends objects in response to requests
PC runningExplorer
Server running
Apache Webserver
Mac runningNavigator
HTTP request
HTTP request
HTTP response
HTTP response
HTTP overview (continued)
Uses TCP:• client initiates TCP connection
(creates socket) to server, port 80
• server accepts TCP connection from client
• HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)
• TCP connection closed
HTTP is “stateless”• server maintains no
information about past client requests
Protocols that maintain “state” are complex!
past history (state) must be maintained
if server/client crashes, their views of “state” may be inconsistent, must be reconciled
aside
URLs – Uniform Resource Locaters
Some common URLs.
HTTP Command
Static Web Pages
Dynamic Pages
Dynamic Pages