计算机网络课件:Chapter2 Application Layer_第1页
计算机网络课件:Chapter2 Application Layer_第2页
计算机网络课件:Chapter2 Application Layer_第3页
计算机网络课件:Chapter2 Application Layer_第4页
计算机网络课件:Chapter2 Application Layer_第5页
已阅读5页,还剩100页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、2: Application Layer1Chapter 2Application LayerComputer Networking: A Top Down Approach Featuring the Internet, 3rd edition. Jim Kurose, Keith RossAddison-Wesley, July 2004. A note on the use of these ppt slides:Were making these slides freely available to all (faculty, students, readers). Theyre in

2、 PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following:q If you use these slides (e.g., in a class) in substantially unaltered form, that yo

3、u mention their source (after all, wed like people to use our book!)q If you post any slides in substantially unaltered form on a www site, that you note that they are adapted from (or perhaps identical to) our slides, and note our copyright of this material.Thanks and enjoy! JFK/KWRAll material cop

4、yright 1996-2006J.F Kurose and K.W. Ross, All Rights Reserved2: Application Layer2Chapter 2: Application layerr2.1 Principles of network applicationsr2.2 Web and HTTPr2.3 FTP r2.4 Electronic MailvSMTP, POP3, IMAPr2.5 DNSr2.6 P2P file sharingr2.7 Socket programming with TCPr2.8 Socket programming wit

5、h UDPr2.9 Building a Web server2: Application Layer3Chapter 2: Application LayerOur goals: rconceptual, implementation aspects of network application protocolsvtransport-layer service modelsvclient-server paradigmvpeer-to-peer paradigmrlearn about protocols by examining popular application-level pro

6、tocolsvHTTPvFTPvSMTP / POP3 / IMAPvDNSrprogramming network applicationsvsocket API2: Application Layer4Some network appsrE-mailrWebrInstant messagingrRemote loginrP2P file sharingrMulti-user network gamesrStreaming stored video clipsrInternet telephonerReal-time video conferencerMassive parallel com

7、putingr r r 2: Application Layer5Creating a network appWrite programs thatvrun on different end systems andvcommunicate over a network.ve.g., Web: Web server software communicates with browser softwarelittle software written for devices in network core (因为网络核心设备并不在应用层起作用,而只是在网络及以下层起作用)vnetwork core

8、devices do not run user application codevapplication on end systems allows for rapid app development, propagationapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysical2: Application Layer6Chapter 2: Application layerr2.1 P

9、rinciples of network applicationsr2.2 Web and HTTPr2.3 FTP r2.4 Electronic MailvSMTP, POP3, IMAPr2.5 DNSr2.6 P2P file sharingr2.7 Socket programming with TCPr2.8 Socket programming with UDPr2.9 Building a Web server2: Application Layer7Application architectures网络应用程序的体系结构,明显不同于网络体系结构(固定的);由应用程序者设计研发

10、,主流有以下三种:rClient-serverrPeer-to-peer (P2P)rHybrid of client-server and P2P2: Application Layer8Client-server architectureserver: valways-on hostvpermanent IP addressvserver farms(服务器场:主机群集) for scalingclients:vcommunicate with servervmay be intermittently connectedvmay have dynamic IP addressesvdo n

11、ot communicate directly with each other2: Application Layer9Pure P2P architecturerno always-on serverrarbitrary end systems directly communicaterpeers are intermittently connected and change IP addressesrexample: GnutellaHighly scalable, but difficult to manage2: Application Layer10Hybrid of client-

12、server and P2PSkypevInternet telephony appvFinding address of remote party: centralized server(s)vClient-client connection is direct (not through server) Instant messaging(即时讯息)vChatting between two users is P2PvPresence detection/location centralized: User registers its IP address on central server

13、 when it comes online User contacts central server to find IP addresses of buddies(伙伴)2: Application Layer11Processes communicatingProcess: program running within a host.rwithin same host, two processes communicate using inter-process (进程间)communication (defined by OS).rprocesses in different hosts

14、communicate by exchanging messagesClient process: process that initiates communicationServer process: process that waits to be contactedrNote: applications with P2P architectures have client processes & server processes(一个进程能够即是客户机进程又是服务器进程,因即可上传文件又可下载文件)2: Application Layer12Sockets (应用程序编程接口:A

15、PI)rprocess sends/receives messages to/from its socketrsocket analogous to doorvsending process shoves(推) message out doorvsending process relies on transport infrastructure on other side of door which brings message to socket at receiving processprocessTCP withbuffers,variablessockethost orserverpr

16、ocessTCP withbuffers,variablessockethost orserverInternetcontrolledby OScontrolled byapp developerrAPI对传输层的控制: (1) choice of transport protocol; (2) ability to fix a few parameters (如最大缓存、最大报文段长度等) 2: Application Layer13Addressing processesrto receive messages, process must have identifierrhost devi

17、ce has unique32-bit IP addressrQ: does IP address of host on which process runs suffice for (满足)identifying the process?2: Application Layer14Addressing processes (寻址进程)rto receive messages, process must have identifierrhost device has unique32-bit IP addressrQ: does IP address of host on which proc

18、ess runs suffice(足够、足以) for identifying the process?vAnswer: NO, many processes can be running on same hostridentifier includes both IP address and port numbers associated with process on host.rExample port numbers(熟知端口号:01023):vHTTP server: 80vMail server: 25rto send HTTP message to gaia.cs.umass.e

19、du web server:vIP address: 2vPort number: 80rmore shortly2: Application Layer15App-layer protocol definesrTypes of messages exchanged, ve.g., request, response rMessage syntax:vwhat fields in messages & how fields are delineatedrMessage semantics vmeaning of information in fieldsrRu

20、les for when and how processes send & respond to messagesPublic-domain protocols(公共领域协议):rdefined in RFCsrallows for interoperabilityre.g., HTTP, SMTPProprietary protocols(专用协议):re.g., KaZaA2: Application Layer16What transport service does an app need?Data lossrsome apps (e.g., audio) can tolera

21、te some lossrother apps (e.g., file transfer, telnet) require 100% reliable data transfer Timingrsome apps (e.g., Internet telephony, interactive games) require low delay to be “effective”Bandwidthrsome apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”rother apps (“elasti

22、c apps”) make use of whatever bandwidth they get (带宽越宽越好)2: Application Layer17Transport service requirements of common appsApplicationfile transfere-mailWeb documentsreal-time audio/videostored audio/videointeractive gamesinstant messagingData lossno lossno lossno lossloss-tolerantloss-tolerantloss

23、-tolerantno lossBandwidthelasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelasticTime Sensitivenononoyes, 100 msecyes, few secsyes, 100 msecyes and no2: Application Layer18Internet transport protocols servicesTCP service:rconnection-oriented: setup required between c

24、lient and server processesrreliable transport between sending and receiving processrflow control: sender wont overwhelm receiver rcongestion control: throttle(抑制) sender when network overloadedrdoes not provide: timing, minimum bandwidth guaranteesUDP service:runreliable data transfer between sendin

25、g and receiving processrdoes not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee Q: why bother? Why is there a UDP?2: Application Layer19Internet apps: application, transport protocolsApplicatione-mailremote terminal accessWeb file transferstr

26、eaming multimediaInternet telephonyApplicationlayer protocolSMTP RFC 2821Telnet RFC 854HTTP RFC 2616FTP RFC 959proprietary(e.g. RealNetworks)Proprietary(有最低速率要求且容忍一定的数据丢失)(e.g., Vonage,Dialpad)Underlyingtransport protocolTCPTCPTCPTCPTCP or UDPtypically UDP2: Application Layer20Chapter 2: Application

27、 layerr2.1 Principles of network applications vapp architecturesvapp requirementsr2.2 Web and HTTPr2.3 FTPr2.4 Electronic MailvSMTP, POP3, IMAPr2.5 DNSr2.6 P2P file sharingr2.7 Socket programming with TCPr2.8 Socket programming with UDPr2.9 Building a Web server2: Application Layer21Web and HTTPWeb的

28、按需操作,一改传统的被动只能收听、收看!rWeb page consists of objects(对象,既文件)rObject can be HTML file, JPEG image, Java applet, audio file,rWeb page consists of base HTML-file which includes several referenced(引用的) objectsrEach object is addressable by a URLrExample URL(包括:存放对象的主机名和路径名):/someDept/pic.

29、gifhost namepath name2: Application Layer22HTTP overviewHTTP: hypertext transfer protocolrWebs application layer protocol,也是Web的核心,包括一个客户机程序和一个服务器程序。rclient/server modelvclient: browser(Web应用的用户代理) that requests, receives, “displays” Web objectsvserver: Web server sends objects in response to reques

30、tsrHTTP 1.0: RFC 1945rHTTP 1.1: RFC 2068PC runningExplorerServer runningApache WebserverMac runningNavigatorHTTP requestHTTP requestHTTP responseHTTP response2: Application Layer23HTTP overview (continued)Uses TCP:rclient initiates TCP connection (creates socket) to server, port 80rserver accepts TC

31、P connection from clientrHTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server)rTCP connection closedHTTP is “stateless”rserver maintains no information about past client requestsProtocols that maintain “state” are complex!rpast histo

32、ry (state) must be maintainedrif server/client crashes, their views of “state” may be inconsistent, must be reconciledaside2: Application Layer24HTTP connectionsNonpersistent HTTPrAt most one object is sent over a TCP connection.rHTTP/1.0 uses nonpersistent HTTPPersistent HTTPrMultiple objects can b

33、e sent over single TCP connection between client and server.rHTTP/1.1 uses persistent connections in default mode2: Application Layer25Nonpersistent HTTPSuppose user enters URL www.someS/someDepartment/home.index1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSc

34、 on port 802. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index1b. HTTP server at host www.someS waiting for TCP connection at port 80. “accepts” connection, notifying client3. HTT

35、P server receives request message, forms response message containing requested object, and sends message into its sockettime(contains text, references to 10 jpeg images)2: Application Layer26Nonpersistent HTTP (cont.)5. HTTP client receives response message containing html file, displays html. Parsi

36、ng html file, finds 10 referenced jpeg objects6. Steps 1-5 repeated for each of 10 jpeg objects4. HTTP server closes TCP connection. time2: Application Layer27Non-Persistent HTTP: Response timeDefinition of RTT: time to send a small packet to travel from client to server and back.Response time:rone

37、RTT to initiate TCP connectionrone RTT for HTTP request and first few bytes of HTTP response to returnrfile transmission timetotal = 2RTT+transmit timetime to transmit fileinitiate TCPconnectionRTTrequestfileRTTfilereceivedtimetime2: Application Layer28Persistent HTTPNonpersistent HTTP issues:rrequi

38、res 2 RTTs per objectrOS overhead for each TCP connectionrbrowsers often open parallel TCP connections to fetch referenced objectsPersistent HTTPrserver leaves connection open after sending responsersubsequent HTTP messages between same client/server sent over open connectionPersistent without pipel

39、ining:rclient issues new request only when previous response has been receivedrone RTT for each referenced objectPersistent with pipelining:rdefault in HTTP/1.1rclient sends requests as soon as it encounters a referenced objectras little as one RTT for all the referenced objects2: Application Layer2

40、9HTTP request messagertwo types of HTTP messages: request, responserHTTP request message(用GET方法来请求一个对象):v用普通的ASCII 文本书写的(human-readable format)v由请求行(一行、三个字段;方法字段、URL字段和HTTP版本字段)和后续的首部行(多行)组成GET /somedir/page.html HTTP/1.1Host: User-agent: Mozilla/4.0(发送请求的浏览器类型)(发送请求的浏览器类型)Connect

41、ion: close(发送完请求的对象后就关闭连接)(发送完请求的对象后就关闭连接)Accept-language:fr (希望得到对象的法语版本)(希望得到对象的法语版本)(extra carriage return, line feed) request line(GET, POST, HEAD commands)header linesCarriage return, line feed indicates end of message2: Application Layer30HTTP request message: general format(在使用POST方法时才有Entity

42、 Body,此时此中包含的是用户在表单字段中的输入值:搜索关键字;HEAD方法常被用来进行故障跟踪)2: Application Layer31Method typesHTTP/1.0rGETrPOSTrHEADvasks server to leave requested object out of responseHTTP/1.1rGET, POST, HEADrPUTvuploads file in entity body to path specified in URL fieldrDELETEvdeletes file specified in the URL field2: App

43、lication Layer32HTTP response messageHTTP/1.1 200 OK Connection close(告客户机发送完报文后关闭了该(告客户机发送完报文后关闭了该TCP连接)连接)Date: 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 . st

44、atus line(protocol,status code,status message)header linesdata, e.g., requestedHTML file2: Application Layer33HTTP response status codes200 OKvrequest succeeded, requested object later in this message301 Moved Permanentlyvrequested object moved, new location specified later in this message (Location

45、:)400 Bad Requestvrequest message not understood by server404 Not Foundvrequested document not found on this server505 HTTP Version Not SupportedIn first line in server-client response message.A few sample codes:2: Application Layer34User-server state: cookies (用户与服务器的交互) 由于HTTP服务器是无状态的,但Many major

46、Web sites 希望能识别用户,故use cookies来跟踪和验证用户Four components (cookie技术中的四个组成部分):1) cookie header line in HTTP response message2) cookie header line in HTTP request message3) cookie file kept on users host, managed by users browser4) back-end (后端)database at Web siteExample:vSusan access Internet always fro

47、m same PCvShe visits a specific e-commerce site for first timevWhen initial HTTP requests arrives at site, site creates a unique ID and creates an entry(表项) in backend database for ID2: Application Layer35Cookies: keeping “state” (cont.)clientserverusual http request msgusual http response +Set-cook

48、ie: 1678 usual http request msgcookie: 1678usual http response msgusual http request msgcookie: 1678usual http response msgcookie-specificactioncookie-spectificactionservercreates ID1678 for userentry in backend databaseaccessaccessCookie fileamazon: 1678ebay: 8734Cookie fileebay: 1678Cookie fileama

49、zon: 1678ebay: 8734one week later:2: Application Layer36Cookies (continued)What cookies can bring:rauthorizationrshopping cartsrrecommendationsruser session state (Web e-mail)Cookies and privacy:rcookies permit sites to learn a lot about youryou may supply name and e-mail to sitesasideHow to keep “s

50、tate”:rProtocol endpoints: maintain state at sender/receiver over multiple transactionsrcookies: http messages carry state2: Application Layer37Web caches (proxy server)ruser sets browser: Web accesses via cacherbrowser sends all HTTP requests to cachevobject in cache: cache returns object velse cac

51、he requests object from origin server, then returns object to clientGoal: satisfy client request without involving origin server(保存着最近请求过的对象的拷贝)clientProxyserverclientHTTP requestHTTP requestHTTP responseHTTP responseHTTP requestHTTP responseorigin serverorigin server2: Application Layer38More about

52、 Web cachingrCache acts as both client and serverrTypically cache is installed by ISP (university, company, residential ISP)Why Web caching?rReduce response time for client request.rReduce traffic on an institutions access link to Internet. 从而大大降低Internet上的Web流量,改善了所有应用的性能rInternet dense with caches

53、: enables “poor” content providers to effectively deliver content (but so does P2P file sharing)2: Application Layer39Caching example Assumptionsraverage object size = 1M bravg. request rate from institutions browsers to origin servers = 15个/secrdelay from Internet router to any origin server and ba

54、ck to router (Internet delay)= 2 secConsequences(计算见P68)rutilization on LAN = 15%rutilization on access link = 100%(即流量强度接近1,路由器间的链路上的时延会变大且趋于无限,至少满足请求的平均响应时间将以分钟计)rtotal delay = Internet delay + access delay + LAN delay= 2 sec + minutes + millisecondsoriginserverspublic Internetinstitutionalnetwork

55、10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer40Caching example (cont)Possible solutionrincrease bandwidth of access link to, say, 10 MbpsConsequencesrutilization on LAN = 15%rutilization on access link = 15 (即流量强度为0.15,则路由器间的链路上的时延也可忽略不计了)rTotal delay = Internet delay + acces

56、s delay + LAN delay= 2 sec + msecs + msecs = 2 sec roften a costly upgradeoriginserverspublic Internetinstitutionalnetwork10Mbps LAN10 Mbps access linkinstitutionalcache2: Application Layer41Caching example (cont)Install cachersuppose hit rate(命中率:一般在0.20.7之间) is 0.4Consequencer40% requests will be

57、satisfied almost immediately (即时延less than 10 msec)r60% requests satisfied by origin server,其链路上的流量强度由1 reduced to 0.6 while resulting in delays (say 10 to 几十 msec),可被negligiblertotal avg delay = Internet delay + access delay + LAN delay = .6*(2) secs + .4*milliseconds 1.3 secs 可见此方案比升级链路速率的前个方案代价小得

58、多!originserverspublic Internetinstitutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer42Conditional GET (条件GET方法:允许缓存器证实它的对象是最新的机制的实现方法)Goal: dont send object if cache has up-to-date cached version(存放在缓冲器中的对象拷贝不能是过时的)rcache: specify date of cached copy in HTTP reques

59、tIf-modified-since: rserver: response contains no object(避免浪费带宽) if cached copy is up-to-date: HTTP/1.0 304 Not ModifiedcacheserverHTTP request msgIf-modified-since: HTTP responseHTTP/1.0 304 Not Modifiedobject not modifiedHTTP request msgIf-modified-since: HTTP responseHTTP/1.0 200 OKobject modifie

60、d2: Application Layer43Chapter 2: Application layerr2.1 Principles of network applicationsr2.2 Web and HTTPr2.3 FTP r2.4 Electronic MailvSMTP, POP3, IMAPr2.5 DNSr2.6 P2P file sharingr2.7 Socket programming with TCPr2.8 Socket programming with UDPr2.9 Building a Web server2: Application Layer44FTP: the file tra

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论