Chapter 9 More on HTTP and DNS Professor Rick Han University of Colorado at Boulder rhan@cs.colorado.edu Announcements • • • • • HW #4 due April 16 Programming Assignment #3 Thursday Midterm solutions on Web Lecture slides from last week on the Web Next, more on HTTP and DNS, also SMTP Prof. Rick Han, University of Colorado at Boulder Recap of Previous Lecture • HTTP • • • • A Simple Stateless Request-Response Protocol Simplicity leads to poor interaction with TCP Persistent HTTP 1.1 multiplexes multiple HTTP requests onto a single TCP connection Caching Proxies • Reduce client response time • Reduce wide-area network traffic • Reduce server processing • Combining Caching and Prefetching Prof. Rick Han, University of Colorado at Boulder More on HTTP • Configure the Web browser to access the Web via the HTTP proxy: • • Internet Explorer: Tools Internet Options Connections LAN Settings Netscape: Edit Preferences Advanced Proxies Manual • DNS lookup by HTTP Proxy • • Given URL http://www.cs.colorado.edu/index.html, then proxy must call DNS to translate www.cs.colorado.edu to 128.138.242.195 Then, proxy establishes HTTP over TCP connection to 128.138.242.195 to retrieve URL’s page Prof. Rick Han, University of Colorado at Boulder More on HTTP (2) • Most browsers now support HTTP 1.1 • Compatibility with HTTP 1.0 is “expected” but not mandated • Eased via HTTP proxies • Load balancing via HTTP Redirect • In response to a GET request, a server can return an HTTP Redirect Response • Server selects another server that is less loaded • Client is redirected to again send GET request to less loaded server Redirect (2) HTTP HTTP Server 2 Server 1 GET (1) Client GET (3) Prof. Rick Han, University of Colorado at Boulder • GET: • • • • More on HTTP (3) Retrieve document, No payload One-step roundtrip process Incorporate parameters via long URL The server returns a response file with a MIME header identifying the type of file. • MIME was developed for email, but is reused by HTTP • POST: sent from Client to Server • • • • typically used by HTML <form> to send data to a back-end CGI script Two-roundtrip process: contact form-processing server, then send data Give information to a server, has payload Expect a response Prof. Rick Han, University of Colorado at Boulder More on HTTP (4) • POST vs. GET • Use POST instead of GET if you want to send complex long text fields/parameters to server • PUT: sent from Client to Server • • • Store document at server under specified URL, May be disabled at server to avoid modifying files Receive a response: Created, Modified, … • POST vs. PUT • • POST URL specifies the CGI process that will handle the enclosed form PUT URL specifies the enclosed document to be created/storedProf. Rick Han, University of Colorado at Boulder DNS Lookup Example root & edu DNS server www.cs.cmu.edu Client Local DNS server Prof. Rick Han, University of Colorado at Boulder cmu.edu DNS server cs.cmu.edu Authoritative DNS server Courtesy: Srini Seshan More on DNS • In addition to name translation, DNS helps with • Host aliasing • DNS supports multiple host names for a single IP address, e.g. yahoo.com and www.yahoo.com • Load distribution • • • Instead of HTTP Redirect, use DNS! A busy site like cnn.com will have multiple replicated Web servers, each with a different IP address • A set of IP addresses associated with cnn.com DNS can return multiple records that match a single name • Order of replicated server addresses is rotated Prof. Rick Han, University of Colorado at Boulder DNS Message Format 12 bytes Name, type fields for a query RRs in response to query Records for authoritative servers Additional “helpful info that may be used Identification Flags No. of Questions No. of Answer RRs No. of Authority RRs No. of Additional RRs Questions (variable number of answers) Answers (variable number of resource records) Authority (variable number of resource records) Additional Info (variable number of resource records Prof. Rick Han, University of Colorado at Boulder More on DNS (2) Server Farm DNS Client • DNS helps with • Load distribution (cont.) • • DNS round robin to N servers Akamai’zing – Smarter than DNS round robin: choose the server closest to you – better response time! • • • Akamai serves a subset of cnn.com Each URL in Akamai subset has a name for which the Akamai DNS server is authoritative www.cnn.com/foo.gif a128.g.akamai.net/foo.gif Prof. Rick Han, University of Colorado at Boulder More on DNS (3) • RFC 1794, DNS Support for Load Balancing • DNS also helps with : • Mail server aliasing • Given hotmail.com, return the specific host name • BIND is a popular name server for Unix Prof. Rick Han, University of Colorado at Boulder More on DNS (4) • Dynamic DNS: • Mapping your well-known Web name to a dynamic IP address (from DHCP) • • • • Solution: your PC includes code snippet to update DNS each time your PC gets a new IP address via DHCP • • Suppose you’ve reserved a hostname www.myweb.org to serve Web pages from your home PC Each time your PC connects via cable/DSL, your ISP assigns your PC a different dynamic IP address via DHCP Users won’t know your dynamic IP address but may remember your Web address. How can they reach you? Your PC must have authorization at a DNS server to update its DNS record Dynamic DNS services are being offered on the Web, some for free, others you pay Prof. Rick Han, University of Colorado at Boulder Load Balancing Techniques • HTTP Redirection • DNS Load Balancing • Router-based • Zany idea #1: N servers each advertise the same IP address. Let IP shortest-hop routing determine the nearest server. • Hopefully no loops. Prof. Rick Han, University of Colorado at Boulder Load Balancing Techniques (2) • Router-based • Better idea: Place an IP router in front of N servers – the router balances the load • • Example: each server has different IP address, and router substitutes IP address of lightest loaded server If a TCP connection is established to a specific server X, router must remember to route packets for this TCP connection to server X only • router can’t just choose most lightly loaded server L, because L might not be X, so server L would not be expecting server X’s TCP packets • NAT-Based (see NAT section) Prof. Rick Han, University of Colorado at Boulder Email: SMTP, POP, IMAP • SMTP – Simple Mail Transfer Protocol • Defines email header and email body • • ASCII text for header and body To:, Subject:, Date:, From:, Received: • • Supplements original email RFC 822 Allows email to carry more than just text: images, audio, video, MS Word, … • MIME = Multipurpose Internet Mail Extensions Prof. Rick Han, University of Colorado at Boulder Email: SMTP, POP, IMAP (2) • MIME = Multipurpose Internet Mail Extensions • Augments email header with fields • MIME-version:, • Content-Description:, • Content-Transfer-Encoding: • Content-Type: namely, the MIME type • • • • text/html application/postscript image/gif multipart – allows multiple types in an email, e.g. multipart/mixed; each part has its own Rick Han, University of header Prof.Colorado at Boulder Email: SMTP, POP, IMAP (3) • Mail client uses SMTP over TCP to send to mail server • Mail reader uses POP3 or IMAP4 to read email from mail server • SMTP • • • Sendmail is UNIX SMTP implementation Mail may traverse several mail forwarding gateways en route to destination • Each gateway will have sendmail or an SMTP equivalent to set up a new SMTP connection SMTP client sends a command (HELO, MAIL, RCPT, …), server responds with a code Prof. Rick Han, University of Colorado at Boulder