1 / 51

Application Layer – Traditional

Application Layer – Traditional. UIUC CS438: Communication Networks Summer 2014 Fred Douglas Slides: Fred , Kurose&Ross (sometimes edited). Topics. Sockets: the interface you’ll code with What is the application layer? Today: just the client-server model Thursday: peer-to-peer

kirk
Télécharger la présentation

Application Layer – Traditional

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Application Layer – Traditional UIUC CS438: Communication Networks Summer 2014 Fred Douglas Slides: Fred, Kurose&Ross(sometimes edited)

  2. Topics • Sockets: the interface you’ll code with • What is the application layer? • Today: just the client-server model • Thursday: peer-to-peer • HTTP: basic protocol of the “world wide web” • DNS: the internet’s phone book • FTP: file transfer • Email

  3. Super Basic TCP Sockets “I own this port” Client Server bind(listenSocket, port) listen(listenSocket) socket = connect(addr,port) … socket = accept() (connect returns) send(socket, data) recv(socket) recv(socket) send(socket, data) … … close(socket) close(socket) Try to establish a connection (may take some time) Put connect()s in a queue Respond to the first connect() in the queue Transfer data (reliably) End this connection

  4. What is the application layer?

  5. 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: defined in RFCs allows for interoperability e.g., HTTP, SMTP proprietary protocols: e.g., Skype App-layer protocol defines

  6. Today’s Example: HTTP + DNS

  7. www.someschool.edu/someDept/pic.gif pathname host name Web and HTTP First, a review… • 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, e.g.,

  8. HTTP: hypertext transfer protocol Web’s 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 HTTP response HTTP response HTTP request HTTP request HTTP overview PC running Firefox browser server running Apache Web server iphone running Safari browser

  9. uses TCP: client initiates TCP connection (creates socket) to server, port 80 server accepts TCP connection from client HTTP messages (application-layer protocol messages) exchanged between browser (HTTP client) and Web server (HTTP server) TCP connection closed HTTP is “stateless” server maintains no information about past client requests HTTP overview (continued) aside protocols that maintain “state” are complex! • past history (state) must be maintained • if server/client crashes, their views of “state” may be inconsistent, must be reconciled

  10. 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, HEAD commands) GET /index.html HTTP/1.1\r\n Host: www-net.cs.umass.edu\r\n User-Agent: Firefox/3.6.10\r\n Accept: text/html,application/xhtml+xml\r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n Keep-Alive: 115\r\n Connection: keep-alive\r\n \r\n header lines carriage return, line feed at start of line indicates end of header lines

  11. ~ ~ ~ ~ ~ ~ ~ ~ value value header field name header field name cr cr lf lf cr lf HTTP request message: general format request line sp sp version cr method URL lf header lines entity body body

  12. HTTP response message status line (protocol status code status phrase) HTTP/1.1 200 OK\r\n Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n Server: Apache/2.0.52 (CentOS)\r\n Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT\r\n ETag: "17dc6-a5c-bf716880"\r\n Accept-Ranges: bytes\r\n Content-Length: 2652\r\n Keep-Alive: timeout=10, max=100\r\n Connection: Keep-Alive\r\n Content-Type: text/html; charset=ISO-8859-1\r\n \r\n data data data data data ... header lines data, e.g., requested HTML file

  13. 200 OK request succeeded, requested object later in this msg 301 Moved Permanently requested object moved, new location specified later in this msg (Location:) 400 Bad Request request msg not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported HTTP response status codes • status code appears in 1st line in server-to-client response message. • some sample codes:

  14. 1. Telnet to your favorite Web server: Trying out HTTP (client side) for yourself 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 telnet cis.poly.edu 80 2. type in a GET HTTP request: by typing this in (hit carriage return twice), you send this minimal (but complete) GET request to HTTP server GET /~ross/ HTTP/1.1 Host: cis.poly.edu 3. look at response message sent by HTTP server! (or use Wireshark to look at captured HTTP request/response)

  15. POST method: web page often includes form input input is uploaded to server in entity body URL method: uses GET method input is uploaded in URL field of request line: Uploading form input www.somesite.com/animalsearch?monkeys&banana

  16. Cookies: Undoing Statelessness,or, “HTTP’s Session Layer” • Purpose: let the site remember what you did • Automatic login • Site preferences • Tracking where you go • Mechanism: HTTP header lines • Server asks to establish a cookie in HTTP reply • Server will have some database connection • Browser saves cookies in a local file • Browser volunteers a site’s cookies in HTTP request

  17. ebay 8734 usual http request msg Amazon server creates ID 1678 for user usual http response set-cookie: 1678 create entry ebay 8734 amazon 1678 ebay 8734 amazon 1678 usual http request msg cookie: 1678 access cookie- specific action usual http response msg usual http response msg access usual http request msg cookie: 1678 cookie- specific action Cookies: keeping “state” (cont.) client server cookie file backend database one week later:

  18. non-persistent HTTP at most one object sent over TCP connection connection then closed downloading multiple objects required multiple connections HTTP connections

  19. Non-persistent HTTP: response time RTT (definition): time for a small packet to travel from client to server and back HTTP response time: • one RTT to initiate TCP connection • one RTT for HTTP request and first few bytes of HTTP response to return • file transmission time • non-persistent HTTP response time = 2RTT+ file transmission time initiate TCP connection RTT request file time to transmit file RTT file received time time

  20. HTTP Optimizations • Optimal time: 1RTT + file transfer • Actual time: (#objects)x(2RTT+file transfer) • Saving round trips • Parallel connections • Supposed to be max 2  • Reusing TCP connections (“Persistent TCP”)

  21. persistent HTTP: server leaves connection open after sending response subsequent HTTP messages between same client/server sent over open connection client sends requests as soon as it encounters a referenced object Typical pattern: Client sends GET page.html Client receives page.html after an RTT Client scans page.html, issues GETs (in same connection) for multiple images Client receives images after RTT + transfer time TOTAL: 2RTT + transfer time Persistent HTTP

  22. HTTP Optimizations • Saving round trips • Parallel connections • Supposed to be max 2  • Reusing TCP connections (“Persistent TCP”) • Saving download time • Caching • If-Modified-Since • Caching proxies

  23. Goal: don’t send object if cache has up-to-date cached version no object transmission delay lower link utilization cache: specify date of cached copy in HTTP request If-modified-since: <date> server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not Modified HTTP response HTTP/1.0 304 Not Modified Local Caching: Conditional GET server client HTTP request msg If-modified-since: <date> object not modified before <date> HTTP request msg If-modified-since: <date> object modified after <date> HTTP response HTTP/1.0 200 OK <data>

  24. user sets browser: Web accesses via cache browser sends all HTTP requests to cache object in cache: cache returns object else cache requests object from origin server, then returns object to client HTTP request HTTP request HTTP response HTTP response HTTP request HTTP response Web caches (proxy server) goal: satisfy client request without involving origin server proxy server client origin server client origin server

  25. CDN: Web cache on steroids • Service provided by a company (e.g. Akamai) with servers EVERYWHERE • User gets directed to a “nearby” server • User is given server’s IP address • Choice is based on geolocation… of DNS resolver • CDN vs web cache: • CDN speeds up everything by a little • Web cache speeds up files requested by other local users by a lot

  26. Back to our example

  27. DNS – A simple goal www.cs.illinois.edu 128.174.252.83

  28. people: many identifiers: SSN, name, passport # Internet hosts, routers: IP address (32 bit) - 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: distributed database implemented in hierarchy of many name servers application-layer protocol: hosts, name servers communicate to resolvenames (address/name translation) note: core Internet function, implemented as application-layer protocol complexity at network’s “edge” DNS: domain name system

  29. why not centralize DNS? Doesn’t scale: single point of failure traffic volume distant centralized database maintenance DNS services hostname to IP address translation host aliasing canonical, alias names mail server aliasing load distribution replicated Web servers: many IP addresses correspond to one name DNS: services, structure

  30. What’s in a domain name? www.cs.illinois.edu mail.google.com romeo.montague.it • Hierarchical names • Hierarchical ownership (what makes it not flat) • Right to decide what IP a name resolves to • Right to delegate subdomains • Responsibility to help with resolution • Return IP address • Return next name server Subdomain of montague Subdomain of it TLD

  31. Root DNS Servers org DNS servers edu DNS servers com DNS servers poly.edu DNS servers umass.edu DNS servers pbs.org DNS servers yahoo.com DNS servers amazon.com DNS servers DNS: a distributed, hierarchical database … … client wants IP for www.amazon.com; 1st approx: • 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

  32. contacted by local name server that can not resolve name root name server: contacts authoritative name server if name mapping not known gets mapping returns mapping to local name server DNS: root name servers c. Cogent, Herndon, VA (5 other sites) d. U Maryland College Park, MD h. ARL Aberdeen, MD j. Verisign, Dulles VA (69 other sites ) k. RIPE London (17 other sites) i. Netnod, Stockholm (37 other sites) m. WIDE Tokyo (5 other sites) e. NASA Mt View, CA f. Internet Software C. Palo Alto, CA (and 48 other sites) 13 root name “servers” worldwide 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)

  33. 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 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

  34. Local DNS name server • does not strictly belong to hierarchy • each ISP (residential ISP, company, university) has one • also called “default name server” • 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

  35. Iterative and Recursive Queries • Recursive: “please resolve this query for me” • End host to local resolver • Iterative: “tell me the next place to look” • Local resolver to any other DNS server

  36. DNS Roles: Summary • Root name servers • Responsible for all the TLDs • TLD servers • Knows the addresses of all of its domain’s name servers • Authoritative name servers • Responsible for a domain (google.com) • For all subdomains, it knows either • an IP address • the subdomain’s name server • Recursive resolver • Handles lookups for many end hosts • Caches IP addresses and name server addresses • End host • Talks to a resolver • Caches IP addresses

  37. Typical DNS Query google.com’s name server is at 1.2.3.4 mail.google.com is at 5.6.7.8 .com TLD name server mail.google.com is at 5.6.7.8 What is mail.google.com’s IP address? Where is google.com’s name server? 3 google.com authoritative server 2 5 4 Friendly neighborhood resolver 5.6.7.8, a.k.a. mail.google.com 7 What is mail.google.com’s IP address? 6 1 You

  38. DNS – Main concepts • Domains • Top Level Domains (com, edu, uk, mil, gov, …) • Subdomains (com  example.com  www.example.com) • Name servers • Authoritative (tells you the IP for example.com) • Root (tells you where example.com’s name server is) • Iterative vs. recursive • Caching • Resolver and host cache end-host IP addresses • Resolver caches name server IP addresses • Entries expire after a TTL

  39. FTP user interface FTP client FTP server FTP: the file transfer protocol file transfer user at host remote file system local file system • transfer file to/from remote host • client/server model • client: side that initiates transfer (either to/from remote) • server: remote host • ftp: RFC 959 • ftp server: port 21

  40. FTP client contacts FTP server at port 21, using TCP client authorized over control connection client browses remote directory, sends commands over control connection when server receives file transfer command, server opens 2ndTCP data connection (for file) to client after transferring one file, server closes data connection FTP: separate control, data connections TCP control connection, server port 21 TCP data connection, server port 20 FTP client FTP server • server opens another TCP data connection to transfer another file • control connection: “out of band”

  41. sample commands: sent as ASCII text over control channel USER username PASS password LISTreturn list of file in current directory RETR filenameretrieves (gets) file STOR filenamestores (puts) file onto remote host sample return codes status code and phrase (as in HTTP) 331 Username OK, password required 125 data connection already open; transfer starting 425 Can’t open data connection 452 Error writing file FTP commands, responses

  42. FTP: What’s the Point? • Public file access • HTTP lets you download binary files • Most HTTP servers can do directory listings • Public access doesn’t need uploads • When uploads are needed, so is authentication • scp, sftp (is NOT ftp) • For “remote drive” access: Samba, sshfs • For collaboration: git • Is FTP just a relic?

  43. Three major components: user agents mail servers simple mail transfer protocol: SMTP User Agent a.k.a. “mail reader” composing, editing, reading mail messages e.g., Outlook, Thunderbird, iPhone mail client …but probably a web interface outgoing, incoming messages stored on server user agent user agent user agent user agent user agent user agent SMTP SMTP SMTP mail server mail server mail server outgoing message queue user mailbox Electronic mail

  44. 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 command/response interaction (like HTTP, FTP) commands: ASCII text response: status code and phrase messages must be in 7-bit ASCI Electronic Mail: SMTP [RFC 2821]

  45. SMTP: protocol for exchanging email msgs RFC 822: standard for text message format: header lines, e.g., To: From: Subject: differentfrom SMTP MAIL FROM, RCPT TO: commands! Body: the “message” ASCII characters only Mail message format header blank line body

  46. MAIL FROM + From: Elegant BCC • Blind Carbon Copy (hidden recipients) is nice • SMTP doesn’t have a specific mechanism for it • Instead: RCPT TO: recipient@example.com RCPT TO: cc-recipient@illinois.edu RCPT TO: hidden-bcc-recipient@illinois.edu DATA To: <recipient@example.com>, <cc-recipient@illinois.edu>

  47. 1) Alice uses UA to compose message “to”bob@someschool.edu 2) Alice’s UA sends message to her mail server; message placed in message queue 3) client side of SMTP opens TCP connection with Bob’s mail server 4) SMTP client sends Alice’s message over the TCP connection 5) Bob’s mail server places the message in Bob’s mailbox 6) Bob invokes his user agent to read message user agent user agent mail server mail server Typical Pattern 1 2 6 3 4 5 Alice’s mail server Bob’s mail server

  48. Addressing • Email addresses look like: fed2@case.edu • Mail servers have a subdomain • smtp.case.edu • new.toad.com • mail.example.com • Q: How does a mail server know to send packets to smtp.case.edu when it only sees fed2@case.edu? • A: DNS has “mail server” records • Interesting note: the mail record is a domain name (smtp.case.edu), not an IP address (129.22.105.31)

  49. Sample SMTP interaction S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <alice@crepes.fr> S: 250 alice@crepes.fr... Sender ok C: RCPT TO: <bob@hamburger.edu> S: 250 bob@hamburger.edu ... 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 Sadly, for security reasons, you probably can’t find a server that will let you actually send mail, but you can go through part of this.

  50. 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. user agent user agent sender’s mail server Mail access protocols mail access protocol SMTP SMTP (e.g., POP, IMAP) receiver’s mail server

More Related