Application Layer e-mailwebinstant messagingremote loginP2P file sharingmulti-user networkgamesstreaming stored video(YouTube)Creating a network app applicationtransportnetworkdata linkphysicalWrite programs thatvoice over IPreal-time videoconferencingcloud computing run on (different) endsystems communicate over network e.g., web server - browserNo need to write softwarefor network-core devices applicationtransportnetworkdata linkphysicalApplication 2-1Client-server architecture Application 2-2Pure P2P architectureserver: always-on permanent IP address server farms tnetworkdata linkphysicalcommunicate with servernot always connecteddynamic IP addressesdo not communicatedirectly with each other no always-on serverend systems directlycommunicatepeer-peerpeers are not alwaysconnected and change IPaddressesApplication 2-3Hybrid of client-server and P2PSkype voice-over-IP P2P application server: finding address of remote party client-client speech: directApplication 2-4Processes communicatingprocess: program runningwithin a host. processes communicateby exchanging messagesApplication 2-5client process: processthat initiatescommunicationserver process: processthat waits to becontactedApplication 2-61

Sockets process sends/receivesmessages to/from itssocketsocket analogous to doorAddressing processeshost orserverhost orserverprocess controlled byapp developerprocessa process must have anidentifierhost device has uniqueIP address socketsocketTCP withbuffers,variablesInternetidentifier includes bothIP address and portnumbers associated withprocess on host.example port numbers: HTTP server: 80 Mail server: 25TCP withbuffers,variables controlledby OSto send HTTP messageto gaia.cs.umass.edu webserver: IP address: Port number: 80Application 2-7What transport service does an app need?App-layer protocol defines types of messages message syntax: message semantics e.g., request, response what fields in messages meaning of information infields Application 2-8public-domain protocols: defined in RFCse.g., HTTP, SMTPproprietary protocols: e.g., Skyperules for when and howprocesses send &respond to messagesData loss some apps (e.g., audio) cantolerate some loss other apps (e.g., filetransfer) require 100%reliable data transferTiming some apps (e.g.,Internet telephony,interactive games)require low delayThroughput some apps (e.g.,multimedia) requireminimum amount ofthroughput to be“effective” other apps (“elastic apps”)make use of whateverthroughput they get Application 2-9Web and HTTPInternet transport protocols servicesTCP service: connection-oriented: setuprequired between client andserver processesreliable transportflow controlcongestion controldoes not provide: timing,minimum throughputguaranteesApplication 2-10UDP service: unreliable data transferbetween sending andreceiving process web page consists of objectsobject can be HTML file, JPEG image, audio file, web page consists of base HTML-file withreferenced objectseach object is addressable by a URLexample URL:www.someschool.edu/someDept/pic.gifhost nameApplication 2-11path nameApplication 2-122

HTTP overviewHTTP overviewHTTP: hypertexttransfer protocolUses TCP: Web’s application layerprotocolclient/server model client: browser server: Web server PC runningExplorer ServerrunningwebserverMac runningChrome HTTP is “stateless”client initiates TCPconnection (creates socket)to server, port 80server accepts TCPconnection from clientHTTP messages (applicationlayer protocol messages)exchanged between browser(HTTP client) and Webserver (HTTP server)TCP connection closed server maintains noinformation aboutpast client requestsprotocols that maintain“state” are complex! past history (state) mustbe maintained if server/client crashes,their views of “state” maybe inconsistentApplication 2-13HTTP connectionsnon-persistent HTTP at most one objectsent over TCPconnection.Application 2-14HTTP request messagepersistent HTTP multiple objects canbe sent over singleTCP connectionbetween client, server. two types of HTTP messages: request, responseHTTP request message: ASCII (human-readable format)request line(GET, POST,HEAD commands)headerlinescarriage return,line feed at startof line indicatesend of header linescarriage return characterline-feed characterGET /index.html HTTP/1.1\r\nHost: www-net.cs.umass.edu\r\nUser-Agent: Firefox/3.6.10\r\nAccept: text/html,application/xhtml xml\r\nAccept-Language: en-us,en;q 0.5\r\nAccept-Encoding: gzip,deflate\r\nAccept-Charset: ISO-8859-1,utf-8;q 0.7\r\nKeep-Alive: 115\r\nConnection: keep-alive\r\n\r\nApplication 2-15HTTP response messagestatus line(protocolstatus codestatus phrase)headerlinesdata, e.g.,requestedHTML fileApplication 2-16HTTP response status codes HTTP/1.1 200 OK\r\nDate: Sun, 26 Sep 2010 20:09:20 GMT\r\nServer: Apache/2.0.52 (CentOS)\r\nLast-Modified: Tue, 30 Oct 2007 17:00:02GMT\r\nETag: "17dc6-a5c-bf716880"\r\nAccept-Ranges: bytes\r\nContent-Length: 2652\r\nKeep-Alive: timeout 10, max 100\r\nConnection: Keep-Alive\r\nContent-Type: text/html; charset ISO-88591\r\n\r\ndata data data data data . status code appears in 1st line in server- clientresponse message.some sample codes:200 OK request succeeded, requested object later in this msg301 Moved Permanently requested object moved, new location specified later in thismsg (Location:)400 Bad Request request msg not understood by server404 Not Found requested document not found on this server505 HTTP Version Not SupportedApplication 2-17Application 2-183

Cookies: keeping “state” (cont.)User-server state: cookiesexample: Susan always accessInternet from PC visits specific e1) cookie header line ofHTTP response messagecommerce site for first2) cookie header line intimeHTTP request message when initial HTTP3) cookie file kept onuser’s host, managed byrequests arrives at site,user’s browsersite creates:4) back-end database at unique IDWeb site entry in backenddatabase for IDclientmany Web sites usecookiesfour components:ebay 8734cookie fileebay 8734amazon 1678serverusual http request msgAmazon servercreates ID1678 for user createusual http responseSet-cookie: 1678entryusual http request msgcookie: 1678one week later:usual http response msgcookiespecificactionaccessaccessebay 8734amazon 1678usual http request msgcookie: 1678usual http response msgcookiespecificactionApplication 2-19Application 2-20More about Web cachingWeb caches (proxy server)Goal: satisfy client request without involving origin server user sets browser:Web accesses viacachebrowser sends allHTTP requests tocache object in cache: cachereturns object else cache requestsobject from originserver, then returnsobject to client originserverclient Proxyserverclientcache acts as bothclient and servertypically cache isinstalled by ISP(university, company,residential ISP)why Web caching? reduce response timefor client request reduce traffic on aninstitution’s accesslinkoriginserverApplication 2-21 Goal: don’t send object ifcache has up-to-datecached versioncache: specify date ofcached copy in HTTPrequestserver: response containsno object if cached copy isup-to-date:Application 2-22EmailConditional GET backenddatabaseservercacheHTTP request msgIf-modified-since: date HTTP responseHTTP/1.0304 Not ModifiedHTTP request msgIf-modified-since: date HTTP responseHTTP/1.0 200 OK data objectmodifiedafter date Application 2-23user mailboxThree major components: objectnotmodifiedbefore date outgoingmessage queue user agentsmail serverssimple mail transferprotocol: SMTPUser Agent “mail reader” composing, editing, readingmail messages e.g., Outlook, elm, MozillaThunderbird, iPhone mailclient outgoing, incoming messagesstored on ntApplication 2-244

Mail serversSMTPuseragentMail Servers mailbox contains incomingmessages for usermessage queue of outgoing(to be sent) mail messagesSMTP protocol between mailservers to send emailmessages client: sending mailserver “server”: receiving mailserver mailserver useragentuseragent uses TCP to reliably transfer email message from clientto server, port 25direct transfer: sending server to receiving serverthree phases of transfer handshaking (greeting) transfer of messages closurecommand/response interaction commands: ASCII text response: status code and phraseuseragentApplication 2-25Mail access protocolsMail message formatSMTP: protocol forexchanging email msgsRFC 822: standard for textmessage format: header lines, e.g., To: From: Subject: Application 2-26headeruseragentblanklineSMTPsender’s mailserver bodySMTP body the “message”accessprotocolreceiver’s mailserverSMTP: delivery/storage to receiver’s servermail access protocol: retrieval from server POP: Post Office Protocol authorization (agent -- server) and download IMAP: Internet Mail Access Protocol more features (more complex) manipulation of stored msgs on server HTTP: gmail, Hotmail, Yahoo! Mail, etc.Application 2-27 replicated Webservers: set of IPaddresses for onecanonical nameApplication 2-28Distributed, Hierarchical DatabaseDNSDNS services hostname to IPaddress translation load distributionuseragentWhy not centralize DNS? single point of failure traffic volume distant centralizeddatabase maintenanceRoot DNS Serverscom DNS serversyahoo.comamazon.comDNS servers DNS serversorg DNS serverspbs.orgDNS serversedu DNS serverspoly.eduumass.eduDNS serversDNS serversclient wants IP for www.amazon.com:doesn’t scale! Application 2-29client queries a root server to find com DNS serverclient queries com DNS server to get amazon.com DNS serverclient queries amazon.com DNS server to get IP address forwww.amazon.comApplication 2-305

TLD and Authoritative ServersDNS: Root name serversTop-level domain (TLD) servers:a Verisign, Dulles, VAc Cogent, Herndon, VA (also LA)d U Maryland College Park, MDg US DoD Vienna, VAh ARL Aberdeen, MD responsible for com, org, net, edu, aero, jobs,museums, and all top-level country domains, e.g.:uk, fr, ca, jpk RIPE London (also 16 other locations)i Autonomica, Stockholm (plus28 other locations)m WIDE Tokyo (also Seoul,Paris, SF)j Verisign, ( 21 locations)e NASA Mt View, CAf Internet Software C. Palo Alto,Authoritative DNS servers:CA (and 36 other locations) organization’s DNS servers, hostname to IPmappings for organization’s servers can be maintained by organization or serviceprovider13 root nameservers worldwideb USC-ISI Marina del Rey, CAl ICANN Los Angeles, CAApplication 2-31DNS nameresolution example iterated query: contacted serverreplies with name ofserver to contact“I don’t know thisname, but ask thisserver”DNS nameresolution exampleroot DNS server2host at cis.poly.eduwants IP address forgaia.cs.umass.edu34Application 2-32TLD DNS serverrecursive query: 5local DNS serverdns.poly.edu182puts burden of nameresolution oncontacted nameserverTLD DNS server5dns.poly.edu1requesting host367local DNS server67root DNS server8authoritative DNS serverdns.cs.umass.educis.poly.edu4requesting hostauthoritative DNS ugaia.cs.umass.eduApplication 2-33DNS: caching and updating records once (any) name server learns mapping, it cachesmapping cache entries timeout (disappear) after sometime TLD servers typically cached in local nameserversApplication 2-34Pure P2P architecture no always-on serverarbitrary end systemsdirectly communicatepeers are intermittently peer-peerconnected and change IPaddresses Thus root name servers not often visitedApplication 2-35Application 2-366

Server-client vs. P2P: exampleFile Distribution: Server-Client vs P2PQuestion : How much time to distribute filefrom one server to N peers?Minimum Distribution Timeus: server uploadbandwidthServeru1usFile, size F3.5dNui: peer i uploadbandwidthu2d1d2di: peer i downloadbandwidth2.521.510.50Network (withabundant ation 2-37File distribution: BitTorrentApplication 2-38BitTorrentP2P file distributiontracker: tracks peersparticipating in torrenttorrent: group ofpeers exchangingchunks of a fileobtain listof peers tradingchunks peerfile 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 otherpeers.peers may come and goonce peer has entire file, it may (selfishly) leave or(altruistically) remainApplication 2-39BitTorrentPulling Chunks at any given time,different peers havedifferent subsets offile chunks periodically, a peer(Alice) asks eachneighbor for list ofchunks that they have. Alice sends requestsfor her missing chunksApplication 2-40P2P example: SkypeSending Chunks: tit-for-tat Alice sends chunks to fourneighbors currentlysending her chunks at thehighest rate re-evaluate top 4 every 10secs every 30 secs: randomlyselect another peer,starts sending chunks pairs of ogin serverprotocolIndex maps usernamesto IP addressesSkype clients (SC)Supernode(SN) newly chosen peer may jointop 4 rarest firstApplication 2-41Application 2-427

DNS servers pbs.org . 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) Application 2-31 TLD and Authoritative Servers Top-level domain (TLD) servers: responsible for com, org, net, edu, aero, jobs,