Download presentation
Presentation is loading. Please wait.
Published byCecily York Modified over 9 years ago
1
Lecture51 Administrative Things r Grader: Yona Raekow Email: yona.raekow@gmx.deyona.raekow@gmx.de Office hours: Wed. 1pm-3pm or Th. 11am-1pm r Homeworks m Usually due on Tuesday (in class) m Returned to you on the following Tuesday m See Yona within one week if you have questions r Projects m See announcements r LATE homeworks or projects will NOT be accepted
2
Lecture52 Chapter 2 outline r 2.1 Principles of app layer protocols m clients and servers m app requirements 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
Lecture53 What we have learned? r Client-server model r Socket (API) r Addressing processes (IP+port number) r Services from transport level m Data loss, bandwidth, timing m What choices we have? r HTTP m Using client-server model, and TCP m Non-persistent and persistent connections m Request and response messages
4
Lecture54 HTTP request message: general format
5
Lecture55 Method types HTTP/1.0 r GET r POST r HEAD HTTP/1.1 r GET, POST, HEAD r PUT r DELETE
6
Lecture56 HTTP response message HTTP/1.1 200 OK Connection close Date: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data... status line (protocol status code status phrase) header lines data, e.g., requested HTML file
7
Lecture57 HTTP response status codes 200 OK 301 Moved Permanently 400 Bad Request 404 Not Found 505 HTTP Version Not Supported 401 Authorization Required... 304 Not Modified... In first line in server->client response message. A few sample codes:
8
Lecture58 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
9
Lecture59 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
10
Lecture510 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:
11
Lecture511 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 search engines use redirection & cookies to learn yet more r advertising companies obtain info across sites aside
12
Lecture512 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
13
Lecture513 Chapter 2 outline r 2.1 Principles of app layer protocols m clients and servers m app requirements 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
14
Lecture514 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
15
Lecture515 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
16
Lecture516 FTP commands, responses Sample commands: r sent as ASCII text over control channel USER username PASS password LIST return list of file 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 For more refer to RFC 959
17
Lecture517 Chapter 2 outline r 2.1 Principles of app layer protocols m clients and servers m app requirements 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
18
Lecture518 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 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
19
Lecture519 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
20
Lecture520 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
21
Lecture521 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
22
Lecture522 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
23
Lecture523 Try SMTP interaction for yourself: r telnet servername 25 Eg, telnet bilbo.engr.uconn.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 (reader)
24
Lecture524 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 both have ASCII command/response interaction, status codes r HTTP: pull SMTP: push r SMTP: requires each msg. in 7- bit ASCII (including msg. body) HTTP: no such restriction r HTTP: each object encapsulated in its own response msg SMTP: multiple objects sent in multipart msg
25
Lecture525 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
26
Lecture526 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
27
Lecture527 MIME types Content-Type: type/subtype; parameters Text example subtypes: plain, html Image example subtypes: jpeg, gif Audio exampe 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 before “viewable” example subtypes: msword, octet-stream
28
Lecture528 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 reciple?
29
Lecture529 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
30
Lecture530 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 update phase 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
31
Lecture531 Try POP3 interaction for yourself: r telnet servername 110 Eg, telnet bilbo.engr.uconn.edu 110 r see “+OK POP3 server ready” reply from server r enter user, pass, list, retr, dele, quit commands above lets you read emails without user agent
32
Lecture532 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 r Much more complex
33
Lecture533 Web-Baed E-mail r Sending and accessing emails through web browser r Using HTTP instead of SMTP, IMAP, POP3 r Mail exchange between mail servers still uses SMTP r A more complex scenario m Using HTTP between user and HTTP server m HTTP server (script) uses IMAP to communicate with an IMAP server to organize folder hierarchy)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.