四川大學(xué)計(jì)算機(jī)網(wǎng)絡(luò)通信2-1_第1頁(yè)
四川大學(xué)計(jì)算機(jī)網(wǎng)絡(luò)通信2-1_第2頁(yè)
四川大學(xué)計(jì)算機(jī)網(wǎng)絡(luò)通信2-1_第3頁(yè)
四川大學(xué)計(jì)算機(jī)網(wǎng)絡(luò)通信2-1_第4頁(yè)
四川大學(xué)計(jì)算機(jī)網(wǎng)絡(luò)通信2-1_第5頁(yè)
已閱讀5頁(yè),還剩35頁(yè)未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶(hù)提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

1、Chapter 2: Application LayerChapter goals: conceptual + implementation aspects of network application protocolsclient server paradigmservice modelslearn about protocols by examining popular application-level protocolsMore chapter goals specific protocols: HTTPFTPSMTPDNSprogramming network applicatio

2、nssocket programming12: Application Layer2.1 Principles of Application Layer ProtocolsApplication: communicating, distributed processesrunning in network hosts in “user space”exchange messages to implement applicatione.g., email, file transfer, the WebApplication-layer protocolsone “piece” of an app

3、define messages exchanged by apps and actions takenuser services provided by lower layer protocolsapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysical2.1.1 Network Application Architecture22: Application Layer Network ap

4、plications: some jargonA process(進(jìn)程) is a program that is running within a host.Within the same host, two processes communicate with inter-process communication (IPC) (進(jìn)程間通信)defined by the OS(operating system).Processes running in different hosts communicate with an application-layer protocolA user

5、agent is an interface between the user and the network application.Web:browserE-mail: mail readerstreaming audio/video: media player32: Application Layer2.1.2 Processes CommunicatingTypical network app has two pieces: client and serverapplicationtransportnetworkdata linkphysicalapplicationtransportn

6、etworkdata linkphysicalClient:initiates contact with server (“speaks first”)typically requests service from server, for Web, client is implemented in browser; for e-mail, client is implemented in mail senderServer:provides requested service to cliente.g., Web server sends requested Web page, mail se

7、rver receives e-mailrequestreply42: Application LayerServer and Client exchange messages over the network through a common Socket API (套接字) Server and Client ProcessesTCP/UDPIPEthernet AdapterServerTCP/UDPIPEthernet AdapterClientsSocket APIhardwarekernel spaceuser spaceportsSpecific section for sock

8、et_programming52: Application Layer2.1.3 Application-layer protocolsAPI: application programming interfacedefines interface between application and transport layersocket: Internet APItwo processes communicate by sending data into socket, reading data out of socketQ: how does a process “identify” the

9、 other process with which it wants to communicate?IP address of host running other process“port number” - allows receiving host to determine to which local process the message should be delivered lots more on this later.62: Application Layer2.1.4 What transport service does an app need?Data loss(丟包率

10、)some apps (e.g., audio) can tolerate some lossother apps (e.g., file transfer, telnet) require 100% reliable data transfer Timing (實(shí)時(shí)性)some apps (e.g., Internet telephony, interactive games) require low delay to be “effective”Bandwidth (帶寬)some apps (e.g., multimedia) require minimum amount of band

11、width to be “effective”other apps (“elastic apps”) make use of whatever bandwidth they get 72: Application LayerTransport service requirements of common appsApplicationfile transfere-mailWeb documentsreal-time audio/videostored audio/videointeractive gamesfinancial appsData lossno lossno lossloss-to

12、lerantloss-tolerantloss-tolerantloss-tolerantno lossBandwidthelasticelasticelasticaudio: 5Kb-1Mbvideo:10Kb-5Mbsame as above few Kbps upelasticTime Sensitivenononoyes, 100s msecyes, few secsyes, 100s msecyes and no82: Application Layer2.1.5 Services provided by Internet transport protocolsTCP service

13、:connection-oriented: setup required between client, serverreliable transport: between sending and receiving processflow control: sender wont overwhelm receivercongestion control: throttle sender when network overloadeddoes not providing: timing, minimum bandwidth guaranteesUDP service:unreliable da

14、ta transfer between sending and receiving processdoes not provide: connection setup, reliability, flow control, congestion control, timing, or bandwidth guarantee Q: why bother? Why is there a UDP?92: Application LayerInternet apps: their protocols and transport protocolsApplicatione-mailremote term

15、inal accessWeb file transferstreaming multimediaremote file serverInternet telephonyApplicationlayer protocolsmtp RFC 821telnet RFC 854http RFC 2068ftp RFC 959proprietary(e.g. RealNetworks)NSFproprietary(e.g., Vocaltec)Underlyingtransport protocolTCPTCPTCPTCPTCP or UDPTCP or UDPtypically UDP102: App

16、lication LayerThe Web: some jargonWeb page:consists of “objects”addressed by a URL (Uniform Resource Locator) Most Web pages consist of:base HTML page, andseveral referenced objects.URL has two components: host name and path name:User agent for Web is called a browser:MS Internet ExplorerNetscape Co

17、mmunicatorServer for Web is called Web server:Apache (public domain)MS Internet Information Serverwww.someS/someDept/pic.gif112: Application Layer2.2 The Web: the http protocolhttp: hypertext transfer protocol(超文本傳送協(xié)議)Webs application layer protocolclient/server modelclient: browser that requests, r

18、eceives, “displays” Web objectsserver: Web server sends objects in response to requestshttp1.0: RFC 1945http1.1: RFC 2068PC runningExplorerServer runningNCSA WebserverMac runningNavigatorhttp requesthttp requesthttp responsehttp response122: Application LayerThe http protocol: morehttp: TCP transpor

19、t service:client initiates TCP connection (creates socket) to server, port 80server accepts TCP connection from clienthttp messages (application-layer protocol messages) exchanged between browser (http client) and Web server (http server)TCP connection closedhttp is “stateless(無(wú)狀態(tài))”server maintains

20、no information about past client requestsProtocols that maintain “state” are complex!past history (state) must be maintainedif server/client crashes, their views of “state” may be inconsistent, must be reconciledaside132: Application Layerhttp exampleSuppose user enters URL www.someS/someDepartment/

21、home.index1a. http client initiates TCP connection to http server (process) at www.someS. Port 80 is default for http server.2. http client sends http request message (containing URL) into TCP connection socket1b. http server at host www.someS waiting for TCP connection at port 80. “accepts” connect

22、ion, notifying client3. http server receives request message, forms response message containing requested object (someDepartment/home.index), sends message into sockettime(contains text, references to 10 jpeg images)142: Application Layerhttp example (cont.)5. http client receives response message c

23、ontaining html file, displays html. Parsing html file, finds 10 referenced jpeg objects6. Steps 1-5 repeated for each of 10 jpeg objects4. http server closes TCP connection. time152: Application LayerNon-persistent and persistent connectionsNon-persistentHTTP/1.0server parses request, responds, and

24、closes TCP connection2 RTTs (Round Trip Time) to fetch each objectEach object transfer suffers from slow startPersistentdefault for HTTP/1.1on same TCP connection: server, parses request, responds, parses new request,.Client sends requests for all referenced objects as soon as it receives base HTML.

25、Fewer RTTs and less slow start.But most 1.0 browsers useparallel TCP connections.162: Application Layerhttp message format: requesttwo types of http messages: request, responsehttp request message:ASCII (human-readable format)GET /somedir/page.html HTTP/1.0 User-agent: Mozilla/4.0 Accept: text/html,

26、 image/gif,image/jpeg Accept-language:fr (extra carriage return 回車(chē), line feed 換行) request line(GET, POST, HEAD commands)header linesCarriage return, line feed indicates end of message172: Application Layerhttp request message: general format182: Application Layerhttp message format: responseHTTP/1.0

27、 200 OK 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 . status line(protocolstatus codestatus phrase)header linesdata, e.g., requestedhtml file192: Application Layerhttp response

28、 status codes200 OKrequest succeeded, requested object later in this message301 Moved Permanentlyrequested object moved, new location specified later in this message (Location:)400 Bad Requestrequest message not understood by server404 Not Foundrequested document not found on this server505 HTTP Ver

29、sion Not SupportedIn first line in server-client response message.A few sample codes:202: Application LayerTrying out http (client side) for yourself1. Telnet to your favorite Web server: (Telnet:遠(yuǎn)程登錄)Opens TCP connection to port 80(default http server port) at www.eurecom.fr.Anything typed in sent

30、to port 80 at www.eurecom.frtelnet www.eurecom.fr 802. Type in a GET http request:GET /ross/index.html HTTP/1.0By typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to http server3. Look at response message sent by http server!水木清華bbsDos界面(#cmd)#telnet guest21

31、2: Application LayerUser-server interaction: authenticationAuthentication goal: control access to server documentsstateless: client must present authorization in each requestauthorization: typically name, passwordauthorization: header line in requestif no authorization presented, server refuses acce

32、ss, sendsWWW authenticate: header line in responseclientserverusual http request msg401: authorization req.WWW authenticate:usual http request msg+ Authorization:lineusual http response msgusual http request msg+ Authorization:lineusual http response msgtimeBrowser caches name & password sothat user

33、 does not have to repeatedly enter it.222: Application LayerUser-server interaction: cookiesserver sends “cookie” to client in response msgSet-cookie: 1678453client presents cookie in later requestscookie: 1678453server matches presented-cookie with server-stored infoauthenticationremembering user p

34、references, previous choicesclientserverusual http request msgusual http response +Set-cookie: #usual http request msgcookie: #usual http response msgusual http request msgcookie: #usual http response msgcookie-specificactioncookie-specificaction232: Application LayerUser-server interaction: conditi

35、onal GETGoal: dont send object if client has up-to-date stored (cached) versionclient: specify date of cached copy in http requestIf-modified-since: server: response contains no object if cached copy up-to-date: HTTP/1.0 304 Not Modifiedclientserverhttp request msgIf-modified-since: http responseHTT

36、P/1.0 304 Not Modifiedobject not modifiedhttp request msgIf-modified-since: http responseHTTP/1.1 200 OKobject modified242: Application LayerWeb Caches 高速緩存 (proxy server)user sets browser: Web accesses via web cacheclient sends all http requests to web cacheif object at web cache, web cache immedia

37、tely returns object in http response else requests object from origin server, then returns http response to clientGoal: satisfy client request without involving origin serverclientProxyserverclienthttp requesthttp requesthttp responsehttp responsehttp requesthttp responsehttp requesthttp responseori

38、gin serverorigin server252: Application LayerWhy Web Caching?Assume: cache is “close” to client (e.g., in same network)smaller response time: cache “closer” to clientdecrease traffic to distant serverslink out of institutional/local ISP network often bottleneck originserverspublic Internetinstitutio

39、nalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache262: Application Layer2.3ftp: the file transfer protocoltransfer file to/from remote hostclient/server modelclient: side that initiates transfer (either to/from remote)server: remote hostftp: RFC 959ftp server: port 21file transferFTPserverF

40、TPuserinterfaceFTPclientlocal filesystemremote filesystemuser at host272: Application Layerftp: separate control, data connectionsftp client contacts ftp server at port 21, specifying TCP as transport protocoltwo parallel TCP connections opened:control: exchange commands, responses between client, s

41、erver.“out of band control”data: file data to/from serverftp server maintains “state”: current directory, earlier authentication , statefulFTPclientFTPserverTCP control connectionport 21TCP data connectionport 20282: Application Layerftp commands, responsesSample commands:sent as ASCII text over con

42、trol channelUSER usernamePASS passwordLIST return list of file in current directoryRETR filename retrieves (gets) fileSTOR filename stores (puts) file onto remote hostSample return codesstatus code and phrase (as in http)331 Username OK, password required125 data connection already open; transfer st

43、arting425 Cant open data connection452 Error writing file292: Application Layer2.4Electronic MailThree major components: user agents mail servers simple mail transfer protocol: smtpUser Agenta.k.a. “mail reader”composing, editing, reading mail messagese.g., Eudora, Outlook, elm, Netscape Messengerou

44、tgoing, incoming messages stored on serveruser mailboxoutgoing message queuemailserveruseragentuseragentuseragentmailserveruseragentuseragentmailserveruseragentSMTPSMTPSMTP302: Application LayerElectronic Mail: mail serversMail Servers mailbox contains incoming messages (yet to be read) for usermess

45、age queue of outgoing (to be sent) mail messagessmtp protocol between mail servers to send email messages“client”: sending mail server“server”: receiving mail servermailserveruseragentuseragentuseragentmailserveruseragentuseragentmailserveruseragentSMTPSMTPSMTP312: Application LayerElectronic Mail:

46、smtp RFC 821uses TCP to reliably transfer email msg from client to server, port 25direct transfer: sending server to receiving serverthree phases of transferhandshaking (greeting)transfer of messagesclosurecommand/response interactioncommands: ASCII textresponse: status code and phrasemessages must

47、be in 7-bit ASCII322: Application LayerSample smtp interaction S: 220 C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: S: 250 alicecrepes.fr. Sender ok C: RCPT TO: S: 250 bob . Recipient ok C: DATA S: 354 Enter mail, end with . on a line by itself C: Do you like ketchup? C

48、: How about pickles? C: . S: 250 Message accepted for delivery C: QUIT S: 221 closing connection332: Application Layertry smtp interaction for yourself:telnet servername 25see 220 reply from serverenter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send email without using email clien

49、t (reader)342: Application Layersmtp: final wordssmtp uses persistent connectionssmtp requires that message (header & body) be in 7-bit asciicertain character strings are not permitted in message (e.g., CRLF.CRLF). Thus message has to be encoded smtp server uses CRLF.CRLF to determine end of message

50、Comparison with httphttp: pullemail: pushboth have ASCII command/response interaction, status codeshttp: each object is encapsulated in its own response messagesmtp: multiple objects message sent in a multipart message352: Application LayerMail message formatsmtp: protocol for exchanging email msgsRFC 822: standard for text message format:header lines, e.g.,To:From:Subject:different from smtp commands!bodythe “message”, ASCII characters onlyh

溫馨提示

  • 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶(hù)所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶(hù)上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶(hù)上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶(hù)因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論