professional documents
home
Upload
docsters
Upload
2: Application Layer1Chapter 2Application LayerComputer Networking: A Top Down Approach, 4thedition. Jim Kurose, Keith RossAddison-Wesley, July 2007. A note on the use of these ppt slides:We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lotof work on our part. In return for use, we only ask the following:If you use these slides (e.g., in a class) in substantially unaltered form, that you mention their source (after all, we’d like people to use our book!)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 copyright 1996-2007J.F Kurose and K.W. Ross, All Rights Reserved2: Application Layer2Chapter 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 Socket programming with TCP2.8 Socket programming with UDP2: Application Layer3Chapter 2: Application LayerOur goals:conceptual, implementation aspects of network application protocolstransport-layer service modelsclient-server paradigmpeer-to-peer paradigmlearn about protocols by examining popular application-level protocolsHTTPFTPSMTP /POP3 /IMAPDNSprogramming network applicationssocket API2: Application Layer4Some 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 conferencinggrid computing2: Application Layer5Creating a network appwrite programs thatrun on (different) end systemscommunicate over networke.g., web server software communicates with browser softwarelittle software written for devices in network corenetwork core devices do not run user applications applications on end systems allows for rapid app development, propagationapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysicalapplicationtransportnetworkdata linkphysical2: Application Layer6Chapter 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2.8 Socket programming with UDP2.9 Building a Web server2: Application Layer7Application architecturesClient-serverPeer-to-peer (P2P)Hybrid of client-server and P2P2: Application Layer8Client-server architectureserver:always-on hostpermanent IP addressserver farms for scalingclients:communicate with servermay be intermittently connectedmay have dynamic IP addressesdo not communicate directly with each otherclient/server2: Application Layer9Pure P2P architecturenoalways-on serverarbitrary end systems directly communicatepeers are intermittently connected and change IP addressesexample: GnutellaHighly scalable but difficult to managepeer-peer2: Application Layer10Hybrid of client-server and P2PSkypevoice-over-IP P2P applicationcentralized server: finding address of remote party: client-client connection: direct (not through server) Instant messagingchatting between 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 buddies2: Application Layer11Processes communicatingProcess:program running within a host.within same host, two processes communicate using inter-process communication(defined by OS).processes in different hosts communicate by exchanging messagesClient process:process that initiates communicationServer process:process that waits to be contactedNote: applications with P2P architectures have client processes & server processes2: Application Layer12Socketsprocess sends/receives messages to/from its socketsocket analogous to doorsending process shoves message out doorsending process relies on transport infrastructure on other side of door which brings message to socket at receiving processprocessTCP withbuffers,variablessockethost orserverprocessTCP withbuffers,variablessockethost orserverInternetcontrolledby OScontrolled byapp developerAPI: (1) choice of transport protocol; (2) ability to fix a few parameters (lots more on this later)2: Application Layer13Addressing 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?2: Application Layer14Addressing 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, manyprocesses can be running on same hostidentifierincludes both IP addressand port numbersassociated with process on host.Example port numbers:HTTP server: 80Mail server: 25to send HTTP message to gaia.cs.umass.edu web server:IP address:128.119.245.12Port number:80more shortly…2: Application Layer15App-layer protocol definesTypes of messages exchanged, e.g., request, response Message syntax:what fields in messages & how fields are delineatedMessage semantics meaning of information in fieldsRules for when and how processes send & respond to messagesPublic-domain protocols:defined in RFCsallows for interoperabilitye.g., HTTP, SMTPProprietary protocols:e.g., Skype2: Application Layer16What 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 transferTimingsome apps (e.g., Internet telephony, interactive games) require low delay to be “effective”Bandwidthsome apps (e.g., multimedia) require minimum amount of bandwidth to be “effective”other apps (“elastic 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-tolerantno lossBandwidthelasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelasticTime Sensitivenononoyes, 100’s msecyes, few secsyes, 100’s msecyes and no2: Application Layer18Internet transport protocols servicesTCP service:connection-oriented:setup required between client and server processesreliable transport between sending and receiving processflow control:sender won’t overwhelm receiver congestion control:throttle sender when network overloadeddoes not provide:timing, minimum bandwidth guaranteesUDP service:unreliable data transfer between sending and receiving processdoes 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 transferstreaming multimediaInternet telephonyApplicationlayer protocolSMTP [RFC 2821]Telnet [RFC 854]HTTP [RFC 2616]FTP [RFC 959]proprietary(e.g. RealNetworks)proprietary(e.g., Vonage,Dialpad)Underlyingtransport protocolTCPTCPTCPTCPTCP or UDPtypically UDP2: Application Layer20Chapter 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 UDP2: Application Layer21Web and HTTPFirst some jargonWeb pageconsists of objectsObject can be HTML file, JPEG image, Java applet, audio file,…Web page consists of base HTML-filewhich includes several referenced objectsEach object is addressable by a URLExample URL:www.someschool.edu/someDept/pic.gifhost namepath name2: Application Layer22HTTP 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 2068PC runningExplorerServer runningApache WebserverMac runningNavigatorHTTP requestHTTP responseHTTP response2: Application Layer23HTTP 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 closedHTTP is “stateless”server maintains no information about past client requestsProtocols that maintain “state” are complex!past history (state) must be maintainedif server/client crashes, their views of “state” may be inconsistent, must be reconciledaside2: Application Layer24HTTP connectionsNonpersistent HTTPAt most one object is sent over a TCP connection.HTTP/1.0 uses nonpersistent HTTPPersistent HTTPMultiple objects can be sent over single TCP connection between client and server.HTTP/1.1 uses persistent connections in default mode2: Application Layer25Nonpersistent HTTPSuppose user enters URL www.someSchool.edu/someDepartment/home.index1a.HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 802.HTTPclient sends HTTP request message(containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index1b.HTTPserver at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client3.HTTPserver receives request message, forms response messagecontaining 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. Parsing html file, finds 10 referenced jpeg objects6.Steps 1-5 repeated for each of 10 jpeg objects4.HTTPserver 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:one RTT to initiate TCP connectionone RTT for HTTP request and first few bytes of HTTP response to returnfile transmission timetotal = 2RTT+transmit timetime to transmit fileinitiate TCPconnectionRTTrequestfileRTTfilereceivedtimetime2: Application Layer28Persistent HTTPNonpersistent HTTP issues:requires 2 RTTs per objectOS overhead for eachTCP connectionbrowsers often open parallel TCP connections to fetch referenced objectsPersistent HTTPserver leaves connection open after sending responsesubsequent HTTP messages between same client/server sent over open connectionPersistent withoutpipelining:client issues new request only when previous response has been receivedone RTT for each referenced objectPersistent withpipelining:default in HTTP/1.1client sends requests as soon as it encounters a referenced objectas little as one RTT for all the referenced objects2: Application Layer29HTTP 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)headerlinesCarriage return, line feed indicates end of message2: Application Layer30HTTP request message: general format2: Application Layer31Uploading form inputPost method:Web page often includes form inputInput is uploaded to server in entity bodyURL method:Uses GET methodInput is uploaded in URL field of request line:www.somesite.com/animalsearch?monkeys&banana2: Application Layer32Method typesHTTP/1.0GETPOSTHEADasks server to leave requested object out of responseHTTP/1.1GET, POST, HEADPUTuploads file in entity body to path specified in URL fieldDELETEdeletes file specified in the URL field2: Application Layer33HTTP response messageHTTP/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/htmldata data data data data ... status line(protocolstatus codestatus phrase)headerlinesdata, e.g., requestedHTML file2: Application Layer34HTTP response status codes200 OKrequest succeeded, requested object later in this message301 Moved Permanentlyrequested object moved, new location specified later in this message (Location:)400 Bad Requestrequest message not understood by server404 Not Foundrequested document not found on this server505 HTTP Version Not SupportedIn first line in server->client response message.A few sample codes:2: Application Layer35Trying out HTTP (client side) for yourself1. Telnet to your favorite Web server:Opens TCP connection to port 80(default HTTP server port) at cis.poly.edu.Anything typed in sent to port 80 at cis.poly.edutelnet cis.poly.edu 802. Type in a GET HTTP request:GET /~ross/HTTP/1.1Host: cis.poly.eduBy typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server3. Look at response message sent by HTTP server!2: Application Layer36Let’s look at HTTP in actiontelnet exampleEthereal example2: Application Layer37User-server state: cookiesMany major Web sites use cookiesFour components:1) cookie header line of HTTP responsemessage2) cookie header line in HTTP requestmessage3) cookie file kept on user’s host, managed by user’s browser4) back-end database at Web siteExample:Susan always access Internet always from PCvisits specific e-commerce site for first timewhen initial HTTP requests arrives at site, site creates: unique IDentry in backend database for ID2: Application Layer38Cookies: keeping “state” (cont.)clientserverusual http response msgusual http response msgcookie fileone week later:usual http request msgcookie: 1678cookie-specificactionaccessebay 8734usual http request msgAmazon servercreates ID1678 for usercreateentryusual http response Set-cookie: 1678 ebay 8734amazon 1678usual http request msgcookie: 1678cookie-spectificactionaccessebay 8734amazon 1678backenddatabase2: Application Layer39Cookies (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 sitesasideHow to keep “state”:protocol endpoints: maintain state at sender/receiver over multiple transactionscookies: http messages carry state2: Application Layer40Web caches (proxy server)user sets browser: Web accesses via cachebrowser sends all HTTP requests to cacheobject in cache: cache returns object else cache requests object from origin server, then returns object to clientGoal:satisfy client request without involving origin serverclientProxyserverclientHTTP requestHTTP responseHTTP requestorigin serverorigin serverHTTP response2: Application Layer41More about Web cachingcache acts as both client and servertypically cache is installed by ISP (university, company, residential ISP)Why Web caching?reduce response time for client requestreduce traffic on an institution’s access link.Internet dense with caches: enables “poor” content providers to effectively deliver content (but so does P2P file sharing)2: Application Layer42Caching example Assumptionsaverage object size = 100,000 bitsavg. request rate from institution’s browsers to origin servers = 15/secdelay from institutional router to any origin server and back to router = 2 secConsequencesutilization on LAN = 15%utilization on access link = 100%total delay = Internet delay + access delay + LAN delay= 2 sec + minutes + millisecondsoriginserverspublicInternetinstitutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer43Caching example (cont)possible solutionincrease bandwidth of access link to, say, 10 Mbpsconsequenceutilization on LAN = 15%utilization on access link = 15%Total delay = Internet delay + access delay + LAN delay= 2 sec + msecs + msecsoften a costly upgradeoriginserverspublicInternetinstitutionalnetwork10 Mbps LAN10 Mbps access linkinstitutionalcache2: Application Layer44Caching example (cont)possible solution: install cachesuppose hit rate is 0.4consequence40% requests will be satisfied almost immediately60% requests satisfied by origin serverutilization of access link reduced to 60%, resulting in negligible delays (say 10 msec)total avg delay = Internet delay + access delay + LAN delay = .6*(2.01) secs + .4*milliseconds < 1.4 secsoriginserverspublicInternetinstitutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer45Conditional GETGoal:don’t send object if cache has up-to-date cached versioncache: specify date of cached copy in HTTP requestIf-modified-since: server: 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 modified2: Application Layer46Chapter 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2.8 Socket programming with UDP2.9 Building a Web server2: Application Layer47FTP: the file transfer protocoltransfer file to/from remote hostclient/server modelclient:side that initiates transfer (either to/from remote)server:remote hostftp: RFC 959ftp server: port 21file transferFTPserverFTPuserinterfaceFTPclientlocal filesystemremote filesystemuser at host2: Application Layer48FTP: separate control, data connectionsFTP client contacts FTP server at port 21, TCP is transport protocolclient authorized over control connectionclient browses remote directory by sending commands over control connection.when server receives file transfer command, server opens 2ndTCP connection (for file) to clientafter transferring one file, server closes data connection.FTPclientFTPserverTCP control connectionport 21TCP data connectionport 20server opens another TCP data connection to transfer another file.control connection: “out of band”FTP server maintains “state”: current directory, earlier authentication2: Application Layer49FTP commands, responsesSample commands:sent as ASCII text over control channelUSER usernamePASS passwordLISTreturn list of file in current directoryRETR filenameretrieves (gets) fileSTOR filenamestores (puts) file onto remote hostSample return codesstatus code and phrase (as in HTTP)331 Username OK, password required125 data connection already open; transfer starting425 Can’t open data connection452 Error writing file2: Application Layer50Chapter 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2.8 Socket programming with UDP2.9 Building a Web server2: Application Layer51Electronic MailThree major components:user agents mail servers simple mail transfer protocol: SMTPUser Agenta.k.a. “mail reader”composing, editing, reading mail messagese.g., Eudora, Outlook, elm, Mozilla Thunderbirdoutgoing, incoming messages stored on serveruser mailboxoutgoing message queuemailserveruseragentuseragentuseragentmailserveruseragentuseragentmailserveruseragentSMTPSMTPSMTP2: Application Layer52Electronic Mail: mail serversMail Serversmailboxcontains incoming messages for usermessagequeueof outgoing (to be sent) mail messagesSMTP protocolbetween mail servers to send email messagesclient: sending mail server“server”: receiving mail servermailserveruseragentuseragentuseragentmailserveruseragentuseragentmailserveruseragentSMTPSMTPSMTP2: Application Layer53Electronic 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 ASCII2: Application Layer54Scenario: Alice sends message to Bob1) Alice uses UA to compose message and “to” bob@someschool.edu2) 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 messageuseragentmailservermailserveruseragent1234562: Application Layer55Sample SMTP interactionS: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: S: 250 alice@crepes.fr... Sender ok C: RCPT TO: S: 250 bob@hamburger.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 hamburger.edu closing connection2: Application Layer56Try SMTP interaction for yourself:telnet servername 25see 220 reply from serverenter HELO, MAIL FROM, RCPT TO, DATA, QUIT commandsabove lets you send email without using email client (reader)2: Application Layer57SMTP: final wordsSMTP uses persistent connectionsSMTP requires message (header & body) to be in 7-bit ASCIISMTP server uses CRLF.CRLFto determine end of messageComparison with HTTP:HTTP: pullSMTP: pushboth have ASCII command/response interaction, status codesHTTP: each object encapsulated in its own response msgSMTP: multiple objects sent in multipart msg2: Application Layer58Mail message formatSMTP: protocol for exchanging email msgsRFC 822: standard for text message format:header lines, e.g.,To:From:Subject:differentfrom SMTP commands!bodythe “message”, ASCII characters onlyheaderbodyblankline2: Application Layer59Message format: multimedia extensionsMIME: multimedia mail extension, RFC 2045, 2056additional lines in msg header declare MIME content typeFrom: alice@crepes.fr To: bob@hamburger.edu 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 declarationmethod usedto encode dataMIME versionencoded data2: Application Layer60Mail 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.useragentsender’s mail serveruseragentSMTPSMTPaccessprotocolreceiver’s mail server2: Application Layer61POP3 protocolauthorization phaseclient commands: user:declare usernamepass:passwordserver responses+OK-ERRtransaction phase, client:list:list message numbersretr:retrieve message by numberdele:deletequitC: list S: 1 498 S: 2 912 S: . C: retr 1 S: S: . C: dele 1 C: retr 2 S: S: . C: dele 2 C: quit S: +OK POP3 server signing offS: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OKuser successfully logged on2: Application Layer62POP3 (more) and IMAPMore 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 name2: Application Layer63Chapter 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2.8 Socket programming with UDP2.9 Building a Web server2: Application Layer64DNS: Domain Name SystemPeople:many identifiers:SSN, name, passport #Internet hosts, routers:IP address (32 bit) -used for addressing datagrams“name”, e.g., ww.yahoo.com -used by humansQ:map between IP addresses and name ?Domain Name System:distributed databaseimplemented in hierarchy of many name serversapplication-layer protocolhost, routers, name servers to communicate to resolvenames (address/name translation)note: core Internet function, implemented as application-layer protocolcomplexity at network’s “edge”2: Application Layer65DNS Why not centralize DNS?single point of failuretraffic volumedistant centralized databasemaintenancedoesn’t scale!DNS serviceshostname to IP address translationhost aliasingCanonical, alias namesmail server aliasingload distributionreplicated Web servers: set of IP addresses for one canonical name2: Application Layer66Root DNS Serverscom DNS serversorg DNS serversedu DNS serverspoly.eduDNS serversumass.eduDNS serversyahoo.comDNS serversamazon.comDNS serverspbs.orgDNS serversDistributed, Hierarchical DatabaseClient wants IP for www.amazon.com; 1stapprox: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.com2: Application Layer67DNS: 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 server13 root name servers worldwideb USC-ISI Marina del Rey, CAl ICANN Los Angeles, CAe NASA Mt View, CAf Internet Software C. PaloAlto, 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)2: Application Layer68TLD 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 provider2: Application Layer69Local 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 hierarchy2: Application Layer70requesting hostcis.poly.edugaia.cs.umass.eduroot DNS serverlocal DNS serverdns.poly.edu123456authoritative DNS serverdns.cs.umass.edu78TLD DNS serverDNS name resolution exampleHost at cis.poly.edu wants IP address for gaia.cs.umass.eduiterated query:contacted server replies with name of server to contact“I don’t know this name, but ask this server”2: Application Layer71requesting hostcis.poly.edugaia.cs.umass.eduroot DNS serverlocal DNS serverdns.poly.edu12456authoritative DNS serverdns.cs.umass.edu78TLD DNS server3recursive query:puts burden of name resolution on contacted name serverheavy load?DNS name resolution example2: Application Layer72DNS: caching and updating recordsonce (any) name server learns mapping, it cachesmapping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.html2: Application Layer73DNS recordsDNS:distributed db storing resource records (RR)Type=NSnameis domain (e.g. foo.com)valueis hostname of authoritative name server for this domainRR format: (name, value, type, ttl)Type=Anameis hostnamevalueis IP addressType=CNAMEnameis alias name for some “canonical” (the real) namewww.ibm.com is reallyservereast.backup2.ibm.comvalueis canonical nameType=MXvalueis name of mailserver associated with name2: Application Layer74DNS protocol, messagesDNS protocol :queryand replymessages, both with same message formatmsg headeridentification:16 bit # for query, reply to query uses same #flags:query or replyrecursion desired recursion availablereply is authoritative2: Application Layer75DNS protocol, messagesName, type fieldsfor a queryRRs in responseto queryrecords forauthoritative serversadditional “helpful”info that may be used2: Application Layer76Inserting records into DNSexample: new startup “Network Utopia”register name networkuptopia.com at DNS registrar(e.g., Network Solutions)provide names, IP addresses of authoritative name server (primary and secondary)registrar inserts two RRs into com TLD server:(networkutopia.com, dns1.networkutopia.com, NS)(dns1.networkutopia.com, 212.212.212.1, A)create authoritative server Type A record for www.networkuptopia.com; Type MX record for networkutopia.comHow do people get IP address of your Web site?2: Application Layer77Chapter 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 server2: Application Layer78P2P file sharingExample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 Bob’s PC to Alice’s notebook: HTTPwhile Alice downloads, other users uploading from Alice.Alice’s peer is both a Web client and a transient Web server.All peers are servers = highly scalable!2: Application Layer79P2P: centralized directoryoriginal “Napster” design1) when peer connects, it informs central server:IP addresscontent2) Alice queries for “Hey Jude”3) Alice requests file from Bobcentralizeddirectory serverpeersAliceBob1111232: Application Layer80P2P: problems with centralized directorysingle point of failureperformance bottleneckcopyright infringement: “target” of lawsuit is obviousfile transfer is decentralized, but locating content is highly centralized2: Application Layer81Query flooding: Gnutellafully distributedno central serverpublic domain protocolmany Gnutella clients implementing protocoloverlay network: graphedge between peer X and Y if there’s a TCP connectionall active peers and edges form overlay netedge: virtual (notphysical) linkgiven peer typically connected with < 10 overlay neighbors2: Application Layer82Gnutella: protocolQueryQueryHitQueryQueryQueryHitQueryQueryQueryHitFile transfer:HTTPQuery messagesent over existing TCPconnectionspeers forwardQuery messageQueryHit sent over reversepathScalability:limited scopeflooding2: Application Layer83Gnutella: Peer joining1.joining peer Alice must find another peer in Gnutella network: use list of candidate peers2.Alice sequentially attempts TCP connections with candidate peers until connection setup with Bob3.Flooding:Alice sends Ping message to Bob; Bob forwards Ping message to his overlay neighbors (who then forward to their neighbors….)peers receiving Ping message respond to Alice with Pong message4.Alice receives many Pong messages, and can then setup additional TCP connectionsPeer leaving: see homework problem!2: Application Layer84Hierarchical Overlaybetween centralized index, query flooding approacheseach peer is either a group leaderor 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 childrenordinary peergroup-leader peerneighoring relationshipsin overlay network2: Application Layer85Comparing Client-server, P2P architecturesQuestion: How much time distribute file initially at one server to N other computers?usu2d1d2u1uNdNServerNetwork (with abundant bandwidth)File, size Fus:server upload bandwidthui:client/peer i upload bandwidthdi:client/peer i download bandwidth2: Application Layer86Client-server: file distribution timeusu2d1d2u1uNdNServerNetwork (with abundant bandwidth)Fserver sequentially sends N copies:NF/ustime client i takes F/di time to downloadincreases linearly in N(for large N)= dcs= max {NF/us, F/min(di)}iTime to distribute Fto Nclients using client/server approach 2: Application Layer87P2P: file distribution timeusu2d1d2u1uNdNServerNetwork (with abundant bandwidth)Fserver must send one copy: F/ustime client i takes F/di time to downloadNF bits must be downloaded (aggregate)fastest possible upload rate (assuming all nodes sending file chunks to same peer): us+ Suii=1,NdP2P= max {F/us, F/min(di), NF/(us+ Sui) }ii=1,N2: Application Layer8800.511.522.533.505101520253035NMinimum Distribution TimeP2PClient-ServerComparing Client-server, P2P architectures2: Application Layer89P2P Case Study: BitTorrent tracker:tracks peers participating in torrenttorrent:group of peers exchanging chunks of a fileobtain listof peerstrading chunkspeerP2P file distribution2: Application Layer90BitTorrent (1)file divided into 256KB chunks.peer joining torrent: has no chunks, but will accumulate them over timeregisters 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) remain2: Application Layer91BitTorrent (2)Pulling Chunksat any given 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 firstSending Chunks: tit-for-tatAlice sends chunks to four neighbors currently sending her chunks 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 42: Application Layer92P2P Case study: SkypeP2P (pc-to-pc, pc-to-phone, phone-to-pc) Voice-Over-IP (VoIP) application also IMproprietary application-layer protocol (inferred via reverse engineering) hierarchical overlaySkype clients (SC)Supernode (SN)Skype login server2: Application Layer93Skype: making a callUser starts SkypeSkype login serverSC registers with SNlist of bootstrap SNsSC logs in (authenticate)Call: SC contacts SN will callee IDSN contacts other SNs (unknown protocol, maybe flooding) to find addr of callee; returns addr to SCSC directly contacts callee, overTCP2: Application Layer94Chapter 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2.8 Socket programming with UDP2: Application Layer95Socket programmingSocket 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 datagram reliable, byte stream-oriented a host-local, application-created, OS-controlledinterface (a “door”) into whichapplication process can both send and receivemessages to/from another application processsocketGoal:learn how to build client/server application that communicate using sockets2: Application Layer96Socket-programming using TCPSocket:a door between application process and end-end-transport protocol (UCP or TCP)TCP service:reliable transfer of bytesfrom one process to anotherprocessTCP withbuffers,variablessocketcontrolled byapplicationdevelopercontrolled byoperatingsystemhost orserverprocessTCP withbuffers,variablessocketcontrolled byapplicationdevelopercontrolled byoperatingsystemhost orserverinternet2: Application Layer97Socket programming with TCPClient must contact serverserver process must first be runningserver must have created socket (door) that welcomes client’s contactClient 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, server TCP creates new socketfor server process to communicate with clientallows server to talk with multiple clientssource port numbers used to distinguish clients (more in Chap 3)TCP provides reliable, in-ordertransfer of bytes (“pipe”) between client and serverapplication viewpoint2: Application Layer98Client/server socket interaction: TCPwait for incomingconnection requestconnectionSocket =welcomeSocket.accept()create socket,port=x, forincoming request:welcomeSocket = ServerSocket()create socket,connect to hostid, port=xclientSocket = Socket()closeconnectionSocketread reply fromclientSocketcloseclientSocketServer (running on hostid)Clientsend request usingclientSocketread request fromconnectionSocketwrite reply toconnectionSocketTCP connection setup2: Application Layer99outToServerto networkfrom networkinFromServerinFromUserkeyboardmonitorProcessclientSocketinputstreaminputstreamoutputstreamTCPsocketClientprocessclient TCP socketStream jargonA streamis a sequence of characters that flow into or out of a process.An input streamis attached to some input source for the process, e.g., keyboard or socket.An output streamis attached to an output source, e.g., monitor or socket.2: Application Layer100Socket programming with TCPExample client-server app:1) client reads line from standard input (inFromUserstream) , sends to server via socket (outToServerstream)2) server reads line from socket3) server converts line to uppercase, sends back to client4) client reads, prints modified line from socket (inFromServerstream)2: Application Layer101Example: Java client (TCP)import java.io.*; import java.net.*; class TCPClient { public static void main(String argv[]) throws Exception { String sentence; String modifiedSentence; BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); Socket clientSocket = new Socket("hostname", 6789); DataOutputStream outToServer = new DataOutputStream(clientSocket.getOutputStream());Createinput streamCreate client socket, connect to serverCreateoutput streamattached to socket2: Application Layer102Example: Java client (TCP), cont.BufferedReader inFromServer = new BufferedReader(newInputStreamReader(clientSocket.getInputStream())); sentence = inFromUser.readLine(); outToServer.writeBytes(sentence + '\n'); modifiedSentence = inFromServer.readLine(); System.out.println("FROM SERVER: " + modifiedSentence); clientSocket.close(); } }Createinput streamattached to socketSend lineto serverRead linefrom server2: Application Layer103Example: Java server (TCP)import java.io.*; import java.net.*; class TCPServer { public static void main(String argv[]) throws Exception { String clientSentence; String capitalizedSentence; ServerSocket welcomeSocket = new ServerSocket(6789); while(true) { Socket connectionSocket = welcomeSocket.accept(); BufferedReader inFromClient = new BufferedReader(newInputStreamReader(connectionSocket.getInputStream())); Createwelcoming socketat port 6789Wait, on welcomingsocket for contactby clientCreate inputstream, attached to socket2: Application Layer104Example: Java server (TCP), contDataOutputStream outToClient = new DataOutputStream(connectionSocket.getOutputStream());clientSentence = inFromClient.readLine(); capitalizedSentence = clientSentence.toUpperCase() + '\n'; outToClient.writeBytes(capitalizedSentence); } } }Read in linefrom socketCreate outputstream, attached to socketWrite out lineto socketEnd of while loop,loop back and wait foranother client connection2: Application Layer105Chapter 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2.8 Socket programming with UDP2.9 Building a Web server2: Application Layer106Socket programming with UDPUDP: no “connection” between client and serverno handshakingsender explicitly attaches IP address and port of destination to each packetserver must extract IP address, port of sender from received packetUDP: transmitted data may be received out of order, or lostapplication viewpointUDP provides unreliabletransferof groups of bytes (“datagrams”)between client and server2: Application Layer107Client/server socket interaction: UDPcloseclientSocketServer (running on hostid)read reply fromclientSocketcreate socket,clientSocket = DatagramSocket()ClientCreate, address (hostid, port=x,send datagram request using clientSocketcreate socket,port=x, forincoming request:serverSocket = DatagramSocket()read request fromserverSocketwrite reply toserverSocketspecifying clienthost address,port number2: Application Layer108Example: Java client (UDP)sendPacketto networkfrom networkreceivePacketinFromUserkeyboardmonitorProcessclientSocketUDPpacketinputstreamUDPpacketUDPsocketOutput: sends packet (recallthat TCP sent “byte stream”)Input: receives packet (recall thatTCP received “byte stream”)Clientprocessclient UDP socket2: Application Layer109Example: Java client (UDP)import java.io.*; import java.net.*; class UDPClient { public static void main(String args[]) throws Exception { BufferedReader inFromUser = new BufferedReader(new InputStreamReader(System.in)); DatagramSocket clientSocket = new DatagramSocket(); InetAddress IPAddress = InetAddress.getByName("hostname"); byte[] sendData = new byte[1024]; byte[] receiveData = new byte[1024]; String sentence = inFromUser.readLine(); sendData = sentence.getBytes();Createinput streamCreate client socketTranslatehostname to IP address using DNS2: Application Layer110Example: Java client (UDP), cont.DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, 9876); clientSocket.send(sendPacket); DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); clientSocket.receive(receivePacket); String modifiedSentence = new String(receivePacket.getData()); System.out.println("FROM SERVER:" + modifiedSentence); clientSocket.close(); } }Create datagram with data-to-send,length, IP addr, portSend datagramto serverRead datagramfrom server2: Application Layer111Example: Java server (UDP)import java.io.*; import java.net.*; class UDPServer { public static void main(String args[]) throws Exception { DatagramSocket serverSocket = new DatagramSocket(9876); byte[] receiveData = new byte[1024]; byte[] sendData = new byte[1024]; while(true) { DatagramPacket receivePacket = new DatagramPacket(receiveData, receiveData.length); serverSocket.receive(receivePacket);Createdatagram socketat port 9876Create space forreceived datagramReceivedatagram2: Application Layer112Example: Java server (UDP), contString sentence = new String(receivePacket.getData()); InetAddress IPAddress = receivePacket.getAddress(); int port = receivePacket.getPort(); String capitalizedSentence = sentence.toUpperCase(); sendData = capitalizedSentence.getBytes(); DatagramPacket sendPacket = new DatagramPacket(sendData, sendData.length, IPAddress, port); serverSocket.send(sendPacket); } } }Get IP addrport #, ofsenderWrite out datagramto socketEnd of while loop,loop back and wait foranother datagramCreate datagramto send to client2: Application Layer113Chapter 2: Summaryapplication architecturesclient-serverP2Phybridapplication service requirements:reliability, bandwidth, delayInternet transport service modelconnection-oriented, reliable: TCPunreliable, datagrams: UDPour study of network apps now complete!specific protocols:HTTPFTPSMTP, POP, IMAPDNSP2P: BitTorrent, Skypesocket programming2: Application Layer114Chapter 2: Summarytypical request/reply message exchange:client requests info or serviceserver responds with data, status codemessage formats:headers: fields giving info about datadata: info being communicatedMost importantly:learned about protocolsImportant themes: control vs. data msgsin-band, out-of-bandcentralized vs. decentralized stateless vs. statefulreliable vs. unreliable msg transfer “complexity at network edge”
flag this doc
324
43
not rated
0
2/29/2008
English
Preview

Computer Networking Chapter 9

MissPowerPoint 2/29/2008 | 280 | 40 | 0 | technology
Preview

Computer Networking Chapter 1

MissPowerPoint 2/29/2008 | 695 | 52 | 0 | technology
Preview

Computer Networking Multimedia Networking

MissPowerPoint 2/29/2008 | 293 | 37 | 0 | technology
Preview

Computer Networking Wireless and Mobile Networking

MissPowerPoint 2/29/2008 | 332 | 59 | 0 | technology
Preview

COMPUTER NETWORKING NETWORK SECURITY

MissPowerPoint 2/29/2008 | 442 | 70 | 0 | technology
Preview

COMPUTER NETWORKING NETWORK LAYER

MissPowerPoint 2/29/2008 | 281 | 39 | 0 | technology
Preview

Networking

BeunaventuraLongjas 9/9/2008 | 53 | 1 | 0 | business
Preview

Networking

itscooligotit 9/8/2008 | 54 | 2 | 0 | business
Preview

IP ADDRESSES CLASSLESS ADDRESSING

MissPowerPoint 2/29/2008 | 238 | 26 | 0 | technology
Preview

IP ADDRESSES CLASSFUL ADDRESSING

MissPowerPoint 2/29/2008 | 234 | 13 | 0 | technology
Preview

Connecting LANS Backbone Networks and Virtual Lans

MissPowerPoint 2/29/2008 | 129 | 7 | 0 | technology
Preview

Communications and Networking

jasonpatino 1/16/2008 | 302 | 12 | 0 | technology
Preview

Business Networking

MaryJeanMenintigar 9/10/2008 | 59 | 6 | 0 | business
Preview

Advantages of Networking in Business

BeunaventuraLongjas 8/29/2008 | 75 | 3 | 0 | business
Preview

2009 Mens and Womens Basketball NCAA Case Book

MissPowerPoint 10/11/2008 | 8 | 0 | 0 | BUZZ
Preview

NCAA Student Athlete Race Ethnicity 2008

MissPowerPoint 10/11/2008 | 6 | 0 | 0 | educational
Preview

NCAA Official Division I Records Book

MissPowerPoint 10/11/2008 | 5 | 0 | 0 | educational
Preview

NCAA Guide for the College Bound 2008 2009

MissPowerPoint 10/11/2008 | 7 | 0 | 0 | educational
Preview

Auburn Tradition History and Legend

MissPowerPoint 10/11/2008 | 6 | 0 | 0 | educational
Preview

NCAA Invests in Largest Officiating Management Organizations in Amateur Sports

MissPowerPoint 10/11/2008 | 2 | 0 | 0 | educational
Preview

NCAA 101 Transfer Guide

MissPowerPoint 10/11/2008 | 9 | 1 | 0 | educational
Preview

Florida Gators Season Bests 2008 Media Guide

MissPowerPoint 10/11/2008 | 9 | 0 | 0 | educational
Preview

Florida Gators Records v Opponents 2008 Media Guide

MissPowerPoint 10/11/2008 | 8 | 0 | 0 | educational
Preview

Florida Gators Roster 2008

MissPowerPoint 10/11/2008 | 12 | 0 | 0 | BUZZ
 
review this doc