CS118 Spring 2014Let’s look at HTTP in actionUser-server state: cookiesCookies: keeping “state” (cont.)Cookies (continued)Web caches (proxy server)More about Web cachingCaching exampleCaching example (cont)Slide 10Conditional GETChapter 2: Application layerFTP: the file transfer protocolFTP: separate control, data connectionsFTP commands, responsesSlide 16Electronic MailScenario: Alice sends message to BobSlide 19Electronic Mail: mail serversElectronic Mail: SMTP [RFC 2821]Slide 22Sample SMTP interactionTry SMTP interaction for yourself:SMTP: final wordsMail message formatMessage format: multimedia extensionsMail access protocolsPOP3 protocolPOP3 (more) and IMAPCS118 Spring 2014Lecture 2B2: Application Layer 2Let’s look at HTTP in actiontelnet exampleEthereal example2: Application Layer 3User-server state: cookiesMany major Web sites use cookiesFour components:1) cookie header line of HTTP response message2) cookie header line in HTTP request message3) cookie file kept on user’s host, managed by user’s browser4) back-end database at Web siteExample:Susan always accesses Internet from PCvisits specific e-commerce site as first thingwhen initial HTTP requests arrives at site, site creates: unique IDentry in backend database for ID2: Application Layer 4Cookies: keeping “state” (cont.)clientserverusual http response msgusual http response msgcookie fileone week later:usual http request msgcookie: 1678cookie-specificactionaccessebay 8734usual http request msgAmazon servercreates ID1678 for usercreate entryusual http response Set-cookie: 1678 ebay 8734amazon 1678usual http request msgcookie: 1678cookie-spectificactionaccessebay 8734amazon 1678backenddatabase2: Application Layer 5Cookies (continued)What cookies can bring:authorizationshopping cartsrecommendationsuser session state (Web e-mail)Cookies and privacy:cookies permit sites to learn a lot about youyou may supply name and e-mail to sitesasideHow to keep “state”:protocol endpoints: maintain state at sender/receiver over multiple transactionscookies: http messages carry state2: Application Layer 6Web caches (proxy server)user sets browser: Web accesses via cachebrowser sends all HTTP requests to cacheobject in cache: cache returns object else cache requests object from origin server, then returns object to clientGoal: satisfy client request without involving origin serverclientProxyserverclientHTTP requestHTTP responseHTTP requestHTTP requestorigin serverorigin serverHTTP responseHTTP response2: Application Layer 7More about Web cachingcache acts as both client and servertypically cache is installed by ISP (university, company, residential ISP)Why Web caching?reduce response time for client requestreduce traffic on an institution’s access link.Internet dense with caches: enables “poor” content providers to effectively deliver content (but so does P2P file sharing)2: Application Layer 8Caching example Assumptionsaverage object size = 100,000 bitsavg. request rate from institution’s browsers to origin servers = 15/secdelay from institutional router to any origin server and back to router = 2 secConsequencesutilization on LAN = 15%utilization on access link = 100%total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + millisecondsoriginserverspublic Internetinstitutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer 9Caching example (cont)possible solutionincrease bandwidth of access link to, say, 10 Mbpsconsequenceutilization on LAN = 15%utilization on access link = 15%Total delay = Internet delay + access delay + LAN delay = 2 sec + msecs + msecsoften a costly upgradeoriginserverspublic Internetinstitutionalnetwork10 Mbps LAN10 Mbps access linkinstitutionalcache2: Application Layer 10Caching example (cont)possible solution: install cachesuppose hit rate is 0.4consequence40% requests will be satisfied almost immediately60% requests satisfied by origin serverutilization of access link reduced to 60%, resulting in negligible delays (say 10 msec)total avg delay = Internet delay + access delay + LAN delay = .6*(2.01) secs + .4*milliseconds < 1.4 secsoriginserverspublic Internetinstitutionalnetwork10 Mbps LAN1.5 Mbps access linkinstitutionalcache2: Application Layer 11Conditional GETGoal: don’t send object if cache has up-to-date cached versionserver: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not Modifiedcache: specify date of cached copy in HTTP requestIf-modified-since: <date>cacheserverHTTP request msgIf-modified-since: <date>HTTP responseHTTP/1.0 304 Not Modifiedobject not modifiedHTTP request msgIf-modified-since: <date>HTTP responseHTTP/1.0 200 OK<data>object modified2: Application Layer 12Chapter 2: Application layer2.1 Principles of network applications2.2 Web and HTTP2.3 FTP 2.4 Electronic MailSMTP, POP3, IMAP2.5 DNS2.6 P2P file sharing2.7 Socket programming with TCP2.8 Socket programming with UDP2.9 Building a Web server2: Application Layer 13FTP: the file transfer protocoltransfer file to/from remote hostclient/server modelclient: side that initiates transfer (either to/from remote)server: remote hostftp: RFC 959ftp server: port 21file transferFTPserverFTPuserinterfaceFTPclientlocal filesystemremote filesystemuser at host2: Application Layer 14FTP: separate control, data connectionsFTP client contacts FTP server at port 21, TCP is transport protocolclient authorized over control connectionclient browses remote directory by sending commands over control connection.when server receives file transfer command, server opens 2nd TCP connection (for file) to clientafter transferring one file, server closes data connection.FTPclientFTPserverTCP control connectionport 21TCP data connectionport 20server opens another TCP data connection to transfer another file.control connection: “out of band”FTP server maintains “state”: current directory, earlier authentication2: Application Layer 15FTP commands, responsesSample commands:sent as ASCII text over control channelUSER usernamePASS passwordLIST return list of file in current directoryRETR filename retrieves (gets) fileSTOR filename stores (puts) file onto remote hostSample return codesstatus code and phrase (as in HTTP)331 Username
View Full Document