Presentation is loading. Please wait.

Presentation is loading. Please wait.

2: Application Layer1 Reminder r Homework 1 for Wednesday: m Problems #3-5,11,16,18-20 m Half of the problems will be graded r Feel free to send me email.

Similar presentations


Presentation on theme: "2: Application Layer1 Reminder r Homework 1 for Wednesday: m Problems #3-5,11,16,18-20 m Half of the problems will be graded r Feel free to send me email."— Presentation transcript:

1 2: Application Layer1 Reminder r Homework 1 for Wednesday: m Problems #3-5,11,16,18-20 m Half of the problems will be graded r Feel free to send me email.

2 2: Application Layer2 Chapter 2 outline r 2.1 Principles of app layer protocols r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail m SMTP, POP3, IMAP r 2.5 DNS r 2.6 Socket programming with TCP r 2.7 Socket programming with UDP r 2.8 Building a Web server r 2.9 Content distribution m Network Web caching m Content distribution networks m P2P file sharing

3 2: Application Layer3 Response time modeling Definition of RTT: time to send a small packet to travel from client to server and back. Response time: r one RTT to initiate TCP connection r one RTT for HTTP request and first few bytes of HTTP response to return r file transmission time total = 2RTT+transmit time time to transmit file initiate TCP connection RTT request file RTT file received time

4 2: Application Layer4 HTTP Headers See headers online: r http://www.web-caching.com/showheaders.html r Try m http://www.lehigh.edu/ m http://www.microsoft.com/ m Others r Access via telnet (next slide) m Digression on terminal types, DISPLAY environment variable, telnet clients, telnet vs. ssh

5 2: Application Layer5 Trying out HTTP (client side) for yourself 1. Telnet (from UNIX) to your favorite Web server: Opens TCP connection to port 80 (default HTTP server port) at www.cse.lehigh.edu. Anything typed in is sent to port 80 at www.cse.lehigh.edu. telnet www.cse.lehigh.edu 80 2. Type in a GET HTTP request: GET /~brian/ HTTP/1.0 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!

6 2: Application Layer6 User-server interaction: authorization Authorization : control access to server content r authorization credentials: typically name, password r stateless: client must present authorization in each request  authorization: header line in each request  if no authorization : header, server refuses access, sends WWW authenticate: header line in response client server usual http request msg 401: authorization req. WWW authenticate: usual http request msg + Authorization: usual http response msgusual http request msg + Authorization: usual http response msg time Browser caches name & password so that user does not have to repeatedly enter it.

7 2: Application Layer7 Cookies: keeping “state” Many major Web sites use cookies Four components: 1) cookie header line in the HTTP response message 2) cookie header line in HTTP request message 3) cookie file kept on user’s host and managed by user’s browser 4) back-end database at Web site Example: m Susan access Internet always from same PC m She visits a specific e- commerce site for first time m When initial HTTP requests arrives at site, site creates a unique ID and creates an entry in backend database for ID

8 2: Application Layer8 Cookies: keeping “state” (cont.) client server usual http request msg usual http response + Set-cookie: 1678 usual http request msg cookie: 1678 usual http response msg usual http request msg cookie: 1678 usual http response msg cookie- specific action cookie- spectific action server creates ID 1678 for user entry in backend database access Cookie file amazon: 1678 ebay: 8734 Cookie file ebay: 8734 Cookie file amazon: 1678 ebay: 8734 one week later:

9 2: Application Layer9 Cookies (continued) What cookies can bring: r authorization r shopping carts r recommendations r user session state (Web e-mail) Cookies and privacy: r cookies permit sites to learn a lot about you r you may supply name and e-mail to sites r advertising companies obtain info across sites aside

10 2: Application Layer10 Conditional GET: client-side caching r Goal: don’t send object if client has up-to-date cached version r client: specify date of cached copy in HTTP request If-modified-since: r server: response contains no object if cached copy is up- to-date: HTTP/1.0 304 Not Modified client server HTTP request msg If-modified-since: HTTP response HTTP/1.0 304 Not Modified object not modified HTTP request msg If-modified-since: HTTP response HTTP/1.0 200 OK object modified

11 2: Application Layer11 Chapter 2 outline r 2.1 Principles of app layer protocols r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail m SMTP, POP3, IMAP r 2.5 DNS r 2.6 Socket programming with TCP r 2.7 Socket programming with UDP r 2.8 Building a Web server r 2.9 Content distribution m Network Web caching m Content distribution networks m P2P file sharing

12 2: Application Layer12 FTP: the file transfer protocol r transfer file to/from remote host r client/server model m client: side that initiates transfer (either to/from remote) m server: remote host r ftp: RFC 959 r ftp server: port 21 file transfer FTP server FTP user interface FTP client local file system remote file system user at host

13 2: Application Layer13 FTP: separate control, data connections r FTP client contacts FTP server at port 21, specifying TCP as transport protocol r Client obtains authorization over control connection r Client browses remote directory by sending commands over control connection. r When server receives a command for a file transfer, the server opens a TCP data connection to client r After transferring one file, server closes connection. FTP client FTP server TCP control connection port 21 TCP data connection port 20 r Server opens a second TCP data connection to transfer another file. r Control connection: “out of band” r FTP server maintains “state”: current directory, earlier authentication

14 2: Application Layer14 FTP commands, responses Sample commands: r sent as ASCII text over control channel  USER username  PASS password  LIST return list of files in current directory  RETR filename retrieves (gets) file  STOR filename stores (puts) file onto remote host Sample return codes: r status code and phrase (as in HTTP) r 331 Username OK, password required r 125 data connection already open; transfer starting r 425 Can’t open data connection r 452 Error writing file

15 2: Application Layer15 Chapter 2 outline r 2.1 Principles of app layer protocols r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail m SMTP, POP3, IMAP r 2.5 DNS r 2.6 Socket programming with TCP r 2.7 Socket programming with UDP r 2.8 Building a Web server r 2.9 Content distribution m Network Web caching m Content distribution networks m P2P file sharing

16 2: Application Layer16 Electronic Mail Three major components: r user agents r mail servers r simple mail transfer protocol: SMTP User Agent r a.k.a. “mail reader” r composing, editing, reading mail messages r e.g., Eudora, Outlook, elm, Netscape Messenger, pine r outgoing, incoming messages stored on server user mailbox outgoing message queue mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP

17 2: Application Layer17 Electronic Mail: mail servers Mail Servers r mailbox contains incoming messages for user r message queue of outgoing (to be sent) mail messages r SMTP protocol between mail servers to send email messages m client: sending mail server m “server”: receiving mail server mail server user agent user agent user agent mail server user agent user agent mail server user agent SMTP

18 2: Application Layer18 Electronic Mail: SMTP [RFC 2821] r uses TCP to reliably transfer email message from client to server, port 25 r direct transfer: sending server to receiving server r three phases of transfer m handshaking (greeting) m transfer of messages m closure r command/response interaction m commands: ASCII text m response: status code and phrase r messages must be in 7-bit ASCII

19 2: Application Layer19 Scenario: Alice sends message to Bob 1) Alice uses UA to compose message and “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 mail server mail server user agent 1 2 3 4 5 6

20 2: Application Layer20 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 alice@crepes.fr... Sender ok C: RCPT TO: 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

21 2: Application Layer21 Try SMTP interaction for yourself:  telnet genie.eecs.lehigh.edu 25 r see 220 reply from server r enter HELO, MAIL FROM, RCPT TO, DATA, QUIT commands (above lets you send email without using email client)

22 2: Application Layer22 SMTP: final words r SMTP uses persistent connections r SMTP requires message (header & body) to be in 7- bit ASCII  SMTP server uses CRLF.CRLF to determine end of message Comparison with HTTP: r HTTP: pull r SMTP: push r both have ASCII command/response interaction, status codes r HTTP: each object encapsulated in its own response msg r SMTP: multiple objects sent in multipart msg

23 2: Application Layer23 Mail message format SMTP: protocol for exchanging email msgs RFC 822: standard for text message format: r header lines, e.g., m To: m From: m Subject: different from SMTP commands! r body m the “message”, ASCII characters only header body blank line

24 2: Application Layer24 Message format: multimedia extensions r MIME: multimedia mail extension, RFC 2045, 2056 r additional lines in msg header declare MIME content type From: alice@crepes.fr To: bob@hamburger.edu Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data....................................base64 encoded data multimedia data type, subtype, parameter declaration method used to encode data MIME version encoded data

25 2: Application Layer25 MIME types Content-Type: type/subtype; parameters Text  example subtypes: plain, html Image  example subtypes: jpeg, gif Audio  example subtypes: basic (8-bit mu-law encoded), 32kadpcm (32 kbps coding) Video  example subtypes: mpeg, quicktime Application r other data that must be processed by reader app before “viewable”  example subtypes: msword, octet-stream

26 2: Application Layer26 Multipart Type From: alice@crepes.fr To: bob@hamburger.edu Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=StartOfNextPart --StartOfNextPart Dear Bob, Please find a picture of a crepe. --StartOfNextPart Content-Transfer-Encoding: base64 Content-Type: image/jpeg base64 encoded data....................................base64 encoded data --StartOfNextPart Do you want the recipe?

27 2: Application Layer27 Mail access protocols r SMTP: delivery/storage to receiver’s server r Mail access protocol: retrieval from server m POP: Post Office Protocol [RFC 1939] authorization (agent server) and download m IMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex) manipulation of stored msgs on server m HTTP: Hotmail, Yahoo! Mail, etc. user agent sender’s mail server user agent SMTP access protocol receiver’s mail server

28 2: Application Layer28 POP3 protocol authorization phase r client commands:  user: declare username  pass: password r server responses m +OK  -ERR transaction phase, client:  list: list message numbers  retr: retrieve message by number  dele: delete r quit C: list S: 1 498 S: 2 912 S:. C: retr 1 S: S:. C: dele 1 C: retr 2 S: S:. C: dele 2 C: quit S: +OK POP3 server signing off S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on

29 2: Application Layer29 POP3 (more) and IMAP More about POP3 r Previous example uses “download and delete” mode. r Bob cannot re-read e- mail if he changes client r “Download-and-keep”: copies of messages on different clients r POP3 is stateless across sessions IMAP r Keep all messages in one place: the server r Allows user to organize messages in folders r IMAP keeps user state across sessions: m names of folders and mappings between message IDs and folder name

30 2: Application Layer30 Chapter 2 outline r 2.1 Principles of app layer protocols r 2.2 Web and HTTP r 2.3 FTP r 2.4 Electronic Mail m SMTP, POP3, IMAP r 2.5 DNS r 2.6 Socket programming with TCP r 2.7 Socket programming with UDP r 2.8 Building a Web server r 2.9 Content distribution m Network Web caching m Content distribution networks m P2P file sharing


Download ppt "2: Application Layer1 Reminder r Homework 1 for Wednesday: m Problems #3-5,11,16,18-20 m Half of the problems will be graded r Feel free to send me email."

Similar presentations


Ads by Google