Lecture 11 Application layer
-
Upload
hemang-kothari -
Category
Education
-
view
1.155 -
download
0
description
Transcript of Lecture 11 Application layer
![Page 1: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/1.jpg)
Application Layer
End of Saga
![Page 2: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/2.jpg)
Content
• Domain Name Service• Electronic Mail• World Wide Web
![Page 3: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/3.jpg)
DNS
• What is DNS?• What services does it provide?• How does it operate?• Message format• Types of messages
![Page 4: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/4.jpg)
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
![Page 5: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/5.jpg)
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.
![Page 6: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/6.jpg)
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.
![Page 7: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/7.jpg)
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.
![Page 8: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/8.jpg)
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.
![Page 9: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/9.jpg)
DNS
Why not centralize DNS?• single point of failure• traffic volume• distant centralized database• maintenance
doesn’t scale!
![Page 10: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/10.jpg)
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
![Page 11: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/11.jpg)
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)
![Page 12: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/12.jpg)
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
![Page 13: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/13.jpg)
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
![Page 14: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/14.jpg)
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.
![Page 15: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/15.jpg)
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.
![Page 16: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/16.jpg)
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
![Page 17: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/17.jpg)
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}.
![Page 18: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/18.jpg)
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
![Page 19: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/19.jpg)
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.
![Page 20: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/20.jpg)
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.
![Page 21: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/21.jpg)
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
![Page 22: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/22.jpg)
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
![Page 23: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/23.jpg)
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
![Page 24: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/24.jpg)
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
![Page 25: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/25.jpg)
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
![Page 26: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/26.jpg)
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
![Page 27: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/27.jpg)
Most Common Scenario
![Page 28: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/28.jpg)
Web based E-mail
![Page 29: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/29.jpg)
Post Office Protocol - 3
![Page 30: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/30.jpg)
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
![Page 31: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/31.jpg)
WWW & HTTP
![Page 32: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/32.jpg)
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
![Page 33: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/33.jpg)
WWW Architecture
![Page 34: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/34.jpg)
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
![Page 35: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/35.jpg)
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
![Page 36: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/36.jpg)
URLs – Uniform Resource Locaters
Some common URLs.
![Page 37: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/37.jpg)
HTTP Command
![Page 38: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/38.jpg)
Static Web Pages
![Page 39: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/39.jpg)
Dynamic Pages
![Page 40: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/40.jpg)
Dynamic Pages
![Page 41: Lecture 11 Application layer](https://reader034.fdocuments.us/reader034/viewer/2022052618/55495c0db4c90566498b5631/html5/thumbnails/41.jpg)