🎧 New: AI-Generated Podcasts Turn your study notes into engaging audio conversations. Learn more

IK1203 VT24 Network Communication.pdf

Loading...
Loading...
Loading...
Loading...
Loading...
Loading...
Loading...

Full Transcript

Chapter 2 Application Layer A note on the use of these Powerpoint slides: We’re making these slides freely available to all (faculty, students, readers). They’re in PowerPoint form so you see the animations; and can add, modify, and delete slides (including this one) and slide content to suit your n...

Chapter 2 Application Layer A note on the use of these Powerpoint slides: We’re making these slides freely available to all (faculty, students, readers). They’re 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, we’d 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-2016 J.F Kurose and K.W. Ross, All Rights Reserved Computer Networking: A Top Down Approach 7th Edition, Global Edition Jim Kurose, Keith Ross Pearson April 2016 Application Layer 2-1 Chapter 2: outline 2.1 principles of network applications 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail 2.6 P2P applications 2.7 socket programming with UDP and TCP § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-2 Chapter 2: application layer our goals: v conceptual and implementation aspects of network application protocols § transport-layer service models § client-server paradigm § peer-to-peer paradigm v learn about protocols by examining popular application-level protocols § § § § v HTTP FTP SMTP / POP3 / IMAP DNS creating network applications § socket API Application Layer 2-3 Some network applications v v v v v v v e-mail web text messaging remote login P2P file sharing multi-user network games streaming stored video (such as YouTube, Hulu, Netflix, SVT Play, …) v v v v v v voice over IP (e.g., Skype) real-time video conferencing social networking search Cloud computing and storage … Application Layer 2-4 Creating applications write programs that: v run on (different) end systems v communicate over network v e.g., web server software communicates with browser software no need to write software for network-core devices v network-core devices do not run user applications v applications on end systems allows for rapid application development and propagation application transport network data link physical application transport network data link physical application transport network data link physical Application Layer 2-5 Application architectures possible structure of applications: v client-server v peer-to-peer (P2P) Application Layer 2-6 Client-server architecture server: v v v always-on host permanent IP address data centers for scaling clients: v client/server v v v communicate with server may be intermittently connected may have dynamic IP addresses do not communicate directly with each other Application Layer 2-7 Client-server examples Web: v Use a web browser (client) to fetch a web page from a web server (server) Mail: v Use a mail program (client) to connect to your mailbox on a mail server (server) Webmail: v Use a web browser (client) to connect to you webmail server (server) v The webmail server has a mail client built-in (client) that connects to the mail server with the mailbox (server) Application Layer 2-8 P2P architecture v v v v no always-on server arbitrary end systems directly communicate peers request service from other peers, provide service in return to other peers § self scalability – new peers bring new service capacity, as well as new service demands peers are intermittently connected and change IP addresses § complex management peer-peer Application Layer 2-9 Processes communicating process: program running within a host v v within same host, two processes communicate using inter-process communication (defined by operating system) processes in different hosts communicate by exchanging messages clients, servers client process: process that initiates communication server process: process that waits to be contacted v aside: applications with P2P architectures have client processes & server processes Application Layer 2-10 Many-to-many Communication Mail Web v v Mail Mail Web Web Many client processes on same host, communicating with different server processes A server process communicates with many client processes Application Layer 2-11 Addressing processes v v v to receive messages, process must have identifier each host device has unique IP address Q: does IP address of host on which process runs suffice for identifying the process? § A: no, many processes can be running on same host v v identifier includes both IP address and port number associated with process on host. example port numbers: § HTTP server: 80 § mail server: 25 v to send HTTP message to gaia.cs.umass.edu web server: § IP address: 128.119.245.12 § port number: 80 v more shortly… Application Layer 2-12 Application layer protocol defines v v v v 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 messages open protocols v defined in RFCs v allows for interoperability v e.g., HTTP, SMTP proprietary protocols v e.g., Skype Application Layer 2-13 What transport service does an application need? data integrity v some applications (e.g., file transfer, web transactions) require 100% reliable data transfer v other applications (e.g., audio) can tolerate some loss timing v some applications (e.g., Internet telephony, interactive games) require low delay throughput v some applications (e.g., multimedia) require a certain minimum amount of throughput v other applications (”elastic”) make use of whatever throughput they get security v encryption, data integrity, … Application Layer 2-14 Transport service requirements: common apps application data loss throughput file transfer e-mail Web documents real-time audio/video no loss no loss no loss loss-tolerant stored audio/video interactive games text messaging loss-tolerant loss-tolerant no loss elastic no elastic no elastic no audio: 5kbps-1Mbps yes, 100’s msec video:10kbps-5Mbps same as above yes, few secs few kbps up yes, 100’s msec elastic yes and no time sensitive Application Layer 2-15 Internet transport protocols services TCP service: UDP service: v v v v v v 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 throughput guarantee, security connection-oriented: setup required between client and server processes v unreliable data transfer between sending and receiving process does not provide: reliability, flow control, congestion control, timing, throughput guarantee, security, orconnection setup, Q: why bother? Why is there a UDP? Application Layer 2-16 Internet application and transport protocols application e-mail remote terminal access Web file transfer streaming multimedia Internet telephony application layer protocol underlying transport 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) TCP TCP TCP TCP TCP or UDP TCP or UDP Application Layer 2-17 Securing TCP TCP & UDP v no encryption v passwords traverse Internet in cleartext SSL (Secure Socket Layer) v provides encrypted TCP connection v data integrity v end-point authentication SSL is at application layer v Applications use SSL libraries, which “talk” to TCP SSL socket API v passwords traverse Internet encrypted v See Chapter 7 Application Layer 2-18 Chapter 2: outline 2.1 principles of network applications § app architectures § app requirements 2.6 P2P applications 2.7 socket programming with UDP and TCP 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-19 Web and HTTP First, a review… v v v v web page consists of objects object can be HTML file, JPEG image, Java applet, audio file,… web page consists of base HTML-file which includes several referenced objects each object is addressable by a URL, Uniform Resource Locator, e.g., http://www.someschool.edu/someDept/pic.gif protocol host name path name Application Layer 2-20 HTTP overview HTTP: hypertext transfer protocol v v Web application layer protocol client/server model § client: browser that requests, receives, (using HTTP protocol) and ”displays” Web objects § server: Web server sends (using HTTP protocol) objects in response to requests PC running Firefox browser server running Apache Web server iphone running Safari browser Application Layer 2-21 HTTP request message v ASCII (human-readable format) § HTTP/1.1 request line (GET, POST, HEAD commands) header lines Empty line indicates end of header lines GET /index.html HTTP/1.1 Host: www-net.cs.umass.edu User-Agent: Firefox/3.6.10 Accept: text/html,application/xhtml+xml Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7 Keep-Alive: 115 Connection: keep-alive Application Layer 2-22 Request Method types HTTP/1.0: v GET § Query – can include input in URL § www.somesite.com/animalsearch?monkeys&banana v v POST § Input in body – data after header HEAD § Header only – server leaves requested object out of response In HTTP/1.1, also: v v PUT § Uploads file in entity body to path specified in URL field DELETE § Deletes file specified in the URL field Application Layer 2-23 HTTP response message status line (protocol status code/ status phrase) header lines data, e.g., requested HTML file HTTP/1.1 200 OK Date: Sun, 26 Sep 2010 20:09:20 GMT Server: Apache/2.0.52 (CentOS) Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT ETag: "17dc6-a5c-bf716880” Accept-Ranges: bytes Content-Length: 2652 Keep-Alive: timeout=10, max=100 Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 data data data data data ... Application Layer 2-24 HTTP response status codes status code appears in first line in server-toclient response message. v some sample codes: v 200 OK § request succeeded, requested object later in this msg 301 Moved Permanently § requested object moved, new location specified later in this message (Location:) 400 Bad Request § request message not understood by server 404 Not Found § requested document not found on this server 505 HTTP Version Not Supported Application Layer 2-25 Trying out HTTP (client side) for yourself 1. Telnet to your favorite Web server: telnet cis.poly.edu 80 opens TCP connection to port 80 (default HTTP server port) at cis.poly.edu. anything typed in sent to port 80 at cis.poly.edu 2. type in a GET HTTP request: GET /~ross/ HTTP/1.1 Host: cis.poly.edu by typing this in (hit carriage return twice), you send this minimal (but complete) GET request to HTTP server 3. look at response message sent by HTTP server! (or use Wireshark to look at captured HTTP request/response) Application Layer 2-26 HTTP is stateless uses TCP, port 80: v Stateless protocol § Client sends request § Server responds § That’s it! v server maintains no information about past client requests aside protocols that maintain ”state” are complex! v v past history (state) must be maintained if server/client crashes, their views of ”state” may be inconsistent, must be reconciled Application Layer 2-27 User-server state: cookies many Web sites use cookies four components: 1) cookie header line of HTTP response message 2) cookie header line in next HTTP request message 3) cookie file kept on user’s host, managed by user’s browser 4) back-end database at Web site example: v Susan always access Internet from PC v visits specific e-commerce site for first time v when initial HTTP requests arrives at site, site creates: § unique ID § entry in backend database for ID Application Layer 2-28 Cookies: keeping “state” (cont.) client ebay 8734 cookie file ebay 8734 amazon 1678 server usual http request msg usual http response set-cookie: 1678 usual http request msg cookie: 1678 usual http response msg Amazon server creates ID 1678 for user create backend entry database cookiespecific action one week later: ebay 8734 amazon 1678 access access usual http request msg cookie: 1678 usual http response msg cookiespecific action Application Layer 2-29 Cookies (continued) what cookies can be used for: v v v v authorization shopping carts recommendations user session state (Web e-mail) aside cookies and privacy: v cookies permit sites to learn a lot about you v you may supply name and e-mail to sites how to keep ”state”: v v protocol endpoints: maintain state at sender/receiver over multiple transactions cookies: http messages carry state Application Layer 2-30 Laws and Regulations In EU, placing a cookie on a user’s computer requires that the user is informed, and that the user consents to it. (This applies not only to cookies, but to any similar technology that stores and accesses information on the user’s device.) Lagen om elektronisk kommunikation http://www.pts.se/sv/Bransch/Regler/Lagar/Lag-om-elektroniskkommunikation/Cookies-kakor 2015-09-21 EU Cookie Law (ePrivacy directive, 2002/58/EC) http://eurlex.europa.eu/LexUriServ/LexUriServ.do?uri=CELEX:32002L0058:EN:HTML 2015-09-21 http://www.cookiechoices.org 2015-09-21 31 Web caches (proxy server) goal: satisfy client request without involving origin server v v user configures browser: Web accesses via cache browser sends all HTTP requests to cache § if object in cache: cache returns object § else cache requests object from origin server, then returns object to client client client proxy server origin server origin server Application Layer 2-32 More about Web caching v cache acts as both client and server § server for original requesting client § client to origin server v typically cache is installed by ISP (university, company, residential ISP) why Web caching? v reduce response time for client request v reduce traffic on an institution’s access link v Internet dense with caches: enables ”poor” content providers to effectively deliver content (so too does P2P file sharing) Application Layer 2-33 HTTP/2 – Why a New Version? v HTTP performance trends § More HTTP transfers per page § More data per transfer § Request/response stop-and-wait v TCP efficiency § Congestion control has little effect with many short connections § Redundancy with same information sent many times § Stop-and-wait nature of TCP handshakes v v User experience suffers as page load time increases Negative influence on server load and performance 34 HTTP/2 – Main Features v v Multiplexing to support loading of multiple objects at the same time over single connection More compact header format § Binary format (not text) § Compression to remove redundancy v Advanced features, such as server push § Server knows which objects the browser will request next – send them in advance v v v v v Backward compatibility – version negotiation Originates from SPDY research project initiative by Google HTTP/2 home page https://http2.github.io/ RFC 7540 – Hypertext Transfer Protocol version 2 (HTTP/2) RFC 7541 – HPACK: Header Compression for HTTP/2 35 Chapter 2: outline 2.6 P2P applications 2.7 socket programming § application architectures with UDP and TCP 2.1 principles of network applications § application requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-36 Chapter 2: outline 2.6 P2P applications 2.7 socket programming § application architectures with UDP and TCP 2.1 principles of network applications § application requirements 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-37 Electronic mail outgoing message queue Three major components: v v v user agents mail servers simple mail transfer protocol: SMTP User Agent v v v v a.k.a. ”mail reader” composing, editing, reading mail messages e.g., Outlook, Thunderbird, iPhone mail client outgoing, incoming messages stored on server user agent user mailbox mail server user agent SMTP mail server user agent SMTP SMTP mail server user agent user agent user agent Application Layer 2-38 Electronic mail: mail servers mail servers: v v v mailbox contains incoming messages for user message queue of outgoing (to be sent) mail messages SMTP protocol between mail servers to send email messages § Note: mail server has client side and server side • client: sending mail server • server: receiving mail server user agent mail server user agent SMTP mail server user agent SMTP SMTP mail server user agent user agent user agent Application Layer 2-39 Electronic Mail: SMTP [RFC 2821] v v v 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 v command/response interaction (like HTTP, FTP) § commands: ASCII text § response: status code and phrase v messages must be in 7-bit ASCII Application Layer 2-40 Scenario: Alice sends message to Bob 4) SMTP client sends Alice’s message over the TCP connection 5) Bob’s incoming mail server places the message in Bob’s mailbox 6) Bob invokes his user agent to read message 1) Alice uses UA to compose message to Bob at [email protected] 2) Alice’s UA sends message to her outgoing mail server; message placed in message queue 3) client side of SMTP opens TCP connection with Bob’s incoming mail server 1 user agent 2 mail server 3 Alice’s mail server user agent mail server 4 6 5 Bob’s mail server Application Layer 2-41 Sample SMTP interaction S: C: S: C: S: C: S: C: S: C: C: C: S: C: S: 220 hamburger.edu HELO crepes.fr 250 Hello crepes.fr, pleased to meet you MAIL FROM: <[email protected]> 250 [email protected]... Sender ok RCPT TO: <[email protected]> 250 [email protected] ... Recipient ok DATA 354 Enter mail, end with "." on a line by itself Do you like ketchup? How about pickles? . 250 Message accepted for delivery QUIT 221 hamburger.edu closing connection Application Layer 2-42 Try SMTP interaction for yourself: v v v telnet servername 25 see 220 reply from server enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands above lets you send email without using email client (reader) Application Layer 2-43 Mail message format RFC 5322 (RFC 822): standard for text message format: v header lines, e.g., § To: § From: § Subject: header blank line body different from SMTP MAIL FROM, RCPT TO: v commands! Body: the “message” § ASCII characters only Application Layer 2-44 MIME v v Multipurpose Internet Mail Extensions, RFC 2045 and more Content formats and encodings for SMTP (7-bit ASCII) § Binary (non-text) objects (binary files) § Non-ASCII text (“Å”, “Ä”, “Ö” for instance) § Multi-part message bodies v Extensions for secure email – S/MIME, PGP, … MIME-version: 1.0 Content-type: multipart/mixed; boundary="frontier" This is a multi-part message in MIME format. --frontier Content-type: text/plain This is the body of the message. --frontier Content-type: application/octet-stream Content-transfer-encoding: base64 PGh0bWw+CiAgPGhlYWQ+CiAgPC9oZWFkPgogIDxib2R5PgogICAgPHA+VGhpcyBpcyB0aGUg Ym9keSBvZiB0aGUgbWVzc2FnZS48L3A+CiAgPC9ib2R5Pgo8L2h0bWw+Cg== --frontier-- From Wikipedia 45 Format of an Email SMTP RFC 5322, MIME, etc 46 Mail access protocols user agent SMTP SMTP (e.g., POP, IMAP) sender’s mail server v v mail access user protocol agent receiver’s mail server SMTP: delivery/storage to receiver’s server mail access protocol: retrieval from server § POP: Post Office Protocol [RFC 1939]: authorization, download § IMAP: Internet Mail Access Protocol [RFC 1730]: more features, including manipulation of stored msgs on server § HTTP: gmail, Hotmail, Yahoo! Mail, etc. Application Layer 2-47 POP3 protocol authorization phase v v client commands: § user: declare username § pass: password server responses § +OK § -ERR transaction phase, client: v v v v list: list message numbers retr: retrieve message by number dele: delete quit S: C: S: C: S: +OK POP3 server ready user bob +OK pass hungry +OK user successfully logged C: S: S: S: C: S: S: C: C: S: S: C: C: S: list 1 498 2 912 . retr 1 <message 1 contents> . dele 1 retr 2 <message 1 contents> . dele 2 quit +OK POP3 server signing off on Application Layer 2-48 POP3 (more) and IMAP more about POP3 v v v previous example uses POP3 ”download and delete” mode § Bob cannot re-read email if he changes client POP3 ”download-andkeep”: copies of messages on different clients POP3 is stateless across sessions IMAP v v v keeps all messages in one place: at server allows user to organize messages in folders keeps user state across sessions: § names of folders and mappings between message IDs and folder name Application Layer 2-49 Chapter 2: outline 2.1 principles of network applications § app architectures § app requirements 2.6 P2P applications 2.7 socket programming with UDP and TCP 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-50 DNS: domain name system people: many identifiers: § Social security number, name, passport number Internet hosts, routers: § IP address - used for addressing datagrams § name, e.g., “www.yahoo.com” used by humans Q: how to map between IP address and name, and vice versa? Domain Name System: v v distributed database implemented in hierarchy of many name servers application-layer protocol: hosts, name servers communicate to resolve names (address/name translation) § note: core Internet function, implemented as applicationlayer protocol § complexity at network’s edge Application Layer 2-51 Internet Domains v Country domains (country code top-level domains, ccTLDs) § Two-letter country domains (per ISO 3166) § “.cn”, “.fi”, “.nu”, “.se”, “.uk”, “.us”, … v Generic domains (generic top-level domains, gTLDs) § Three letters or more § “.com”, “.net”, “.org”, … Application Layer 2- Generic Domain Labels Domai n Intended use Domai n Intended use aero mil the U.S. military asia the air transport industry. companies, organizations and individuals in the Asia-Pacific region mobi sites catering to mobile devices biz business use museum museums cat Catalan language/culture commercial organizations, but unrestricted name org edu cooperatives U.S. post-secondary educational establishments gov U.S. government entities at the federal, state, and local levels com coop info net pro tel int informational sites, but unrestricted travel international organizations established by treaty xxx jobs employment-related sites From: Wikipedia, 2013-09-30 families and individuals originally for network infrastructures, now unrestricted originally for organizations not clearly falling within the other gTLDs, now unrestricted certain professions services involving connections between the telephone network and the Internet travel agents, airlines, hoteliers, tourism bureaus, etc. pornography Generic Domain Labels Domain Intended use Domain Intended use aero mil the U.S. military asia the air transport industry. companies, organizations and individuals in the Asia-Pacific region mobi sites catering to mobile devices biz business use museum museums cat Catalan language/culture commercial organizations, but unrestricted name cooperatives U.S. post-secondary educational establishments org families and individuals originally for network infrastructures, now unrestricted originally for organizations not clearly falling within the other gTLDs, now unrestricted post postal services pro int U.S. government entities at the federal, state, and local levels informational sites, but unrestricted international organizations established by treaty travel certain professions services involving connections between the telephone network and the Internet travel agents, airlines, hoteliers, tourism bureaus, etc. jobs employment-related sites xxx pornography com coop edu gov info From: Wikipedia, 2013-09-30 net tel ICANN New gTLD Program v Internet Corporation for Assigned Names and Numbers § § § § http://newgtlds.icann.org “Largest-ever expansion of the Domain Name System” ICANN accepting applications for new gTLDs since 2012 1192 “Registry Agreements” signed for new gTLDs as of Sept 25, 2015 • Still more in process v Examples § Commonly used words – .CULTURE, .MUSICAL, .TRUSTED, .PIZZA § Geographic – .WALES, .BUDAPEST § Community – .CLEANWATER, .LITERACY § Brand – .BMW, .YOUTUBE § Internationalized Domain Names – онлайн, 游戏 55 DNS: services, structure DNS services v hostname to IP address translation § “resolving” v host aliasing § canonical, alias names v v mail server aliasing load distribution § replicated Web servers: many IP addresses correspond to one name why not centralize DNS? v v v v single point of failure traffic volume distant centralized database maintenance A: doesn’t scale! Application Layer 2-56 DNS: a distributed, hierarchical database Root DNS Servers … com DNS servers yahoo.com amazon.com DNS servers DNS servers … org DNS servers pbs.org DNS servers edu DNS servers poly.edu umass.edu DNS serversDNS servers client wants IP address for www.amazon.com; 1st approx: v v v client queries 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.com” Application Layer 2-57 DNS: root name servers v v contacted by local name server when it cannot resolve name root name server: § Maintains database of TLD (top-level domain) servers § When contacted, returns list of DNS servers for TLD in question c. Cogent, Herndon, VA (5 other sites) d. U Maryland College Park, MD h. ARL Aberdeen, MD j. Verisign, Dulles VA (69 other sites ) e. NASA Mt View, CA f. Internet Software C. Palo Alto, CA (and 48 other sites) a. Verisign, Los Angeles CA (5 other sites) b. USC-ISI Marina del Rey, CA l. ICANN Los Angeles, CA (41 other sites) g. US DoD Columbus, OH (5 other sites) k. RIPE London (17 other sites) i. Netnod, Stockholm (37 other sites) m. WIDE Tokyo (5 other sites) 13 root name “servers” worldwide Application Layer 2-58 TLD, authoritative servers top-level domain (TLD) servers: § responsible for com, org, net, edu, aero, jobs, museums, and all top-level country domains, e.g.: uk, fr, ca, jp • Network Solutions maintains servers for .com TLD • Educause for .edu TLD § When contacted, returns list of authoritative DNS servers for organization in question authoritative DNS servers: § Organization’s own DNS server(s), providing authoritative hostname to IP mappings for organization’s named hosts § can be maintained by organization or service provider § When contacted, returns host’s IP address(es) • Or, possibly, refers to other servers in the organization Application Layer 2-59 Local DNS name server v v does not strictly belong to hierarchy each ISP (residential ISP, company, university) has one § also called “default name server” • Part of a host’s network configuration v when host makes DNS query, query is sent to its local DNS server § has local cache of recent name-to-address translation pairs (but may be out of date!) § acts as proxy, forwards query into hierarchy Application Layer 2-60 DNS name resolution example v root DNS server 2 host at cis.poly.edu wants IP address for gaia.cs.umass.edu 4 v v contacted server replies with local DNS server dns.poly.edu name of server to contact “I don’t know this name, but ask 1 8 this server” This is what root, TLD, and authoritative DNS server do recursive query: v v contacted server replies with IP address v Resolves name This is what local DNS server does TLD DNS server 5 iterated query: v 3 requesting host 7 6 authoritative DNS server dns.cs.umass.edu cis.poly.edu gaia.cs.umass.edu Application Layer 2-61 DNS: caching, updating records v once (any) name server learns mapping, it caches mapping § cache entries timeout (disappear) after some time (TTL, time to live) § TLD servers typically cached in local name servers • thus root name servers not often visited v cached entries may be out-of-date (best effort name-to-address translation!) § If host changes IP address, may not be known Internetwide until all TTLs expire v update/notify mechanisms proposed IETF standard § RFC 2136 Application Layer 2-62 DNS records DNS: distributed database storing resource records (RR) RR format: (name, type=A § name is hostname § value is IP address type=NS § name is domain (e.g., foo.com) § value is hostname of authoritative name server for this domain value, type, ttl) type=CNAME § name is alias name for some “canonical” (the real) name § www.ibm.com is really servereast.backup2.ibm.com § value is canonical name type=MX § value is name of mailserver associated with name Application Layer 2-63 Inserting records into DNS v v example: new startup “Network Utopia” register name networkuptopia.com at DNS registrar (e.g., Network Solutions) § provide names and IP addresses of authoritative name servers (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) v create authoritative server type A record for www.networkuptopia.com; type MX record for networkutopia.com Application Layer 2-64 Attacking DNS DDoS attacks v Bombard root servers with traffic § Not successful to date § Traffic Filtering § Local DNS servers cache IPs of TLD servers, allowing root server bypass v Bombard TLD servers § Potentially more dangerous Redirect attacks v Man-in-middle § Intercept queries v DNS poisoning § Send bogus entries to DNS server, which caches Exploit DNS for DDoS v Send queries with spoofed source address: target IP v Requires amplification Application Layer 2-65 Chapter 2: outline 2.1 principles of network applications § app architectures § app requirements 2.6 P2P applications 2.7 socket programming with UDP and TCP 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-66 Pure P2P architecture v v v no always-on server arbitrary end systems directly communicate peers are intermittently connected and change IP addresses examples: § file distribution (BitTorrent) § Streaming (Kankan) § VoIP (Skype) Application Layer 2-67 File sharing – In Five Steps § Figuring out what content you want to download • Reading newspapers etc to learn of, e.g., “P2P – The Movie” § Mapping content names to metadata objects • Metadata objects contain information about data objects with the desired content. – “.torrent” files • Searching metadata directories, e.g., The Pirate Bay § Finding and downloading metadata objects • Function no longer provided by, e.g., The Pirate Bay. § Using metadata objects to identify desired data objects • Typically done internally by file sharing application § Finding host(s) capable of providing desired data object(s) • Using tracker, by gossiping, by Distributed Hash Table (DHT), etc Application 2-68 P2P file distribution: BitTorrent v file divided into 256Kb chunks v peers in torrent send/receive file chunks tracker: tracks peers participating in torrent torrent: group of peers exchanging chunks of a file Alice arrives … … obtains list of peers from tracker … and begins exchanging file chunks with peers in torrent Application Layer 2-69 P2P file distribution: BitTorrent v v v v v peer joining torrent: § has no chunks, but will accumulate them over time from other peers § registers with tracker to get list of peers, connects to subset of peers (“neighbors”) while downloading, peer uploads chunks to other peers peer may change peers with whom it exchanges chunks churn: peers may come and go once peer has entire file, it may (selfishly) leave or (altruistically) remain in torrent Application Layer 2-70 BitTorrent: requesting, sending file chunks requesting chunks: v v v at any given time, different peers have different subsets of file chunks periodically, Alice asks each peer for list of chunks that they have Alice requests missing chunks from peers, rarest first sending chunks: tit-for-tat v Alice 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 secs v every 30 secs: randomly select another peer, starts sending chunks § “optimistically unchoke” this peer § newly chosen peer may join top 4 Application Layer 2-71 BitTorrent: tit-for-tat (1) Alice ”optimistically unchokes” Bob (2) Alice becomes one of Bob’s top-four providers; Bob reciprocates (3) Bob becomes one of Alice’s top-four providers higher upload rate: find better trading partners, get file faster! Application Layer 2-72 Distributed Hash Table (DHT) DHT: a distributed P2P database v database has (key, value) pairs; examples: v § key: social security number; value: human name § key: movie title; value: IP address Distribute the (key, value) pairs over the (millions of peers) v a peer queries DHT with key v § DHT returns values that match the key v peers can also insert (key, value) pairs DHTs are used, for example, in BitTorrent’s distributed tracker. The key is a torrent identifier, and the value is the set of IP addresses of the hosts currently in the torrent. Application 2-73 Q: how to assign keys to peers? v central issue: § assigning (key, value) pairs to peers. v basic idea: § convert each key to an integer § Assign integer to each peer § put (key,value) pair in the peer that is closest to the key Application 2-74 DHT identifiers v assign integer identifier to each peer in range [0,2n-1] for some n. § each identifier represented by n bits. v require each key to be an integer in same range v to get integer key, hash original key § e.g., key = hash(”Led Zeppelin IV”) § this is why its is referred to as a distributed ”hash” table Application 2-75 Assign keys to peers v rule: assign key to the peer that has the closest ID. v convention in lecture: closest is the immediate successor of the key. v e.g., n=4; peers: 1,3,4,5,8,10,12,14; § key = 13, then successor peer = 14 § key = 15, then successor peer = 1 Application 2-76 Circular DHT (1) 1 3 15 4 12 5 10 8 each peer only aware of immediate successor and predecessor. v “overlay network” v Application 2-77 Circular DHT (1) O(N) messages on average to resolve query, when there I am are N peers 0001 Who’s responsible for key 1110 ? 0011 1111 1110 0100 1110 1110 1100 1110 Define closest as closest successor 1110 0101 1110 1010 1000 Application 2-78 Circular DHT with shortcuts 1 3 Who’s responsible for key 1110? 15 4 12 5 10 v v v 8 each peer keeps track of IP addresses of predecessor, successor, and short cuts. reduced from 6 to 2 messages. possible to design shortcuts so O(log N) neighbors, O(log N) messages in query Application 2-79 Peer churn handling peer churn: 1 vpeers 3 15 4 12 5 10 may come and go (churn) veach peer knows address of its two successors veach peer periodically pings its two successors to check aliveness vif immediate successor leaves, choose next successor as new immediate successor 8 example: peer 5 abruptly leaves vpeer 4 detects peer 5 departure; makes 8 its immediate successor; asks 8 who its immediate successor is; makes 8’s immediate successor its second successor. vwhat if peer 13 wants to join? Application 2-80 Chapter 2: outline 2.1 principles of network applications § app architectures § app requirements 2.6 P2P applications 2.7 socket programming with UDP and TCP 2.2 Web and HTTP 2.3 FTP 2.4 electronic mail § SMTP, POP3, IMAP 2.5 DNS Application Layer 2-81 Chapter 2: summary our study of network apps now complete! v v v application architectures § client-server § P2P application service requirements: § reliability, bandwidth, delay Internet transport service model § connection-oriented, reliable: TCP § unreliable, datagrams: UDP v v specific protocols: § HTTP § FTP § SMTP, POP, IMAP § DNS § P2P: BitTorrent, DHT socket programming: TCP, UDP sockets Application Layer 2-82 Chapter 2: summary most importantly: learned about protocols! v v 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 communicated important themes: v v v v v control vs. data msgs § in-band, out-of-band centralized vs. decentralized stateless vs. stateful reliable vs. unreliable msg transfer “complexity at network edge” Application Layer 2-83

Use Quizgecko on...
Browser
Browser