chapter 2 v6.2

Upload: anas-nain

Post on 29-Oct-2015

28 views

Category:

Documents


2 download

TRANSCRIPT

  • Application Layer2-*Chapter 2 Application LayerComputer Networking: A Top Down Approach 6th edition Jim Kurose, Keith Ross Addison-Wesley March 2012A note on the use of these ppt slides:Were making these slides freely available to all (faculty, students, readers). Theyre in PowerPoint form so you see the animations; and can add, modify, and delete slides (including this one) and slide content to suit your needs. They obviously represent a lot of work on our part. In return for use, we only ask the following:

    If you use these slides (e.g., in a class) that you mention their source (after all, wed like people to use our book!)If you post any slides 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/KWR

    All material copyright 1996-2012 J.F Kurose and K.W. Ross, All Rights Reserved

    Application Layer

  • Application Layer2-*Chapter 2: outline2.1 principles of network applications2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*Chapter 2: application layerour goals: conceptual, implementation aspects of network application protocolstransport-layer service modelsclient-server paradigmpeer-to-peer paradigmlearn about protocols by examining popular application-level protocolsHTTPFTPSMTP / POP3 / IMAPDNScreating network applicationssocket API

    Application Layer

  • Application Layer2-*Some network appse-mailwebtext messagingremote loginP2P file sharingmulti-user network gamesstreaming stored video (YouTube, Hulu, Netflix)

    voice over IP (e.g., Skype)real-time video conferencingsocial networkingsearch

    Application Layer

  • Application Layer2-*Creating a network appwrite programs that:run on (different) end systemscommunicate over networke.g., web server software communicates with browser softwareno need to write software for network-core devicesnetwork-core devices do not run user applications applications on end systems allows for rapid app development, propagation

    Application Layer

  • Application Layer2-*Application architecturespossible structure of applications:client-serverpeer-to-peer (P2P)

    Application Layer

  • Application Layer2-*Client-server architectureserver: always-on hostpermanent IP addressdata centers for scalingclients:communicate with servermay be intermittently connectedmay have dynamic IP addressesdo not communicate directly with each otherclient/server

    Application Layer

  • Application Layer2-*P2P architectureno always-on serverarbitrary end systems directly communicatepeers request service from other peers, provide service in return to other peersself scalability new peers bring new service capacity, as well as new service demandspeers are intermittently connected and change IP addressescomplex management

    peer-peer

    Application Layer

  • Application Layer2-*Processes communicatingprocess: program running within a hostwithin 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

    aside: applications with P2P architectures have client processes & server processesclients, servers

    Application Layer

  • Application Layer2-*Socketsprocess sends/receives messages to/from its socketsocket analogous to doorsending process shoves message out doorsending process relies on transport infrastructure on other side of door to deliver message to socket at receiving processInternetcontrolledby OS

    controlled byapp developertransportapplicationphysicallinknetworkprocesstransportapplicationphysicallinknetworkprocesssocket

    Application Layer

  • Application Layer2-*Addressing processesto receive messages, process must have identifierhost device has unique 32-bit IP addressQ: does IP address of host on which process runs suffice for identifying the process?identifier includes both IP address and port numbers associated with process on host.example port numbers:HTTP server: 80mail server: 25to send HTTP message to gaia.cs.umass.edu web server:IP address: 128.119.245.12port number: 80more shortlyA: no, many processes can be running on same host

    Application Layer

  • Application Layer2-*App-layer protocol definestypes of messages exchanged, e.g., request, response message syntax:what fields in messages & how fields are delineatedmessage semantics meaning of information in fieldsrules for when and how processes send & respond to messagesopen protocols:defined in RFCsallows for interoperabilitye.g., HTTP, SMTPproprietary protocols:e.g., Skype

    Application Layer

  • Application Layer2-*What transport service does an app need?data integritysome apps (e.g., file transfer, web transactions) require 100% reliable data transfer other apps (e.g., audio) can tolerate some loss

    timingsome apps (e.g., Internet telephony, interactive games) require low delay to be effectivethroughputsome apps (e.g., multimedia) require minimum amount of throughput to be effectiveother apps (elastic apps) make use of whatever throughput they get securityencryption, data integrity,

    Application Layer

  • Application Layer2-*Transport service requirements: common appsapplication

    file transfere-mailWeb documentsreal-time audio/video

    stored audio/videointeractive gamestext messagingdata loss

    no lossno lossno lossloss-tolerant

    loss-tolerantloss-tolerantno lossthroughput

    elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelastictime sensitive

    nononoyes, 100s msec

    yes, few secsyes, 100s msecyes and no

    Application Layer

  • Application Layer2-*Internet transport protocols servicesTCP service:reliable transport between sending and receiving processflow control: sender wont overwhelm receiver congestion control: throttle sender when network overloadeddoes not provide: timing, minimum throughput guarantee, securityconnection-oriented: setup required between client and server processes

    UDP service:unreliable data transfer between sending and receiving processdoes not provide: reliability, flow control, congestion control, timing, throughput guarantee, security, orconnection setup,

    Q: why bother? Why is there a UDP?

    Application Layer

  • Application Layer2-*Internet apps: application, transport protocolsapplication

    e-mailremote terminal accessWeb file transferstreaming multimedia

    Internet telephony

    applicationlayer protocol

    SMTP [RFC 2821]Telnet [RFC 854]HTTP [RFC 2616]FTP [RFC 959]HTTP (e.g., YouTube), RTP [RFC 1889]SIP, RTP, proprietary(e.g., Skype)underlyingtransport protocol

    TCPTCPTCPTCPTCP or UDP

    TCP or UDP

    Application Layer

  • Securing TCPTCP & UDP no encryptioncleartext passwds sent into socket traverse Internet in cleartextSSL provides encrypted TCP connectiondata integrityend-point authenticationSSL is at app layerApps use SSL libraries, which talk to TCPSSL socket APIcleartext passwds sent into socket traverse Internet encrypted See Chapter 7

    Application Layer2-*

    Application Layer

  • Application Layer2-*Chapter 2: outline2.1 principles of network applicationsapp architecturesapp requirements2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*Web and HTTPFirst, a reviewweb page consists of objectsobject can be HTML file, JPEG image, Java applet, audio file,web page consists of base HTML-file which includes several referenced objectseach object is addressable by a URL, e.g.,

    Application Layer

  • Application Layer2-*HTTP overviewHTTP: hypertext transfer protocolWebs application layer protocolclient/server modelclient: browser that requests, receives, (using HTTP protocol) and displays Web objects server: Web server sends (using HTTP protocol) objects in response to requests

    PC runningFirefox browserserver runningApache Webserveriphone runningSafari browser

    Application Layer

  • Application Layer2-*HTTP overview (continued)uses TCP: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 statelessserver maintains 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 reconciled

    aside

    Application Layer

  • Application Layer2-*HTTP connectionsnon-persistent HTTPat most one object sent over TCP connectionconnection then closeddownloading multiple objects required multiple connections

    persistent HTTPmultiple objects can be sent over single TCP connection between client, server

    Application Layer

  • Application Layer2-*Non-persistent HTTPsuppose user enters URL:1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 802. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. accepts connection, notifying client3. HTTP server receives request message, forms response message containing requested object, and sends message into its sockettime(contains text, references to 10 jpeg images)www.someSchool.edu/someDepartment/home.index

    Application Layer

  • Application Layer2-*Non-persistent 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. HTTP server closes TCP connection. time

    Application Layer

  • Application Layer2-*Non-persistent HTTP: response timeRTT (definition): time for a small packet to travel from client to server and backHTTP response time:one RTT to initiate TCP connectionone RTT for HTTP request and first few bytes of HTTP response to returnfile transmission timenon-persistent HTTP response time = 2RTT+ file transmission time

    time to transmit fileinitiate TCPconnectionRTTrequestfileRTTfilereceivedtimetime

    Application Layer

  • Application Layer2-*Persistent HTTPnon-persistent HTTP issues:requires 2 RTTs per objectOS overhead for each TCP connectionbrowsers often open parallel TCP connections to fetch referenced objects

    persistent HTTP:server leaves connection open after sending responsesubsequent HTTP messages between same client/server sent over open connectionclient sends requests as soon as it encounters a referenced objectas little as one RTT for all the referenced objects

    Application Layer

  • Application Layer2-*HTTP request messagetwo types of HTTP messages: request, responseHTTP request message:ASCII (human-readable format)request line(GET, POST, HEAD commands)header linescarriage return, line feed at startof line indicatesend of header linesGET /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\ncarriage return characterline-feed character

    Application Layer

  • Application Layer2-*HTTP request message: general formatrequestlineheaderlinesbodymethodspspcrlfversionURLentity body

    Application Layer

  • Application Layer2-*Uploading form inputPOST method:web page often includes form inputinput is uploaded to server in entity bodyURL method:uses GET methodinput is uploaded in URL field of request line:

    www.somesite.com/animalsearch?monkeys&banana

    Application Layer

  • Application Layer2-*Method typesHTTP/1.0:GETPOSTHEADasks server to leave requested object out of responseHTTP/1.1:GET, POST, HEADPUTuploads file in entity body to path specified in URL fieldDELETEdeletes file specified in the URL field

    Application Layer

  • Application Layer2-*HTTP response messagestatus line(protocolstatus codestatus phrase)header linesdata, e.g., requestedHTML fileHTTP/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:02 GMT\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-8859-1\r\n\r\ndata data data data data ...

    Application Layer

  • Application Layer2-*HTTP response status codes200 OKrequest succeeded, requested object later in this msg301 Moved Permanentlyrequested object moved, new location specified later in this msg (Location:)400 Bad Requestrequest msg not understood by server404 Not Foundrequested document not found on this server505 HTTP Version Not Supportedstatus code appears in 1st line in server-to-client response message.some sample codes:

    Application Layer

  • Application Layer2-*Trying 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!(or use Wireshark to look at captured HTTP request/response)

    Application Layer

  • Application Layer2-*User-server state: cookiesmany Web sites use cookiesfour components:1) cookie header line of HTTP response message2) cookie header line in next HTTP request message3) cookie file kept on users host, managed by users browser4) back-end database at Web siteexample:Susan always access Internet from PCvisits specific e-commerce site for first timewhen initial HTTP requests arrives at site, site creates: unique IDentry in backend database for ID

    Application Layer

  • Application Layer2-*Cookies: keeping state (cont.)clientservercookie fileone week later:backenddatabase

    Application Layer

  • Application Layer2-*Cookies (continued)what cookies can be used for:authorizationshopping cartsrecommendationsuser session state (Web e-mail)cookies and privacy:cookies permit sites to learn a lot about youyou may supply name and e-mail to sitesasidehow to keep state:protocol endpoints: maintain state at sender/receiver over multiple transactionscookies: http messages carry state

    Application Layer

  • Application Layer2-*Web caches (proxy server)user sets browser: Web accesses via cachebrowser sends all HTTP requests to cacheobject in cache: cache returns object else cache requests object from origin server, then returns object to clientgoal: satisfy client request without involving origin serverclientproxyserverclientorigin serverorigin server

    Application Layer

  • Application Layer2-*More about Web cachingcache acts as both client and serverserver for original requesting clientclient to origin servertypically cache is installed by ISP (university, company, residential ISP)why Web caching?reduce response time for client requestreduce traffic on an institutions access linkInternet dense with caches: enables poor content providers to effectively deliver content (so too does P2P file sharing)

    Application Layer

  • Application Layer2-*Caching example: originserverspublic Internetinstitutionalnetwork1 Gbps LAN1.54 Mbps access linkassumptions:avg object size: 100K bitsavg request rate from browsers to origin servers:15/secavg data rate to browsers: 1.50 MbpsRTT from institutional router to any origin server: 2 secaccess link rate: 1.54 Mbpsconsequences:LAN utilization: 15%access link utilization = 99%total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + usecs

    problem!

    Application Layer

  • Application Layer2-*assumptions:avg object size: 100K bitsavg request rate from browsers to origin servers:15/secavg data rate to browsers: 1.50 MbpsRTT from institutional router to any origin server: 2 secaccess link rate: 1.54 Mbpsconsequences:LAN utilization: 15%access link utilization = 99%total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + usecs

    Caching example: fatter access link originservers1.54 Mbps access link154 Mbps154 MbpsmsecsCost: increased access link speed (not cheap!)9.9%public Internetinstitutionalnetwork1 Gbps LAN

    Application Layer

  • institutionalnetwork1 Gbps LANApplication Layer2-*Caching example: install local cache originservers1.54 Mbps access linkassumptions:avg object size: 100K bitsavg request rate from browsers to origin servers:15/secavg data rate to browsers: 1.50 MbpsRTT from institutional router to any origin server: 2 secaccess link rate: 1.54 Mbpsconsequences:LAN utilization: 15%access link utilization = 100%total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + usecs

    ??How to compute link utilization, delay?Cost: web cache (cheap!)public Internet

    Application Layer

  • Application Layer2-*Caching example: install local cache Calculating access link utilization, delay with cache:suppose cache hit rate is 0.440% requests satisfied at cache, 60% requests satisfied at origin originservers1.54 Mbps access linkaccess link utilization: 60% of requests use access link data rate to browsers over access link = 0.6*1.50 Mbps = .9 Mbps utilization = 0.9/1.54 = .58total delay= 0.6 * (delay from origin servers) +0.4 * (delay when satisfied at cache)= 0.6 (2.01) + 0.4 (~msecs) = ~ 1.2 secsless than with 154 Mbps link (and cheaper too!) public Internetinstitutionalnetwork1 Gbps LAN

    Application Layer

  • Application Layer2-*Conditional GET Goal: dont send object if cache has up-to-date cached versionno object transmission delaylower link utilizationcache: 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 ModifiedHTTP request msgIf-modified-since: object not modifiedbefore

    HTTP request msgIf-modified-since: HTTP responseHTTP/1.0 200 OK

    object modifiedafter

    clientserver

    Application Layer

  • Application Layer2-*Chapter 2: outline2.1 principles of network applicationsapp architecturesapp requirements2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*FTP: the file transfer protocolfile transferlocal filesystemremote filesystemuser at hosttransfer file to/from remote hostclient/server modelclient: side that initiates transfer (either to/from remote)server: remote hostftp: RFC 959ftp server: port 21

    Application Layer

  • Application Layer2-*FTP: separate control, data connectionsFTP client contacts FTP server at port 21, using TCP client authorized over control connectionclient browses remote directory, sends commands over control connectionwhen server receives file transfer command, server opens 2nd TCP data connection (for file) to clientafter transferring one file, server closes data connectionFTPclientFTPserverTCP control connection,server port 21TCP data connection,server port 20server opens another TCP data connection to transfer another filecontrol connection: out of bandFTP server maintains state: current directory, earlier authentication

    Application Layer

  • Application Layer2-*FTP commands, responsessample commands:sent as ASCII text over control 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 starting425 Cant open data connection452 Error writing file

    Application Layer

  • Application Layer2-*Chapter 2: outline2.1 principles of network applicationsapp architecturesapp requirements2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*Electronic mailThree major components: user agents mail servers simple mail transfer protocol: SMTPUser Agenta.k.a. mail readercomposing, editing, reading mail messagese.g., Outlook, Thunderbird, iPhone mail clientoutgoing, incoming messages stored on server

    Application Layer

  • Application Layer2-*Electronic mail: mail serversmail servers:mailbox contains incoming messages for usermessage queue of outgoing (to be sent) mail messagesSMTP protocol between mail servers to send email messagesclient: sending mail serverserver: receiving mail server

    Application Layer

  • Application Layer2-*Electronic Mail: SMTP [RFC 2821]uses TCP to reliably transfer email message from client to server, port 25direct transfer: sending server to receiving serverthree phases of transferhandshaking (greeting)transfer of messagesclosurecommand/response interaction (like HTTP, FTP)commands: ASCII textresponse: status code and phrasemessages must be in 7-bit ASCI

    Application Layer

  • Application Layer2-*Scenario: Alice sends message to Bob1) Alice uses UA to compose message to [email protected]) Alices UA sends message to her mail server; message placed in message queue3) client side of SMTP opens TCP connection with Bobs mail server4) SMTP client sends Alices message over the TCP connection5) Bobs mail server places the message in Bobs mailbox6) Bob invokes his user agent to read message

    123456Alices mail serverBobs mail server

    Application Layer

  • Application Layer2-*Sample SMTP interaction S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: S: 250 [email protected]... Sender ok C: RCPT TO: S: 250 [email protected] ... 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 connection

    Application Layer

  • Application Layer2-*Try 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 client (reader)

    Application Layer

  • Application Layer2-*SMTP: final wordsSMTP uses persistent connectionsSMTP requires message (header & body) to be in 7-bit ASCIISMTP server uses CRLF.CRLF to determine end of messagecomparison with HTTP:HTTP: pullSMTP: pushboth have ASCII command/response interaction, status codesHTTP: each object encapsulated in its own response msgSMTP: multiple objects sent in multipart msg

    Application Layer

  • Application Layer2-*Mail message formatSMTP: protocol for exchanging email msgsRFC 822: standard for text message format:header lines, e.g.,To:From:Subject:different from SMTP MAIL FROM, RCPT TO: commands!Body: the message ASCII characters onlyheaderbodyblankline

    Application Layer

  • Application Layer2-*Mail access protocolsSMTP: delivery/storage to receivers servermail access protocol: retrieval from serverPOP: Post Office Protocol [RFC 1939]: authorization, download IMAP: Internet Mail Access Protocol [RFC 1730]: more features, including manipulation of stored msgs on serverHTTP: gmail, Hotmail, Yahoo! Mail, etc.

    SMTPSMTPmail accessprotocolreceivers mail server(e.g., POP, IMAP)

    Application Layer

  • Application Layer2-*POP3 protocolauthorization phaseclient commands: user: declare usernamepass: passwordserver responses+OK-ERRtransaction phase, client:list: list message numbersretr: retrieve message by numberdele: deletequit C: 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 off

    S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on

    Application Layer

  • Application Layer2-*POP3 (more) and IMAPmore about POP3previous example uses POP3 download and delete modeBob cannot re-read e-mail if he changes clientPOP3 download-and-keep: copies of messages on different clientsPOP3 is stateless across sessionsIMAPkeeps all messages in one place: at serverallows user to organize messages in folderskeeps user state across sessions:names of folders and mappings between message IDs and folder name

    Application Layer

  • Application Layer2-*Chapter 2: outline2.1 principles of network applicationsapp architecturesapp requirements2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*DNS: domain name systempeople: many identifiers:SSN, name, passport #Internet hosts, routers:IP address (32 bit) - used for addressing datagramsname, e.g., www.yahoo.com - used by humansQ: how to map between IP address and name, and vice versa ?Domain Name System:distributed database implemented in hierarchy of many name serversapplication-layer protocol: hosts, name servers communicate to resolve names (address/name translation)note: core Internet function, implemented as application-layer protocolcomplexity at networks edge

    Application Layer

  • Application Layer2-*DNS: services, structure why not centralize DNS?single point of failuretraffic volumedistant centralized databasemaintenance

    DNS serviceshostname to IP address translationhost aliasingcanonical, alias namesmail server aliasingload distributionreplicated Web servers: many IP addresses correspond to one name

    A: doesnt scale!

    Application Layer

  • Application Layer2-*DNS: a distributed, hierarchical databaseclient wants IP for www.amazon.com; 1st approx:client queries 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 for www.amazon.com

    Application Layer

  • Application Layer2-*DNS: root name serverscontacted by local name server that can not resolve nameroot name server:contacts authoritative name server if name mapping not knowngets mappingreturns mapping to local name server 13 root name servers worldwidea. Verisign, Los Angeles CA (5 other sites)b. USC-ISI Marina del Rey, CAl. ICANN Los Angeles, CA (41 other sites)e. NASA Mt View, CAf. Internet Software C.Palo Alto, CA (and 48 other sites)i. Netnod, Stockholm (37 other sites)k. RIPE London (17 other sites)m. WIDE Tokyo(5 other sites)c. Cogent, Herndon, VA (5 other sites)d. U Maryland College Park, MDh. ARL Aberdeen, MDj. Verisign, Dulles VA (69 other sites )g. US DoD Columbus, OH (5 other sites)

    Application Layer

  • Application Layer2-*TLD, authoritative serverstop-level domain (TLD) servers:responsible for com, org, net, edu, aero, jobs, museums, and all top-level country domains, e.g.: uk, fr, ca, jpNetwork Solutions maintains servers for .com TLDEducause for .edu TLDauthoritative DNS servers: organizations own DNS server(s), providing authoritative hostname to IP mappings for organizations named hosts can be maintained by organization or service provider

    Application Layer

  • Application Layer2-*Local DNS name serverdoes not strictly belong to hierarchyeach ISP (residential ISP, company, university) has onealso called default name serverwhen host makes DNS query, query is sent to its local DNS serverhas local cache of recent name-to-address translation pairs (but may be out of date!)acts as proxy, forwards query into hierarchy

    Application Layer

  • Application Layer2-*requesting hostcis.poly.edugaia.cs.umass.eduroot DNS server123456authoritative DNS serverdns.cs.umass.edu78TLD DNS serverDNS name resolution examplehost at cis.poly.edu wants IP address for gaia.cs.umass.eduiterated query:contacted server replies with name of server to contactI dont know this name, but ask this server

    Application Layer

  • Application Layer2-*4563recursive query:puts burden of name resolution on contacted name serverheavy load at upper levels of hierarchy?requesting hostcis.poly.edugaia.cs.umass.eduroot DNS server127authoritative DNS serverdns.cs.umass.edu8DNS name resolution exampleTLD DNS server

    Application Layer

  • Application Layer2-*DNS: caching, updating recordsonce (any) name server learns mapping, it caches mappingcache entries timeout (disappear) after some time (TTL)TLD servers typically cached in local name serversthus root name servers not often visitedcached entries may be out-of-date (best effort name-to-address translation!)if name host changes IP address, may not be known Internet-wide until all TTLs expireupdate/notify mechanisms proposed IETF standardRFC 2136

    Application Layer

  • Application Layer2-*DNS recordsDNS: distributed db storing resource records (RR)type=NSname is domain (e.g., foo.com)value is hostname of authoritative name server for this domain

    RR format: (name, value, type, ttl)type=Aname is hostnamevalue is IP address

    type=CNAMEname is alias name for some canonical (the real) namewww.ibm.com is really servereast.backup2.ibm.comvalue is canonical name

    type=MXvalue is name of mailserver associated with name

    Application Layer

  • Application Layer2-*DNS protocol, messagesquery and reply messages, both with same message formatmsg headeridentification: 16 bit # for query, reply to query uses same #flags:query or replyrecursion desired recursion availablereply is authoritative

    Application Layer

  • Application Layer2-*name, type fields for a queryRRs in responseto queryrecords forauthoritative serversadditional helpfulinfo that may be usedDNS protocol, messages

    Application Layer

  • Application Layer2-*Inserting records into DNSexample: new startup Network Utopiaregister 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

    Application Layer

  • Attacking DNSDDoS attacksBombard root servers with trafficNot successful to dateTraffic FilteringLocal DNS servers cache IPs of TLD servers, allowing root server bypassBombard TLD serversPotentially more dangerous

    Redirect attacksMan-in-middleIntercept queriesDNS poisoningSend bogus relies to DNS server, which cachesExploit DNS for DDoSSend queries with spoofed source address: target IPRequires amplificationApplication Layer2-*

    Application Layer

  • Application Layer2-*Chapter 2: outline2.1 principles of network applicationsapp architecturesapp requirements2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*Pure P2P architectureno always-on serverarbitrary end systems directly communicatepeers are intermittently connected and change IP addressesexamples:file distribution (BitTorrent)Streaming (KanKan)VoIP (Skype)

    Application Layer

  • Application Layer2-*File distribution: client-server vs P2PQuestion: how much time to distribute file (size F) from one server to N peers?peer upload/download capacity is limited resourceusuNdNservernetwork (with abundant bandwidth)file, size Fus: server upload capacityui: peer i upload capacitydi: peer i download capacitydiui

    Application Layer

  • Application Layer2-*File distribution time: client-serverserver transmission: must sequentially send (upload) N file copies:time to send one copy: F/us time to send N copies: NF/usincreases linearly in Ntime to distribute F to N clients using client-server approach Dc-s > max{NF/us,,F/dmin} client: each client must download file copydmin = min client download ratemin client download time: F/dmin usnetworkdiuiF

    Application Layer

  • Application Layer2-*File distribution time: P2Pserver transmission: must upload at least one copytime to send one copy: F/us time to distribute F to N clients using P2P approach usnetworkdiuiF DP2P > max{F/us,,F/dmin,,NF/(us + Sui)} client: each client must download file copymin client download time: F/dmin clients: as aggregate must download NF bitsmax upload rate (limting max download rate) is us + Sui but so does this, as each peer brings service capacityincreases linearly in N

    Application Layer

  • Application Layer2-*Client-server vs. P2P: exampleclient upload rate = u, F/u = 1 hour, us = 10u, dmin us

    Application Layer

    Chart1

    0.10.1

    0.16666666670.2

    0.23076923080.3

    0.28571428570.4

    0.33333333330.5

    0.3750.6

    0.41176470590.7

    0.44444444440.8

    0.47368421050.9

    0.51

    0.52380952381.1

    0.54545454551.2

    0.56521739131.3

    0.58333333331.4

    0.61.5

    0.61538461541.6

    0.62962962961.7

    0.64285714291.8

    0.65517241381.9

    0.66666666672

    0.67741935482.1

    0.68752.2

    0.6969696972.3

    0.70588235292.4

    0.71428571432.5

    0.72222222222.6

    0.72972972972.7

    0.73684210532.8

    0.74358974362.9

    0.753

    0.7560975613.1

    0.76190476193.2

    P2P

    Client-Server

    N

    Minimum Distribution Time

    Sheet1

    LP2PClient-Serverratiofactor

    10.10.1110

    20.16666666670.2

    30.23076923080.3

    40.28571428570.4

    50.33333333330.5

    60.3750.6

    70.41176470590.7

    80.44444444440.8

    90.47368421050.9

    100.51

    110.52380952381.1

    120.54545454551.2

    130.56521739131.3

    140.58333333331.4

    150.61.5

    160.61538461541.6

    170.62962962961.7

    180.64285714291.8

    190.65517241381.9

    200.66666666672

    210.67741935482.1

    220.68752.2

    230.6969696972.3

    240.70588235292.4

    250.71428571432.5

    260.72222222222.6

    270.72972972972.7

    280.73684210532.8

    290.74358974362.9

    300.753

    310.7560975613.1

    320.76190476193.2

    330.76744186053.3

    340.77272727273.4

    350.77777777783.5

    360.78260869573.6

    370.78723404263.7

    380.79166666673.8

    390.79591836733.9

    400.84

    410.80392156864.1

    420.80769230774.2

    430.81132075474.3

    440.81481481484.4

    450.81818181824.5

    460.82142857144.6

    470.82456140354.7

    480.82758620694.8

    490.83050847464.9

    Sheet1

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    00

    P2P

    Client-Server

    N

    Minimum Distribution Time

    Sheet2

    Sheet3

  • Application Layer2-*P2P file distribution: BitTorrent tracker: tracks peers participating in torrenttorrent: group of peers exchanging chunks of a fileAlice arrives file divided into 256Kb chunkspeers in torrent send/receive file chunks obtains listof peers from tracker and begins exchanging file chunks with peers in torrent

    Application Layer

  • Application Layer2-*peer joining torrent: has no chunks, but will accumulate them over time from other peersregisters with tracker to get list of peers, connects to subset of peers (neighbors)P2P file distribution: BitTorrent while downloading, peer uploads chunks to other peerspeer may change peers with whom it exchanges chunkschurn: peers may come and goonce peer has entire file, it may (selfishly) leave or (altruistically) remain in torrent

    Application Layer

  • Application Layer2-*BitTorrent: requesting, sending file chunksrequesting chunks:at any given time, different peers have different subsets of file chunksperiodically, Alice asks each peer for list of chunks that they haveAlice requests missing chunks from peers, rarest firstsending chunks: tit-for-tatAlice sends chunks to those four peers currently sending her chunks at highest rate other peers are choked by Alice (do not receive chunks from her)re-evaluate top 4 every10 secsevery 30 secs: randomly select another peer, starts sending chunksoptimistically unchoke this peernewly chosen peer may join top 4

    Application Layer

  • Application Layer2-*BitTorrent: tit-for-tat(1) Alice optimistically unchokes Bob(2) Alice becomes one of Bobs top-four providers; Bob reciprocates(3) Bob becomes one of Alices top-four providershigher upload rate: find better trading partners, get file faster !

    Application Layer

  • Distributed Hash Table (DHT)Hash table

    DHT paradigm Circular DHT and overlay networks Peer churn

  • Simple database with(key, value) pairs: key: human name; value: social security #

    Simple Database

    key: movie title; value: IP address

    KeyValueJohn Washington132-54-3570Diana Louise Jones761-55-3791Xiaoming Liu385-41-0902Rakesh Gopal441-89-1956Linda Cohen217-66-5609.Lisa Kobayashi177-23-0199

  • More convenient to store and search on numerical representation of key key = hash(original key)

    Hash Table

    Original KeyKeyValueJohn Washington8962458132-54-3570Diana Louise Jones7800356761-55-3791Xiaoming Liu1567109385-41-0902Rakesh Gopal2360012441-89-1956Linda Cohen5430938217-66-5609.Lisa Kobayashi9290124177-23-0199

  • Distribute (key, value) pairs over millions of peerspairs are evenly distributed over peersAny peer can query database with a keydatabase returns value for the keyTo resolve query, small number of messages exchanged among peersEach peer only knows about a small number of other peersRobust to peers coming and going (churn)

    Distributed Hash Table (DHT)

  • Assign key-value pairs to peersrule: assign key-value pair to the peer that has the closest ID.convention: closest is the immediate successor of the key.e.g., ID space {0,1,2,3,,63}suppose 8 peers: 1,12,13,25,32,40,48,60If key = 51, then assigned to peer 60If key = 60, then assigned to peer 60If key = 61, then assigned to peer 1

  • Circular DHTeach peer only aware of immediate successor and predecessor.

  • 112132532404860O(N) messageson avgerage to resolvequery, when thereare N peersResolving a query

  • Circular DHT with shortcutseach peer keeps track of IP addresses of predecessor, successor, short cuts.reduced from 6 to 3 messages.possible to design shortcuts with O(log N) neighbors, O(log N) messages in queryvalue

  • Peer churnexample: peer 5 abruptly leaves

    handling peer churn:peers may come and go (churn)each peer knows address of its two successors each peer periodically pings its two successors to check alivenessif immediate successor leaves, choose next successor as new immediate successor

  • Peer churnexample: peer 5 abruptly leavespeer 4 detects peer 5s departure; makes 8 its immediate successor 4 asks 8 who its immediate successor is; makes 8s immediate successor its second successor.

    1348101215handling peer churn:peers may come and go (churn)each peer knows address of its two successors each peer periodically pings its two successors to check alivenessif immediate successor leaves, choose next successor as new immediate successor

  • Application Layer2-*Chapter 2: outline2.1 principles of network applicationsapp architecturesapp requirements2.2 Web and HTTP2.3 FTP 2.4 electronic mailSMTP, POP3, IMAP2.5 DNS

    2.6 P2P applications2.7 socket programming with UDP and TCP

    Application Layer

  • Application Layer2-*Socket programming goal: learn how to build client/server applications that communicate using socketssocket: door between application process and end-end-transport protocol

    Application Layer

  • Application Layer2-*Socket programming Two socket types for two transport services:UDP: unreliable datagramTCP: reliable, byte stream-oriented

    Application Example:Client reads a line of characters (data) from its keyboard and sends the data to the server.The server receives the data and converts characters to uppercase.The server sends the modified data to the client.The client receives the modified data and displays the line on its screen.

    Application Layer

  • Application Layer2-*Socket programming with UDPUDP: no connection between client & serverno handshaking before sending datasender explicitly attaches IP destination address and port # to each packetrcvr extracts sender IP address and port# from received packetUDP: transmitted data may be lost or received out-of-orderApplication viewpoint:UDP provides unreliable transfer of groups of bytes (datagrams) between client and server

    Application Layer

  • Client/server socket interaction: UDPcreate socket, port= x:serverSocket =socket(AF_INET,SOCK_DGRAM)Application 2-*server (running on serverIP)client

  • Application Layer2-*Example app: UDP clientfrom socket import *serverName = hostnameserverPort = 12000clientSocket = socket(socket.AF_INET, socket.SOCK_DGRAM)message = raw_input(Input lowercase sentence:)clientSocket.sendto(message,(serverName, serverPort))modifiedMessage, serverAddress = clientSocket.recvfrom(2048)print modifiedMessageclientSocket.close()Python UDPClient

    Application Layer

  • Application Layer2-*Example app: UDP serverfrom socket import *serverPort = 12000serverSocket = socket(AF_INET, SOCK_DGRAM)serverSocket.bind(('', serverPort))print The server is ready to receivewhile 1: message, clientAddress = serverSocket.recvfrom(2048) modifiedMessage = message.upper() serverSocket.sendto(modifiedMessage, clientAddress)Python UDPServer

    Application Layer

  • Application Layer2-*Socket programming with TCPclient must contact serverserver process must first be runningserver must have created socket (door) that welcomes clients contactclient contacts server by:Creating TCP socket, specifying IP address, port number of server processwhen client creates socket: client TCP establishes connection to server TCP

    when contacted by client, server TCP creates new socket for server process to communicate with that particular clientallows server to talk with multiple clientssource port numbers used to distinguish clients (more in Chap 3)TCP provides reliable, in-orderbyte-stream transfer (pipe) between client and server

    Application Layer

  • Application Layer2-*Client/server socket interaction: TCPserver (running on hostid)client

    Application Layer

  • Application Layer2-*Example app: TCP clientfrom socket import *serverName = servernameserverPort = 12000clientSocket = socket(AF_INET, SOCK_STREAM)clientSocket.connect((serverName,serverPort))sentence = raw_input(Input lowercase sentence:)clientSocket.send(sentence)modifiedSentence = clientSocket.recv(1024)print From Server:, modifiedSentenceclientSocket.close()Python TCPClient

    Application Layer

  • Application Layer2-*Example app: TCP server from socket import *serverPort = 12000serverSocket = socket(AF_INET,SOCK_STREAM)serverSocket.bind((,serverPort))serverSocket.listen(1)print The server is ready to receivewhile 1: connectionSocket, addr = serverSocket.accept() sentence = connectionSocket.recv(1024) capitalizedSentence = sentence.upper() connectionSocket.send(capitalizedSentence) connectionSocket.close()Python TCPServer

    Application Layer

  • Application Layer2-*Chapter 2: summaryapplication architecturesclient-serverP2Papplication service requirements:reliability, bandwidth, delayInternet transport service modelconnection-oriented, reliable: TCPunreliable, datagrams: UDPour study of network apps now complete!specific protocols:HTTPFTPSMTP, POP, IMAPDNSP2P: BitTorrent, DHT socket programming: TCP, UDP sockets

    Application Layer

  • Application Layer2-*typical request/reply message exchange:client requests info or serviceserver responds with data, status codemessage formats:headers: fields giving info about datadata: info being communicatedimportant themes: control vs. data msgsin-band, out-of-bandcentralized vs. decentralized stateless vs. statefulreliable vs. unreliable msg transfer complexity at network edgeChapter 2: summarymost importantly: learned about protocols!

    Application Layer

    ***************************************************************************************