Computer Networking CCS-2201/CE-231 PDF
Document Details
Uploaded by GroundbreakingPlatinum
2020
Ehab Abousaif
Tags
Summary
This document details computer networking focusing on the application layer. It includes discussions of application architectures, specific protocols (like HTTP, SMTP, IMAP), and application requirements concerning reliability, bandwidth, and delays. The document also mentions Internet transport service models, including connection-oriented TCP and unreliable UDP.
Full Transcript
Computer Networking CCS-2201/CE-231: Introduction to Networks Dr. Ehab Abousaif PhD in Electrical and Computer Eng., University of Idaho, USA IEEE member, IMAPS member College of Computing and Information Technology, AASTMT Cell: 01114757888 Email: [email protected] Chapter 2 Application Layer...
Computer Networking CCS-2201/CE-231: Introduction to Networks Dr. Ehab Abousaif PhD in Electrical and Computer Eng., University of Idaho, USA IEEE member, IMAPS member College of Computing and Information Technology, AASTMT Cell: 01114757888 Email: [email protected] Chapter 2 Application Layer Computer Networking: A A note on the use of these PowerPoint slides: Top-Down Approach These slides are based on the original slides made by the authors of the book. 8th edition These slides are a modified version of the original slides and have the same copyrights for Jim Kurose, Keith Ross the authors and for Dr. Ehab Abousaif who modify the slides and put it into this final form. Pearson, 2020 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-1 Application layer: overview P2P applications Principles of network video streaming and content applications distribution networks Web and HTTP socket programming with E-mail, SMTP, IMAP UDP and TCP The Domain Name System DNS Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-2 Application layer: overview Our goals: learn about protocols by examining popular application- conceptual and layer protocols and implementation aspects of infrastructure HTTP application-layer protocols SMTP, IMAP transport-layer service DNS models video streaming systems, Content Distribution Networks (CDNs) client-server paradigm programming network peer-to-peer paradigm applications socket API (Application Programming Interface) Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-3 Some network apps social networking voice over IP (e.g., Skype) Web real-time video conferencing text messaging (e.g., Zoom) e-mail Internet search multi-user network games remote login streaming stored video … (YouTube, Hulu, Netflix) P2P file sharing Q: your favorites? Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-4 Creating a network app application write programs that: transport mobile network network data link physical run on (different) end systems national or global ISP communicate over network e.g., web server software communicates with browser software local or no need to write software for regional ISP network-core devices home network content application network-core devices do not run user transport network provider network datacenter applications data link physical application transport network network applications on end systems allows data link physical for rapid app development, enterprise propagation network Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-5 Client-server paradigm server: mobile network always-on host national or global ISP permanent IP address often in data centers, for scaling clients: local or regional ISP contact, communicate with server may be intermittently connected home network content provider may have dynamic IP addresses network datacenter network do not communicate directly with each other enterprise examples: HTTP, IMAP, FTP network Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-6 Peer-peer architecture no always-on server mobile network arbitrary end systems directly national or global ISP communicate peers request service from other peers, provide service in return to other peers local or regional ISP self scalability – new peers bring new service capacity, as well as new service home network content demands provider network datacenter peers are intermittently connected network and change IP addresses complex management enterprise example: P2P file sharing network Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-7 Processes communicating process: program running clients, servers within a host client process: process that initiates communication within same host, two server process: process processes communicate that waits to be contacted using inter-process communication (defined by OS) note: applications with P2P architectures have processes in different hosts client processes & communicate by exchanging server processes messages Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-8 Sockets process sends/receives messages to/from its socket socket analogous to door sending process shoves message out door sending process relies on transport infrastructure on other side of door to deliver message to socket at receiving process two sockets involved: one on each side application application socket controlled by process process app developer transport transport network network controlled link by OS link Internet physical physical Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-9 Addressing processes to receive messages, process identifier includes both IP address must have identifier and port numbers associated with host device has unique 32-bit process on host. IP address example port numbers: IP address of host on which HTTP server: 80 process runs is not sufficient mail server: 25 for identifying the process. to send HTTP message to Why? gaia.cs.umass.edu web server: Because many processes can IP address: 128.119.245.12 be running on same host port number: 80 more shortly… Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-10 An application-layer protocol defines: types of messages exchanged, open protocols: e.g., request, response defined in RFCs, everyone message syntax: has access to protocol what fields in messages & definition how fields are delineated allows for interoperability message semantics e.g., HTTP, SMTP meaning of information in proprietary (non-published) fields protocols: rules for when and how e.g., Skype, Zoom processes send & respond to messages Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-11 What transport service does an app need? data integrity throughput some apps (e.g., file transfer, some apps (e.g., multimedia) web transactions) require require minimum amount of 100% reliable data transfer throughput to be “effective” other apps (e.g., audio) can other apps (“elastic apps”) tolerate some loss make use of whatever throughput they get timing some apps (e.g., Internet security telephony, interactive games) encryption, data integrity, require low delay to be “effective” … Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-12 Transport service requirements: common apps application data loss throughput time sensitive? file transfer/download no loss elastic no e-mail no loss elastic no Web documents no loss elastic no real-time audio/video loss-tolerant audio: 5Kbps-1Mbps yes, 10’s msec video:10Kbps-5Mbps streaming audio/video loss-tolerant same as above yes, few secs interactive games loss-tolerant Kbps+ yes, 10’s msec text messaging no loss elastic yes and no Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-13 Internet transport protocols services TCP service: UDP service: reliable transport between sending unreliable data transfer and receiving process between sending and receiving flow control: sender won’t process overwhelm receiver does not provide: reliability, congestion control: throttle sender flow control, congestion when network overloaded control, timing, throughput guarantee, security, or connection-oriented: setup required connection setup. between client and server processes does not provide: timing, minimum Q: why bother? Why throughput guarantee, security is there a UDP? Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-14 Internet applications, and transport protocols application application layer protocol transport protocol file transfer/download FTP [RFC 959] TCP e-mail SMTP [RFC 5321] TCP Web documents HTTP 1.1 [RFC 7320] TCP Internet telephony SIP [RFC 3261], RTP [RFC TCP or UDP 3550], or proprietary streaming audio/video HTTP [RFC 7320], DASH TCP interactive games WOW, FPS (proprietary) UDP or TCP Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-15 Securing TCP TCP & UDP sockets: TSL implemented in no encryption application layer cleartext passwords sent into socket apps use TSL libraries, that traverse Internet in cleartext (!) use TCP in turn Transport Layer Security (TLS) cleartext sent into “socket” provides encrypted TCP connections traverse Internet encrypted data integrity more: Chapter 8 end-point authentication Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-16 Application layer: overview P2P applications Principles of network video streaming and content applications distribution networks Web and HTTP socket programming with E-mail, SMTP, IMAP UDP and TCP The Domain Name System DNS Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-17 Web and HTTP First, a quick review… web page consists of objects, each of which can be stored on different Web servers object can be HTML file, JPEG image, Java applet, audio file,… web page consists of base HTML-file which includes several referenced objects, each addressable by a URL, e.g., www.someschool.edu/someDept/pic.gif host name path name Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-18 HTTP overview HTTP: hypertext transfer protocol Web’s application-layer protocol client/server model: PC running client: browser that requests, Firefox browser receives, (using HTTP protocol) and “displays” Web objects server running server: Web server sends (using Apache Web HTTP protocol) objects in response server to requests iPhone running Safari browser Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-19 HTTP overview (continued) HTTP uses TCP: HTTP is “stateless” client initiates TCP connection server maintains no (creates socket) to server, port 80 information about past client server accepts TCP connection requests from client aside protocols that maintain “state” HTTP messages (application-layer are complex! protocol messages) exchanged past history (state) must be between browser (HTTP client) and maintained Web server (HTTP server) if server/client crashes, their views TCP connection closed of “state” may be inconsistent, must be reconciled Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-20 HTTP connections: two types Non-persistent HTTP Persistent HTTP 1. TCP connection opened TCP connection opened to 2. at most one object sent a server over TCP connection multiple objects can be 3. TCP connection closed sent over single TCP connection between client, downloading multiple and that server objects required multiple TCP connection closed connections Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-21 Non-persistent HTTP: example User enters URL: www.someSchool.edu/someDepartment/home.index (containing text, references to 10 jpeg images) 1a. HTTP client initiates TCP connection to HTTP server 1b. HTTP server at host (process) at www.someSchool.edu on www.someSchool.edu waiting for TCP port 80 connection at port 80 “accepts” connection, notifying client 2. HTTP client sends HTTP request message (containing URL) into TCP connection 3. HTTP server receives request message, socket. Message indicates forms response message containing time that client wants object requested object, and sends message someDepartment/home.index into its socket Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-22 Non-persistent HTTP: example (cont.) User enters URL: www.someSchool.edu/someDepartment/home.index (containing text, references to 10 jpeg images) 4. HTTP server closes TCP 5. HTTP client receives response connection. message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects 6. Steps 1-5 repeated for each of 10 jpeg objects time Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-23 Non-persistent HTTP: response time RTT (Round Trip Time): time for a small packet to travel from client to initiate TCP server and back connection RTT HTTP response time (per object): one RTT to initiate TCP connection request file one RTT for HTTP request and first few RTT time to transmit bytes of HTTP response to return file file received object/file transmission time time time Non-persistent HTTP response time = 2RTT+ file transmission time Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-24 Persistent HTTP (HTTP 1.1) Non-persistent HTTP issues: Persistent HTTP (HTTP1.1): requires 2 RTTs per object server leaves connection open after OS overhead for each TCP sending response connection subsequent HTTP messages browsers often open multiple between same client/server sent parallel TCP connections to over open connection fetch referenced objects in client sends requests as soon as it parallel encounters a referenced object as little as one RTT for all the referenced objects (cutting response time in half) Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-25 HTTP request message two types of HTTP messages: request, response HTTP request message: ASCII (human-readable format) carriage return character line-feed character request line (GET, POST, GET /index.html HTTP/1.1\r\n HEAD commands) Host: www-net.cs.umass.edu\r\n User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:80.0) Gecko/20100101 Firefox/80.0 \r\n header Accept: text/html,application/xhtml+xml\r\n lines Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Connection: keep-alive\r\n carriage return, line feed \r\n at start of line indicates end of header lines Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-26 HTTP request message: general format method sp URL sp version cr lf request line header field name value cr lf header ~ ~ ~ ~ lines header field name value cr lf cr lf ~ ~ entity body ~ ~ body Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-27 Other HTTP request messages POST method: HEAD method: web page often includes form requests headers (only) that input would be returned if specified user input sent from client to URL were requested with an server in entity body of HTTP HTTP GET method. POST request message PUT method: uploads new file (object) to server GET method (for sending data to server): completely replaces file that exists include user data in URL field of HTTP at specified URL with content in GET request message (following a ‘?’): entity body of POST HTTP request www.somesite.com/animalsearch?monkeys&banana message Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-28 HTTP response message status line (protocol HTTP/1.1 200 OK status code status phrase) Date: Tue, 08 Sep 2020 00:53:20 GMT Server: Apache/2.4.6 (CentOS) OpenSSL/1.0.2k-fips PHP/7.4.9 mod_perl/2.0.11 Perl/v5.16.3 header Last-Modified: Tue, 01 Mar 2016 18:57:50 GMT lines ETag: "a5b-52d015789ee9e" Accept-Ranges: bytes Content-Length: 2651 Content-Type: text/html; charset=UTF-8 \r\n data, e.g., requested data data data data data... HTML file Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-29 HTTP response status codes status code appears in 1st line in server-to-client response message. some sample codes: 200 OK request succeeded, requested object later in this message 301 Moved Permanently requested object moved, new location specified later in this message (in Location: field) 400 Bad Request request msg not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-30 Maintaining user/server state: cookies a stateful protocol: client makes Recall: HTTP GET/response two changes to X, or none at all interaction is stateless X no notion of multi-step exchanges of HTTP messages to complete a Web X “transaction” no need for client/server to track X’ “state” of multi-step exchange t’ all HTTP requests are independent of X’’ each other no need for client/server to “recover” X’’ from a partially-completed-but-never- time completely-completed transaction time Q: what happens if network connection or client crashes at t’ ? Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-31 Maintaining user/server state: cookies Web sites and client browser use Example: cookies to maintain some state Susan uses browser on laptop, visits specific e-commerce site between transactions for first time four components: when initial HTTP requests 1) cookie header line of HTTP response arrives at site, site creates: message unique ID (aka “cookie”) entry in backend database 2) cookie header line in next HTTP for ID request message subsequent HTTP requests 3) cookie file kept on user’s host, from Susan to this site will managed by user’s browser contain cookie ID value, 4) back-end database at Web site allowing site to “identify” Susan Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-32 Maintaining user/server state: cookies client server ebay 8734 usual HTTP request msg Amazon server cookie file creates ID usual HTTP response 1678 for user backend create ebay 8734 set-cookie: 1678 entry database amazon 1678 usual HTTP request msg cookie: 1678 cookie- access specific usual HTTP response msg action one week later: access ebay 8734 usual HTTP request msg amazon 1678 cookie: 1678 cookie- specific usual HTTP response msg action time time Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-33 HTTP cookies: comments aside What cookies can be used for: cookies and privacy: authorization cookies permit sites to shopping carts learn a lot about you on their site. recommendations third party persistent user session state (Web e-mail) cookies (tracking cookies) allow common identity (cookie value) to be Challenge: How to keep state? tracked across multiple at protocol endpoints: maintain state at web sites sender/receiver over multiple transactions in messages: cookies inHTTP messages carry state Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-34 Example: displaying a NY Times web page 1 GET base html file 2 from nytimes.com 4 fetch ad from nytimes.com 5 AdX.com HTTP 1 2 HTTP 7 display composed GET reply page 3 4 6 5 NY times page with embedded ad displayed AdX.com Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-35 Cookies: tracking a user’s browsing behavior 1634: sports, 2/15/22 nytimes.com (sports) “first party” cookie – from website you chose to visit (provides base HTTP HTTP GET reply html file) Set cookie: 1634 HTTP GET Referer: NY Times Sports 4 7493: NY Times sports, 2/15/22 5 “third party” cookie – HTTP reply from website you did not Set cookie: 7493 choose to visit NY Times: 1634 AdX: 7493 AdX.com Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-36 Cookies: tracking a user’s browsing behavior 1634: sports, 2/15/22 nytimes.com AdX: tracks my web browsing socks.com over sites with AdX ads 2 HTTP 1 can return targeted ads GET based on browsing history HTTP GET Referer: socks.com, cookie: 7493 4 7493: NY Times sports, 2/15/22 5 7493: socks.com, 2/16/22 HTTP reply Set cookie: 7493 NY Times: 1634 AdX: 7493 AdX.com Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-37 Cookies: tracking a user’s browsing behavior (one day later) 1634: sports, 2/15/22 1634: arts, 2/17/22 nytimes.com (arts) socks.com HTTP HTTP GET reply cookie: 1634 Set cookie: 1634 HTTP GET Referer:nytimes.com, cookie: 7493 4 7493: NY Times sports, 2/15/22 5 7493: socks.com, 2/16/22 HTTP reply 7493: NY Times arts, 2/15/22 NY Times: 1634 Set cookie: 7493 AdX: 7493 Returned ad for socks! AdX.com Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-38 Cookies: tracking a user’s browsing behavior Cookies can be used to: track user behavior on a given website (first party cookies) track user behavior across multiple websites (third party cookies) without user ever choosing to visit tracker site (!) tracking may be invisible to user: rather than displayed ad triggering HTTP GET to tracker, could be an invisible link third party tracking via cookies: disabled by default in Firefox, Safari browsers to be disabled in Chrome browser in 2023 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-39 GDPR (EU General Data Protection Regulation) and cookies “Natural persons may be associated with online identifiers […] such as internet protocol addresses, cookie identifiers or other identifiers […]. This may leave traces which, in particular when combined with unique identifiers and other information received by the servers, may be used to create profiles of the natural persons and identify them.” GDPR, recital 30 (May 2018) User has explicit control over when cookies can identify an individual, cookies whether or not cookies are are considered personal data, subject to GDPR allowed personal data regulations Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-40 Web caches Goal: satisfy client requests without involving origin server user configures browser to point to a (local) Web cache Web cache browser sends all HTTP client origin requests to cache server if object in cache: cache returns object to client else cache requests object client from origin server, caches received object, then returns object to client Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-41 Web caches (aka proxy servers) Web cache acts as both Why Web caching? client and server reduce response time for client server for original requesting client request client to origin server cache is closer to client reduce traffic on an institution’s server tells cache about object’s allowable caching in access link response header: Internet is dense with caches enables “poor” content providers to more effectively deliver content Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-42 Caching example Scenario: access link rate: 1.54 Mbps origin RTT from institutional router to server: 2 sec servers public web object size: 100K bits Internet average request rate from browsers to origin servers: 15/sec avg data rate to browsers: 1.50 Mbps 1.54 Mbps access link Performance: problem: large institutional access link utilization =.97 queueing delays network 1 Gbps LAN LAN utilization:.0015 at high utilization! end-end delay = Internet delay + access link delay + LAN delay = 2 sec + minutes + usecs Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-43 Option 1: buy a faster access link Scenario: 154 Mbps access link rate: 1.54 Mbps origin RTT from institutional router to server: 2 sec servers public web object size: 100K bits Internet average request rate from browsers to origin servers: 15/sec avg data rate to browsers: 1.50 Mbps 154 Mbps 1.54 Mbps access link Performance: institutional access link utilization =.97.0097 network 1 Gbps LAN LAN utilization:.0015 end-end delay = Internet delay + access link delay + LAN delay = 2 sec + minutes + usecs Cost: faster access link (expensive!) msecs Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-44 Option 2: install a web cache Scenario: access link rate: 1.54 Mbps origin RTT from institutional router to server: 2 sec servers public web object size: 100K bits Internet average request rate from browsers to origin servers: 15/sec avg data rate to browsers: 1.50 Mbps 1.54 Mbps access link Cost: web cache (cheap!) institutional network Performance: 1 Gbps LAN LAN utilization:.? How to compute link access link utilization = ? utilization, delay? local web cache average end-end delay = ? Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-45 Calculating access link utilization, end-end delay with cache: suppose cache hit rate is 0.4: 40% requests served by cache, with low origin servers (msec) delay public 60% requests satisfied at origin Internet rate to browsers over access link = 0.6 * 1.50 Mbps =.9 Mbps 1.54 Mbps access link utilization = 0.9/1.54 =.58 means access link low (msec) queueing delay at access link institutional average end-end delay: network 1 Gbps LAN = 0.6 * (delay from origin servers) + 0.4 * (delay when satisfied at cache) = 0.6 (2.01) + 0.4 (~msecs) = ~ 1.2 secs local web cache lower average end-end delay than with 154 Mbps link (and cheaper too!) Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-46 Browser caching: Conditional GET client server Goal: don’t send object if browser HTTP request msg has up-to-date cached version If-modified-since: object not no object transmission delay (or use modified of network resources) HTTP response before HTTP/1.0 client: specify date of browser- 304 Not Modified cached copy in HTTP request If-modified-since: server: response contains no HTTP request msg If-modified-since: object object if browser-cached copy is modified up-to-date: HTTP response HTTP/1.0 200 OK after HTTP/1.0 304 Not Modified Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-47 HTTP/2 Key goal: decreased delay in multi-object HTTP requests HTTP1.1: introduced multiple, pipelined GETs over single TCP connection server responds in-order (FCFS: first-come-first-served scheduling) to GET requests with FCFS, small object may have to wait for transmission (head-of- line (HOL) blocking) behind large object(s) loss recovery (retransmitting lost TCP segments) stalls object transmission Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-48 HTTP/2 Key goal: decreased delay in multi-object HTTP requests HTTP/2: [RFC 7540, 2015] increased flexibility at server in sending objects to client: methods, status codes, most header fields unchanged from HTTP 1.1 transmission order of requested objects based on client-specified object priority (not necessarily FCFS) push unrequested objects to client divide objects into frames, schedule frames to mitigate HOL blocking Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-49 HTTP/2: mitigating HOL blocking HTTP 1.1: client requests 1 large object (e.g., video file) and 3 smaller objects server GET O4 GET O3 GET O 2 GET O1 object data requested client O1 O2 O1 O2 O3 O3 O4 O4 objects delivered in order requested: O2, O3, O4 wait behind O1 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-50 HTTP/2: mitigating HOL blocking HTTP/2: objects divided into frames, frame transmission interleaved server GET O4 GET O3 GET O 2 GET O1 object data requested client O2 O4 O3 O1 O2 O3 O1 O4 O2, O3, O4 delivered quickly, O1 slightly delayed Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-51 HTTP/2 to HTTP/3 HTTP/2 over single TCP connection means: recovery from packet loss still stalls all object transmissions as in HTTP 1.1, browsers have incentive to open multiple parallel TCP connections to reduce stalling, increase overall throughput no security over vanilla TCP connection HTTP/3: adds security, per object error- and congestion- control (more pipelining) over UDP more on HTTP/3 in transport layer Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-52 Application layer: overview P2P applications Principles of network video streaming and content applications distribution networks Web and HTTP socket programming with E-mail, SMTP, IMAP UDP and TCP The Domain Name System DNS Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-53 E-mail user agent Three major components: mail user user agents server agent mail servers SMTP mail user server agent simple mail transfer protocol: SMTP SMTP User Agent SMTP user agent mail a.k.a. “mail reader” server user composing, editing, reading mail messages agent user e.g., Outlook, iPhone mail client agent outgoing outgoing, incoming messages stored on message queue server user mailbox Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-54 E-mail: mail servers user agent mail servers: mail user server agent mailbox contains incoming messages for user SMTP mail user server agent message queue of outgoing (to be SMTP sent) mail messages SMTP user SMTP protocol between mail mail server agent servers to send email messages user agent client: sending mail server user “server”: receiving mail server agent outgoing message queue user mailbox Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-55 SMTP RFC (5321) “client” SMTP server “server” SMTP server uses TCP to reliably transfer email message initiate TCP from client (mail server initiating connection connection) to server, port 25 RTT TCP connection direct transfer: sending server (acting like client) initiated to receiving server three phases of transfer 220 SMTP handshaking (greeting) SMTP HELO handshaking SMTP transfer of messages 250 Hello SMTP closure command/response interaction (like HTTP) SMTP commands: ASCII text transfers response: status code and phrase time Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-56 Scenario: Alice sends e-mail to Bob 1) Alice uses UA to compose e-mail 4) SMTP client sends Alice’s message message “to” [email protected] over the TCP connection 2) Alice’s UA sends message to her 5) Bob’s mail server places mail server using SMTP; message the message in Bob’s placed in message queue mailbox 3) client side of SMTP at mail server 6) Bob invokes his user opens TCP connection with Bob’s mail agent to read message server 1 user mail user mail agent agent server server 2 3 6 4 5 Alice’s mail server Bob’s mail server Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-57 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 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-58 SMTP: observations comparison with HTTP: SMTP uses persistent connections HTTP: client pull SMTP requires message SMTP: client push (header & body) to be in both have ASCII command/response 7-bit ASCII interaction, status codes SMTP server uses CRLF.CRLF to determine HTTP: each object encapsulated in its end of message own response message SMTP: multiple objects sent in multipart message Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-59 Mail message format SMTP: protocol for exchanging e-mail messages, defined in RFC 5321 (like RFC 7231 defines HTTP) RFC 2822 defines syntax for e-mail message itself (like HTML defines syntax for web documents) header lines, e.g., header blank To: line From: Subject: these lines, within the body of the email body message area different from SMTP MAIL FROM:, RCPT TO: commands! Body: the “message” , ASCII characters only Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-60 Retrieving email: mail access protocols user e-mail access user SMTP SMTP protocol agent agent (e.g., IMAP, HTTP) sender’s e-mail receiver’s e-mail server server SMTP: delivery/storage of e-mail messages to receiver’s server mail access protocol: retrieval from server IMAP: Internet Mail Access Protocol [RFC 3501]: messages stored on server, IMAP provides retrieval, deletion, folders of stored messages on server HTTP: gmail, Hotmail, Yahoo!Mail, etc. provides web-based interface on top of STMP (to send), IMAP (or POP) to retrieve e-mail messages Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-61 Application Layer: Overview P2P applications Principles of network video streaming and content applications distribution networks Web and HTTP socket programming with E-mail, SMTP, IMAP UDP and TCP The Domain Name System DNS Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-62 DNS: Domain Name System people: many identifiers: Domain Name System (DNS): SSN, name, passport # distributed database implemented in Internet hosts, routers: hierarchy of many name servers IP address (32 bit) - used for application-layer protocol: hosts, DNS addressing datagrams servers communicate to resolve “name”, e.g., cs.umass.edu - names (address/name translation) used by humans note: core Internet function, Q: how to map between IP implemented as application-layer address and name, and vice protocol versa ? complexity at network’s “edge” Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-63 DNS: services, structure DNS services: Q: Why not centralize DNS? hostname-to-IP-address translation single point of failure traffic volume host aliasing distant centralized database canonical, alias names maintenance mail server aliasing load distribution A: doesn‘t scale! replicated Web servers: many IP Comcast DNS servers alone: addresses correspond to one 600B DNS queries/day name Akamai DNS servers alone: 2.2T DNS queries/day Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-64 Thinking about the DNS humongous distributed database: ~ billion records, each simple handles many trillions of queries/day: many more reads than writes performance matters: almost every Internet transaction interacts with DNS - msecs count! organizationally, physically decentralized: millions of different organizations responsible for their records “bulletproof”: reliability, security Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-65 DNS: a distributed, hierarchical database Root DNS Servers Root … ….com DNS servers.org DNS servers.edu DNS servers Top Level Domain … … … … yahoo.com amazon.com pbs.org nyu.edu umass.edu DNS servers DNS servers DNS servers DNS servers DNS servers Authoritative Client wants IP address for www.amazon.com; 1st approximation: 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 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-66 DNS: root name servers official, contact-of-last-resort by name servers that can not resolve name Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-67 DNS: root name servers official, contact-of-last-resort by name servers that can not 13 logical root name “servers” worldwide each “server” replicated resolve name many times (~200 servers in US) incredibly important Internet function Internet couldn’t function without it! DNSSEC – provides security (authentication, message integrity) ICANN (Internet Corporation for Assigned Names and Numbers) manages root DNS domain Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-68 Top-Level Domain, and authoritative servers Top-Level Domain (TLD) servers: responsible for.com,.org,.net,.edu,.aero,.jobs,.museums, and all top-level country domains, e.g.:.cn,.uk,.fr,.ca,.jp Network Solutions: authoritative registry for.com,.net TLD Educause:.edu TLD 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 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-69 Local DNS name servers when host makes DNS query, it is sent to its local DNS server Local DNS server returns reply, answering: from its local cache of recent name-to-address translation pairs (possibly out of date!) forwarding request into DNS hierarchy for resolution each ISP has local DNS name server; to find yours: MacOS: % scutil --dns Windows: >ipconfig /all local DNS server doesn’t strictly belong to hierarchy Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-70 DNS name resolution: iterated query root DNS server Example: host at engineering.nyu.edu wants IP address for gaia.cs.umass.edu 2 3 TLD DNS server Iterated query: 1 4 contacted server replies 8 5 with name of server to requesting host at local DNS server contact engineering.nyu.edu dns.nyu.edu gaia.cs.umass.edu “I don’t know this name, 7 6 but ask this server” authoritative DNS server dns.cs.umass.edu Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-71 DNS name resolution: recursive query root DNS server Example: host at engineering.nyu.edu wants IP address for gaia.cs.umass.edu 2 3 7 6 Recursive query: 1 TLD DNS server puts burden of name 8 resolution on requesting host at local DNS server 5 4 engineering.nyu.edu dns.nyu.edu contacted name gaia.cs.umass.edu server heavy load at upper authoritative DNS server levels of hierarchy? dns.cs.umass.edu Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-72 Caching DNS Information once (any) name server learns mapping, it caches mapping, and immediately returns a cached mapping in response to a query caching improves response time cache entries timeout (disappear) after some time called: Time-to- Live (TTL). TLD servers typically cached in local name servers cached entries may be out-of-date if named host changes IP address, may not be known Internet-wide until all TTLs expire! best-effort name-to-address translation! Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-73 DNS records DNS: distributed database storing Resource Records (RR) RR format: (name, value, type, ttl) type=A type=CNAME name is hostname name is alias name for some “canonical” value is IP address (the real) name www.ibm.com is really servereast.backup2.ibm.com type=NS value is canonical name name is domain (e.g., foo.com) value is hostname of type=MX authoritative name server for value is name of SMTP mail this domain server associated with name Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-74 DNS protocol messages DNS query and reply messages, both have same format: 2 bytes 2 bytes message header: identification flags identification: 16 bit # for query, # questions # answer RRs reply to query uses same # # authority RRs # additional RRs flags: questions (variable # of questions) query or reply recursion desired answers (variable # of RRs) recursion available reply is authoritative authority (variable # of RRs) additional info (variable # of RRs) Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-75 DNS protocol messages DNS query and reply messages, both have same format: 2 bytes 2 bytes identification flags # questions # answer RRs # authority RRs # additional RRs name, type fields for a query questions (variable # of questions) RRs in response to query answers (variable # of RRs) records for authoritative servers authority (variable # of RRs) additional “ helpful” info that may additional info (variable # of RRs) be used Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-76 Getting your info into the DNS example: new startup “Network Utopia” register name networkuptopia.com at DNS registrar (e.g., Network Solutions) provide names, IP addresses of authoritative name server (primary and secondary) registrar inserts NS, A RRs into.com TLD server: (networkutopia.com, dns1.networkutopia.com, NS) (dns1.networkutopia.com, 212.212.212.1, A) create authoritative server locally with IP address 212.212.212.1 type A record for www.networkuptopia.com type MX record for networkutopia.com Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-77 DNS security DDoS attacks Spoofing attacks bombard root servers with intercept DNS queries, traffic returning bogus replies not successful to date DNS cache poisoning traffic filtering RFC 4033: DNSSEC authentication services local DNS servers cache IPs of TLD servers, allowing root server bypass bombard TLD servers potentially more dangerous Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-78 Application layer: overview P2P applications Principles of network video streaming and content applications distribution networks Web and HTTP socket programming with E-mail, SMTP, IMAP UDP and TCP The Domain Name System DNS Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-79 Video Streaming and CDNs: context stream video traffic: major consumer of Internet bandwidth Netflix, YouTube, Amazon Prime, Hulu: 80% of residential ISP traffic (2020) challenge: scale - how to reach ~1B users? challenge: heterogeneity different users have different capabilities (e.g., wired versus mobile; bandwidth rich versus bandwidth poor) solution: distributed, application-level infrastructure Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-80 Multimedia: video spatial coding example: instead of sending N values of same color (all purple), send only two values: color value (purple) and video: sequence of images number of repeated values (N) displayed at constant rate …………………….. ……………….……. e.g., 24 images/sec digital image: array of pixels each pixel represented by bits coding: use redundancy within and frame i between images to decrease # bits used to encode image spatial (within image) temporal coding example: instead of sending temporal (from one image to complete frame at i+1, next) send only differences from frame i frame i+1 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-81 Multimedia: video spatial coding example: instead of sending N values of same color (all purple), send only two values: color value (purple) and CBR: (constant bit rate): video number of repeated values (N) encoding rate fixed …………………….. ……………….……. VBR: (variable bit rate): video encoding rate changes as amount of spatial, temporal coding changes examples: frame i MPEG 1 (CD-ROM) 1.5 Mbps MPEG2 (DVD) 3-6 Mbps temporal coding example: MPEG4 (often used in instead of sending complete frame at i+1, Internet, 64Kbps – 12 Mbps) send only differences from frame i frame i+1 Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-82 Streaming stored video simple scenario: Internet video server client (stored video) Main challenges: server-to-client bandwidth will vary over time, with changing network congestion levels (in house, access network, network core, video server) packet loss, delay due to congestion will delay playout, or result in poor video quality Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-83 Streaming stored video 2. video sent 1. video 3. video received, played out at client recorded (30 frames/sec) (e.g., 30 time network delay frames/sec) (fixed in this example) streaming: at this time, client playing out early part of video, while server still sending later part of video Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-84 Streaming stored video: challenges continuous playout constraint: during client video playout, playout timing must match original timing … but network delays are variable (jitter), so will need client-side buffer to match continuous playout constraint other challenges: client interactivity: pause, fast-forward, rewind, jump through video video packets may be lost, retransmitted Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-85 Streaming stored video: playout buffering constant bit rate video client video constant bit transmission reception rate video playout at client variable network buffered video delay client playout time delay client-side buffering and playout delay: compensate for network-added delay, delay jitter Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-86 Dynamic, Adaptive Streaming multimedia: DASH Streaming over HTTP server: divides video file into multiple chunks... each chunk encoded at multiple different rates... different rate encodings stored in different files ? files replicated in various CDN nodes... manifest file: provides URLs for different chunks client client: periodically estimates server-to-client bandwidth consulting manifest, requests one chunk at a time chooses maximum coding rate sustainable given current bandwidth can choose different coding rates at different points in time (depending on available bandwidth at time), and from different servers Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-87 Streaming multimedia: DASH “intelligence” at client: client determines... when to request chunk (so that buffer... starvation, or overflow does not occur) ? what encoding rate to request (higher... client quality when more bandwidth available) where to request chunk (can request from URL server that is “close” to client or has high available bandwidth) Streaming video = encoding + DASH + playout buffering Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-88 Content distribution networks (CDNs) challenge: how to stream content (selected from millions of videos) to hundreds of thousands of simultaneous users? option 1: single, large “mega- server” single point of failure point of network congestion long (and possibly congested) path to distant clients ….quite simply: this solution doesn’t scale Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-89 Content distribution networks (CDNs) challenge: how to stream content (selected from millions of videos) to hundreds of thousands of simultaneous users? option 2: store/serve multiple copies of videos at multiple geographically distributed sites (CDN) enter deep: push CDN servers deep into many access networks close to users Akamai: 240,000 servers deployed in > 120 countries (2015) bring home: smaller number (10’s) of larger clusters in POPs near access nets used by Limelight Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-90 Case study: Netflix Netflix cloud upload copies of multiple versions of video to CDN servers CDN server Netflix registration, accounting servers Bob browses Netflix video CDN 2 Manifest file, server requested 1 3 returned for Bob manages specific video Netflix account CDN 4 server DASH server selected, contacted, streaming begins Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-91 Case study: Netflix CDN: stores copies of content (e.g. MADMEN) at CDN nodes subscriber requests content, service provider returns manifest using manifest, client retrieves content at highest supportable rate may choose different rate or copy if network path congested manifest file where’s Madmen? Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-92 Case study: Netflix OTT: “over the top” Internet host-host communication as a service OTT challenges: coping with a congested Internet from the “edge” what content to place in which CDN node? from which CDN node to retrieve content? At which rate? Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-93 CDN content access: a closer look Bob (client) requests video http://netcinema.com/6Y7B23V video stored in CDN at http://KingCDN.com/NetC6y&B23V 1. Bob gets URL for video http://netcinema.com/6Y7B23V from netcinema.com web page 2. resolve http://netcinema.com/6Y7B23V 2 via Bob’s local DNS 1 6. request video from 5 Bob’s KINGCDN server, local DNS streamed via HTTP server 3. netcinema’s DNS returns CNAME for netcinema.com 4 http://KingCDN.com/NetC6y&B23V 3 netcinema’s authoratative DNS KingCDN.com KingCDN authoritative DNS Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-94 Chapter 2: Summary our study of network application layer is now complete! application architectures specific protocols: client-server HTTP P2P SMTP, IMAP DNS application service requirements: P2P: BitTorrent reliability, bandwidth, delay video streaming, CDNs Internet transport service model connection-oriented, reliable: TCP unreliable, datagrams: UDP Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-95 Chapter 2: Summary Most importantly: learned about protocols! typical request/reply message important themes: exchange: centralized vs. decentralized client requests info or service stateless vs. stateful server responds with data, status code scalability message formats: reliable vs. unreliable headers: fields giving info about data message transfer data: info(payload) being “complexity at network communicated edge” Copyrights ©Dr. Ehab Abousaif – Application Layer: 2-96