计算机网络第二章课件.ppt_第1页
计算机网络第二章课件.ppt_第2页
计算机网络第二章课件.ppt_第3页
计算机网络第二章课件.ppt_第4页
计算机网络第二章课件.ppt_第5页
已阅读5页,还剩109页未读 继续免费阅读

下载本文档

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

文档简介

1、2: Application Layer,1,Computer Networking: A Top Down Approach, 2011.9.5,4th edition. Jim Kurose, Keith Ross,2: Application Layer,2,Chapter 2: Application layer,2.1 Principles of network applications 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS,2.6 P2P Applications 2.7 Sock

2、et programming with TCP 2.8 Socket programming with UDP,2: Application Layer,3,Chapter 2: Application Layer,Our goals: conceptual, implementation aspects of network application protocols transport-layer service models client-server paradigm peer-to-peer paradigm,learn about protocols by examining po

3、pular application-level protocols HTTP FTP SMTP / POP3 / IMAP DNS programming network applications socket API,2: Application Layer,4,Some network apps,e-mail web instant messaging remote login P2P file sharing multi-user network games streaming stored video clips,voice over IP real-time video confer

4、encing Gridcomputing (网格计算),2: Application Layer,5,Creating a network app,write programs that run on (different) end systems communicate over network e.g., web server software communicates with browser software little software written for devices in network core network core devices do not run user

5、applications applications on end systems allows for rapid app development, propagation,2: Application Layer,6,Chapter 2: Application layer,2.1 Principles of network applications 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS,2.6 P2P file sharing 2.7 Socket programming with TCP

6、 2.8 Socket programming with UDP 2.9 Building a Web server,2: Application Layer,7,Application architectures,Client-server Peer-to-peer (P2P) Hybrid of client-server and P2P,2: Application Layer,8,Client-server architecture,server: always-on host permanent IP address server farms(服务器群 ) for scaling c

7、lients: communicate with server may be intermittently(间歇地 ) connected may have dynamic IP addresses do not communicate directly with each other,2: Application Layer,9,Pure P2P architecture,no always-on server arbitrary end systems directly communicate peers are intermittently connected and change IP

8、 addresses example: Gnutella Highly scalable but difficult to manage,2: Application Layer,10,Hybrid of client-server and P2P,Skype voice-over-IP P2P application centralized server: finding address of remote party: client-client connection: direct (not through server) Instant messaging chatting betwe

9、en two users is P2P centralized service: client presence detection/location user registers its IP address with central server when it comes online user contacts central server to find IP addresses of buddies(伙伴),2: Application Layer,11,Processes communicating(进程通信),Process: program running within a

10、host. within same host, two processes communicate using inter-process communication (defined by OS). processes in different hosts communicate by exchanging messages(报文),Client process: process that initiates communication Server process: process that waits to be contacted,Note: applications with P2P

11、 architectures have client processes (2) ability to fix a few parameters (lots more on this later),2: Application Layer,13,Addressing(寻址) processes,to receive messages, process must have identifier host device has unique 32-bit IP address Q: does IP address of host on which process runs suffice for

12、identifying the process?,2: Application Layer,14,Addressing processes,to receive messages, process must have identifier host device has unique 32-bit IP address Q: does IP address of host on which process runs suffice for(满足需求) identifying the process? A: No, many processes can be running on same ho

13、st,identifier includes both IP address and port numbers associated with process on host. Example port numbers: HTTP server: 80 Mail server: 25 to send HTTP message to web server: IP address: 2 Port number: 80 more shortly,2: Application Layer,15,App-layer protocol defi

14、nes,Types of messages exchanged, e.g., request, response Message syntax: what fields in messages transfer starting 425 Cant open data connection 452 Error writing file,2: Application Layer,52,Experiment,ftp Ls Pwd Cd MTV Retr ,2: Application Layer,53,Chapter 2: Application layer,2.1 Principles of ne

15、twork applications 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS,2.6 P2P file sharing 2.7 Socket programming with TCP 2.8 Socket programming with UDP 2.9 Building a Web server,2: Application Layer,54,Electronic Mail,Three major components: user agents mail servers simple mail

16、 transfer protocol: SMTP User Agent a.k.a. “mail reader” composing, editing, reading mail messages e.g., Eudora, Outlook, elm, Mozilla Thunderbird outgoing, incoming messages stored on server,2: Application Layer,55,Electronic Mail: mail servers,Mail Servers mailbox contains incoming messages for us

17、er 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,2: Application Layer,56,Electronic Mail: SMTP RFC 2821,uses TCP to reliably transfer email message from client to server, port

18、 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,2: Application Layer,57,Scenario: Alice sends messag

19、e to Bob,1) Alice uses UA to compose message and “to” 2) Alices UA sends message to her mail server; message placed in message queue 3) Client side of SMTP opens TCP connection with Bobs mail server,4) SMTP client sends Alices message over the TCP connection 5) Bobs mail server pla

20、ces the message in Bobs mailbox 6) Bob invokes his user agent to read message,1,2,3,4,5,6,2: Application Layer,58,Sample 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 bobhamburger.

21、edu . 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 closing connection,2: Application Layer,59,Try SMTP interaction for yourself:,telnet servername 25 see 220

22、 reply from server enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send email without using email client (reader),2: Application Layer,60,Experiment,telnet 25,2: Application Layer,61,SMTP: final words,SMTP uses persistent connections SMTP requires message (header 1st approx: clien

23、t queries a root server to find com DNS server client queries com DNS server to get DNS server client queries DNS server to get IP address for ,2: Application Layer,72,DNS: Root name servers,contacted by local name server that can not resolve name root name server: contacts authoritative name server

24、 if name mapping not known gets mapping returns mapping to local name server,13 root name servers worldwide,b USC-ISI Marina del Rey, CA l ICANN Los Angeles, CA,e NASA Mt View, CA f Internet Software C. Palo Alto, CA (and 36 other locations),i Autonomica, Stockholm (plus 28 other locations),k RIPE L

25、ondon (also 16 other locations),m WIDE Tokyo (also Seoul, Paris, SF),a Verisign, Dulles, VA c Cogent, Herndon, VA (also LA) d U Maryland College Park, MD g US DoD Vienna, VA h ARL Aberdeen, MD j Verisign, ( 21 locations),2: Application Layer,73,TLD and Authoritative Servers,Top-level domain (TLD) se

26、rvers: 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: organizations DNS servers, providing authoritative hostname to IP mappings for organizations servers (e.g.

27、, Web, mail). can be maintained by organization or service provider,2: Application Layer,74,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 ser

28、ver acts as proxy, forwards query into hierarchy,2: Application Layer,75,requesting host ,,root DNS server,1,2,3,4,5,6,authoritative DNS server ,7,8,TLD DNS server,DNS name resolution example,Host at wants IP address for ,Ite

29、rated(迭代) query: contacted server replies with name of server to contact “I dont know this name, but ask this server”,2: Application Layer,76,Recursive(递归) query: puts burden of name resolution on contacted name server heavy load?,DNS name resolution example,2: Application Layer,77,DNS: caching and

30、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 /html.chart

31、ers/dnsind-charter.html,2: Application Layer,78,DNS records,DNS: distributed db storing resource records (RR 资源记录),Type=NS name is domain (e.g. ) value is hostname of authoritative name server for this domain,Type=A name is hostname value is IP address,Type=CNAME name is alias name for some “canonic

32、al(规范)” (the real) name is really value is canonical name,Type=MX value is name of mailserver associated with name,2: Application Layer,79,DNS protocol, messages,DNS protocol : query and reply messages, both with same message format,msg header identification: 16 bit # for query, reply to query uses

33、same # flags: query or reply Recursion(递归) desired recursion available reply is authoritative,2: Application Layer,80,DNS protocol, messages,Name, type fields for a query,RRs in response to query,records for authoritative servers,additional “helpful” info that may be used,2: Application Layer,81,Cha

34、pter 2: Application layer,2.1 Principles of network applications app architectures app requirements 2.2 Web and HTTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS,2.6 P2P file sharing 2.7 Socket programming with TCP 2.8 Socket programming with UDP 2.9 Building a Web server,2: Application Layer,82,P2P

35、 file sharing,Example Alice runs P2P client application on her notebook computer intermittently connects to Internet; gets new IP address for each connection asks for “Hey Jude” application displays other peers that have copy of Hey Jude.,Alice chooses one of the peers, Bob. file is copied from Bobs

36、 PC to Alices notebook: HTTP while Alice downloads, other users uploading from Alice. Alices peer is both a Web client and a transient Web server. All peers are servers = highly scalable!,2: Application Layer,83,P2P: centralized directory,original “Napster” design 1) when peer connects, it informs c

37、entral server: IP address content 2) Alice queries for “Hey Jude” 3) Alice requests file from Bob,2: Application Layer,84,P2P: problems with centralized directory,single point of failure performance bottleneck copyright infringement: “target” of lawsuit is obvious,file transfer is decentralized, but

38、 locating content is highly centralized,2: Application Layer,85,Query flooding: Gnutella,fully distributed no central server public domain protocol many Gnutella clients implementing protocol,overlay network(覆盖型网络): graph edge between peer X and Y if theres a TCP connection all active peers and edge

39、s form overlay net edge: virtual (not physical) link given peer typically connected with 10 overlay neighbors,2: Application Layer,86,Gnutella: protocol,File transfer: HTTP,Query messagesent over existing TCPconnections peers forwardQuery message QueryHit(查询命中) sent over reversepath,Scalability: lim

40、ited scopeflooding,2: Application Layer,87,Gnutella: Peer joining,joining peer Alice must find another peer in Gnutella network: use list of candidate peers Alice sequentially attempts TCP connections with candidate peers until connection with Bob Flooding: Alice sends Ping message to Bob; Bob forwa

41、rds Ping message to his overlay neighbors (who then forward to their neighbors.) peers receiving Ping message respond to Alice with Pong message Alice receives many Pong messages, and can then setup additional TCP connections Peer leaving: see homework problem!,2: Application Layer,88,Hierarchical O

42、verlay(层次覆盖),between centralized index, query flooding approaches each peer is either a group leader or assigned to a group leader. TCP connection between peer and its group leader. TCP connections between some pairs of group leaders. group leader tracks content in its children,2: Application Layer,

43、89,P2P Case Study: BitTorrent,tracker: tracks peers participating in torrent,torrent: group of peers exchanging chunks of a file,P2P file distribution,2: Application Layer,90,BitTorrent (1),file divided into 256KB chunks. peer joining torrent: has no chunks, but will accumulate them over time regist

44、ers with tracker to get list of peers, connects to subset of peers (“neighbors”) while downloading, peer uploads chunks to other peers. peers may come and go once peer has entire file, it may (selfishly) leave or (altruistically) remain,2: Application Layer,91,BitTorrent (2),Pulling Chunks at any gi

45、ven time, different peers have different subsets of file chunks periodically, a peer (Alice) asks each neighbor for list of chunks that they have. Alice issues requests for her missing chunks rarest first(最稀罕优先),Sending Chunks: tit-for-tat Alice sends chunks to four neighbors currently sending her c

46、hunks at the highest rate re-evaluate top 4 every 10 secs every 30 secs: randomly select another peer, starts sending chunks newly chosen peer may join top 4,2: Application Layer,92,P2P Case study: Skype,P2P (pc-to-pc, pc-to-phone, phone-to-pc) Voice-Over-IP (VoIP) application also IM proprietary ap

47、plication-layer protocol (inferred via reverse engineering) hierarchical overlay,Skype clients (SC),Supernode (SN),2: Application Layer,93,Skype: making a call,User starts Skype,Skype login server,SC registers with SN list of bootstrap SNs,SC logs in (authenticate),Call: SC contacts SN will callee I

48、D SN contacts other SNs (unknown protocol, maybe flooding) to find addr of callee; returns addr to SC,SC directly contacts callee, overTCP,2: Application Layer,94,Chapter 2: Application layer,2.1 Principles of network applications 2.2 Web and HTTP 2.3 FTP 2.4 Electronic Mail SMTP, POP3, IMAP 2.5 DNS

49、,2.6 P2P file sharing 2.7 Socket programming with TCP 2.8 Socket programming with UDP,2: Application Layer,95,Socket programming,Socket API introduced in BSD4.1 UNIX, 1981 explicitly created, used, released by apps client/server paradigm two types of transport service via socket API: unreliable data

50、gram reliable, byte stream-oriented,Goal: learn how to build client/server application that communicate using sockets,2: Application Layer,96,Socket-programming using TCP,Socket: a door between application process and end-end-transport protocol (UCP or TCP) TCP service: reliable transfer of bytes fr

51、om one process to another,controlled by application developer,controlled by operating system,host or server,controlled by application developer,controlled by operating system,host or server,internet,2: Application Layer,97,Socket programming with TCP,Client must contact server server process must fi

52、rst be running server must have created socket (door) that welcomes clients contact Client contacts server by: creating client-local TCP socket specifying IP address, port number of server process When client creates socket: client TCP establishes connection to server TCP,When contacted by client, s

53、erver TCP creates new socket for server process to communicate with client allows server to talk with multiple clients source port numbers used to distinguish clients (more in Chap 3),2: Application Layer,98,Client/server socket interaction: TCP,Server (running on hostid),Client,2: Application Layer

54、,99,Client process,client TCP socket,Stream jargon,A stream is a sequence of characters that flow into or out of a process. An input stream is attached to some input source for the process, e.g., keyboard or socket. An output stream is attached to an output source, e.g., monitor or socket.,2: Applic

55、ation Layer,100,Socket programming with TCP,Example client-server app: 1) client reads line from standard input (inFromUser stream) , sends to server via socket (outToServer stream) 2) server reads line from socket 3) server converts line to uppercase, sends back to client 4) client reads, prints mo

56、dified line from socket (inFromServer stream),2: Application Layer,101,Example: Java client (TCP),import java.io.*; import .*; class TCPClient public static void main(String argv) throws Exception String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStrea

57、mReader(System.in); Socket clientSocket = new Socket(hostname, 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream();,Create input stream,Create client socket, connect to server,Create output stream attached to socket,2: Application Layer,102,Example: Java client

58、(TCP), cont.,BufferedReader inFromServer = new BufferedReader(new InputStreamReader(clientSocket.getInputStream(); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + n); modifiedSentence = inFromServer.readLine(); System.out.println(FROM SERVER: + modifiedSentence); clientSocket.close(); ,Create input stream attached to socket,Send line to server,Read line from server,2: Application Layer,103,Example: Java server (TCP),import java.io.*; import .*; class TCPServer public

温馨提示

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

评论

0/150

提交评论