+ All Categories
Home > Documents > Chapter 7: Application layer

Chapter 7: Application layer

Date post: 25-Feb-2016
Category:
Upload: nishan
View: 53 times
Download: 2 times
Share this document with a friend
Description:
Chapter 7: Application layer. Application Layer Domain name system (DNS) Electronic Mail World Wide Web (WWW) Readings Sections 7.1-7.3. Application: communicating, distributed processes running in network hosts in “user space” exchange messages to implement app - PowerPoint PPT Presentation
40
1 Chapter 7: Application layer Application Layer Domain name system (DNS) Electronic Mail World Wide Web (WWW) • Readings Sections 7.1-7.3
Transcript
Page 1: Chapter 7: Application layer

1

Chapter 7: Application layer

• Application Layer– Domain name system (DNS)– Electronic Mail– World Wide Web (WWW)

• Readings– Sections 7.1-7.3

Page 2: Chapter 7: Application layer

2

Applications and application-layer protocols

Application: communicating, distributed processes– running in network hosts in

“user space”– exchange messages to

implement app– e.g., email, file transfer, the

WebApplication-layer protocols

– one “piece” of an app– define messages exchanged by

apps and actions taken– user services provided by lower

layer protocols

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

Page 3: Chapter 7: Application layer

3

Client-server paradigm

Typical network app has two pieces: client and server

applicationtransportnetworkdata linkphysical

applicationtransportnetworkdata linkphysical

Client:initiates contact with server (“speaks first”)typically requests service from server, for Web, client is implemented in browser; for e-mail, in mail readerServer:provides requested service to cliente.g., Web server sends requested Web page, mail server delivers e-mail

request

reply

Page 4: Chapter 7: Application layer

4

What transport service does an app need?

Data loss• some apps (e.g., audio) can

tolerate some loss• other apps (e.g., file transfer,

telnet) require 100% reliable data transfer Delay

• some apps (e.g., Internet telephony, interactive games) require low delay to be “effective”

Bandwidthsome apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”other apps (“elastic apps”) make use of whatever bandwidth they get

Page 5: Chapter 7: Application layer

5

Transport service requirements of common apps

Application

file transfere-mail

Web documentsreal-time audio/video

stored audio/videointeractive games

financial apps

Data loss

no lossno lossloss-tolerantloss-tolerant

loss-tolerantloss-tolerantno loss

Bandwidth

elasticelasticelasticaudio: 5Kb-1Mbvideo:10Kb-5Mbsame as above few Kbps upelastic

Time Sensitive

nononoyes, 100’s msec

yes, few secsyes, 100’s msecyes and no

Page 6: Chapter 7: Application layer

6

Internet apps: their protocols and transport protocols

Application

e-mailremote terminal access

Web file transfer

streaming multimedia

remote file serverInternet telephony

Applicationlayer protocol

smtp [RFC 821]telnet [RFC 854]http [RFC 2068]ftp [RFC 959]proprietary(e.g. RealNetworks)NFSproprietary(e.g., Vocaltec)

Underlyingtransport protocol

TCPTCPTCPTCPTCP or UDP

TCP or UDPtypically UDP

Page 7: Chapter 7: Application layer

7

DNS: Domain Name System

DNS services• Hostname to IP address translation• Host aliasing

– Canonical and alias names• Mail server aliasing• Load distribution

– Replicated Web servers: set of IP addresses for one canonical name

Page 8: Chapter 7: Application layer

8

Root DNS Servers`

com DNS servers org DNS servers edu DNS servers

fsu.eduDNS servers

umass.eduDNS serversyahoo.com

DNS serversamazon.comDNS servers

pbs.orgDNS servers

Distributed, Hierarchical Database

Page 9: Chapter 7: Application layer

9

DNS: Root name servers• contacted by local name server that cannot 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 17 other locations)

i Autonomica, Stockholm (plus 3 other locations)

k RIPE London (also Amsterdam, Frankfurt)

m WIDE Tokyo

a Verisign, Dulles, VAc Cogent, Herndon, VA (also Los Angeles)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MDj Verisign, ( 11 locations)

Page 10: Chapter 7: Application layer

10

TLD and Authoritative Servers

• Top-level domain (TLD) servers: responsible for com, org, net, edu, etc, and all top-level country domains cn, ca, fr, jp, uk etc.– 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 and mail).– Can be maintained by organization or service provider

Page 11: Chapter 7: Application layer

11

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.

Page 12: Chapter 7: Application layer

12

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

23

4

5

6

authoritative DNS serverdns.cs.umass.edu

78

TLD DNS server

Iterative Queries

iterated query:• contacted server replies with

name of server to contact• “I don’t know this name, but

ask this server”

Page 13: Chapter 7: Application layer

13

requesting hostcis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS serverdns.poly.edu

1

2

45

6

authoritative DNS serverdns.cs.umass.edu

7

8

TLD DNS server

3

Recursive queries

recursive query:puts burden of name resolution on contacted name serverheavy load?

Page 14: Chapter 7: Application layer

14

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

Page 15: Chapter 7: Application layer

15

DNS records

DNS: distributed db storing resource records (RR)

• Type=NS– name is domain (e.g.

foo.com)– value is IP address of

authoritative name server for this domain

RR format: (name, ttl, class, type, value

• Type=Aname is hostnamevalue is IP address

• Type=CNAMEname is alias name for some “canonical” (the real) name www.ibm.com is really servereast.backup2.ibm.com

value is canonical name

• Type=MXvalue is name of mail server associated with name

Page 16: Chapter 7: Application layer

16

• Example:

Aix 86400 IN A 192.168.42.2 86400 IN MX 5 aix.unpbook.com.

86400 IN MX 10 mailhost.unpbook.com.Aix-4 86400 IN A 192.168.42.2ftp 86400 IN CNAME linux.unpbook.comwww 86400 IN CNAME linux.unpbook.com

• DNS uses UDP to exchange information• Query is initiated from a system call: gethostbyname, gethostbyaddr.

Page 17: Chapter 7: Application layer

17

Electronic Mail

Three major components: • user agents • mail servers • simple mail transfer protocol:

SMTP

User Agent• a.k.a. “mail reader”• composing, editing, reading

mail messages• e.g., pine, Eudora, Outlook,

elm, Netscape Messenger• outgoing, incoming messages

stored on server

user mailbox

outgoing message queue

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 18: Chapter 7: Application layer

18

Electronic Mail: mail servers

Mail Servers • mailbox contains incoming

messages (yet to be read) for user

• message queue of outgoing (to be sent) mail messages

• SMTP protocol between mail servers to send email messages– “client”: sending mail server– “server”: receiving mail server

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 19: Chapter 7: Application layer

19

Electronic Mail: SMTP [RFC 821]

• uses tcp to reliably transfer email msg 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 20: Chapter 7: Application layer

20

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

Page 21: Chapter 7: Application layer

21

try smtp interaction for yourself:

• telnet servername 25• see 220 reply from server• enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send email without using email client (reader)

• The current SMTP-based email system cannot verify the identity of sender– Sender Policy Framework/SenderID proposed to verify if

sender mail server is authorized to send email for the sender email address

Page 22: Chapter 7: Application layer

22

smtp: final words

• smtp uses persistent connections– keep-alive connections, more than one request-response per

TCP/IP connection– if there are more messages – they are sent via a persistent TCP

connection • smtp requires that message (header & body) be in 7-bit ascii• certain character strings are not permitted in message (e.g.,

CRLF.CRLF). Thus message has to be encoded (usually into either base-64 or quoted printable)

• smtp server uses CRLF.CRLF to determine end of message

Page 23: Chapter 7: Application layer

23

Mail message format

smtp: protocol for exchanging email msgs

RFC 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 24: Chapter 7: Application layer

24

Message format: multimedia extensions

• MIME: multimedia mail extension, RFC 2045, 2056– Multipurpose Internet Mail Extensions– Support for non-ASCII messages, non-textual messages, multipart messages,

non-ASCII message headers, etc• 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 25: Chapter 7: Application layer

25

MIME typesContent-Type: type/subtype; parameters

Text• example subtypes: plain,

html

Image• example subtypes: jpeg,

gif

Audio• example subtypes: basic

(8-bit mu-law encoded), 32kadpcm (32 kbps coding)

Video• example subtypes: mpeg,

quicktime

Application• other data that must be

processed by reader before “viewable”

• example subtypes: msword, octet-stream

Page 26: Chapter 7: Application layer

26

Multipart Type

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=98766789 --98766789Content-Transfer-Encoding: quoted-printableContent-Type: text/plain

Dear Bob, Please find a picture of a crepe.--98766789Content-Transfer-Encoding: base64Content-Type: image/jpeg

base64 encoded data ..... ......................... ......base64 encoded data --98766789--

Page 27: Chapter 7: Application layer

27

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: Hotmail , Yahoo! Mail, etc.

useragent

sender’s mail server

useragent

SMTP SMTP POP3 orIMAP

receiver’s mail server

Page 28: Chapter 7: Application layer

28

POP3 protocol

authorization phase• client commands:

– user: declare username– pass: password

• server responses– +OK– -ERR

transaction phase, client:• list: list message numbers• retr: retrieve message by

number• dele: delete• quit

C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

S: +OK POP3 server ready C: user alice S: +OK C: pass hungry S: +OK user successfully logged on

Page 29: Chapter 7: Application layer

Web and HTTP

First 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 30: Chapter 7: Application layer

HTTP overviewHTTP: 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

• HTTP 1.0: RFC 1945• HTTP 1.1: RFC 2068

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP request

HTTP response

HTTP response

Page 31: Chapter 7: Application layer

HTTP overview (continued)

Over 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

Page 32: Chapter 7: Application layer

HTTP request message• two types of HTTP messages: request,

response• HTTP request message:

– ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)header

lines

Carriage return, line feed

indicates end of message

Page 33: Chapter 7: Application layer

HTTP request message: general format

Page 34: Chapter 7: Application layer

HTTP response message

HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...

status line(protocol

status codestatus phrase)

header lines

data, e.g., requestedHTML file

Page 35: Chapter 7: Application layer

Trying out HTTP (client side) for yourself

1. Telnet to your favorite Web server:

Opens TCP connection to port 80(default HTTP server port) at www.cs.fsu.edu.Anything typed in sent to port 80 at cis.poly.edu

telnet www.cs.fsu.edu 80

2. Type in a GET HTTP request:GET index.html / HTTP/1.1Host: www.cs.fsu.edu

By typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server

3. Look at response message sent by HTTP server!

Page 36: Chapter 7: Application layer

36

telnet www.cs.fsu.edu 80Trying 192.168.23.10...Connected to www.cs.fsu.edu (192.168.23.10).Escape character is '^]'.GET /index.html /HTTP/1.1Host: www.cs.fsu.edu

HTTP/1.1 200 OKDate: Wed, 28 Nov 2007 18:34:29 GMTServer: Apache/2.0.52 (Scientific Linux)Last-Modified: Mon, 29 Aug 2005 18:02:35 GMTETag: "1defce0-29c5-4cd2a4c0"Accept-Ranges: bytesContent-Length: 10693Connection: closeContent-Type: text/html; charset=ISO-8859-1

<html>

<head><title>Computer Science @ Florida State University</title>

<base HREF="http://www.cs.fsu.edu/">

<meta NAME="resource-type" CONTENT="document"><meta NAME="description" CONTENT="Website for the Computer Science Department at Florida State University"><meta NAME="keywords" CONTENT="Florida State University, Computer Science, Internet2, CS"><meta NAME="distribution" CONTENT="global"><meta NAME="author" CONTENT="Kendal Van Dyke">

Page 37: Chapter 7: Application layer

User-server state: cookies

• HTTP is stateless.– two requests are treated independently.– Why stateless?– What is the problem with a stateless http?

• E-commence: People buy things by making many requests. Need the ability to bind the requests from the same customer together.

– Solution: cookies

Page 38: Chapter 7: Application layer

Cookies: keeping “state” (cont.)

client serverusual http request

msgusual http response +

Set-cookie: 1678

usual http request msg

cookie: 1678usual http response msg

usual http request msg

cookie: 1678usual http response msg

cookie-specificaction

cookie-spectificaction

servercreates ID

1678 for user

entry in backend

database

access

access

Cookie file

amazon: 1678ebay: 8734

Cookie file

ebay: 8734

Cookie file

amazon: 1678ebay: 8734

one week later:

Page 39: Chapter 7: Application layer

Cookies (continued)

What cookies can bring:

• authorization• shopping carts• recommendations• user session state

(Web e-mail)

Cookies and privacy:• cookies permit sites to

learn a lot about you• you may supply name

and e-mail to sites• search engines use

redirection & cookies to learn yet more

• advertising companies obtain info across sites

aside

Page 40: Chapter 7: Application layer

• Some issues in HTTP:• Mainly due to its popularity

– Cache support.• Insufficient in http/1.0, improved in http/1.1• Intermediate nodes, encoding, etc

– Dynamically generated date• Not reliable in http/1.0

– Performance• Persistent or non-persistent TCP connection• Download the whole file or part of a file

– User preference– Security


Recommended