Stanford CS 144 - Lecture 2 - Applications and Application Programming

Unformatted text preview:

Lecture 2: Applications and ApplicationProgrammingAdministrivia• We’re in a new room• If you are a Masters student, you need to enroll for3, not 4 credits• Prof. Levis will not have regular office hours nextweek (will be in Redmond)Overview• End-to-end model• Applications: a lot of different ways to use TCP- Telnet- Web/HTTP- BitTorrent- Skype• Application programmingReview• The Internet is a network of networks• Hourglass / narrow waist: host-host delivery- IP protocol to deliver packets to hosts- Transport above for service/program demultiplexing- Link layer below for a single hop• Sockets are system call interface forcommunicationApplications• How services use sockets to provide usefulfunctionality• “the intelligence is end to end rather than hiddenin the network.” (RFC 1958)• Two basic questions- What do you send- Whom do you send it toAn Application View of the Worldclient serverInternet• Why doesn’t the network help more?- Compress data- Reformat/improve requests- Respond with cached dataEnd-to-End Model• Saltzer, Reed, and Clark, 1984• “The function in question can completely andcorrectly be implemented only with theknowledge and help of the application standing atthe end points of the communication system.Therefore, providing that questioned function as afeature of the communication system itself is notpossible. (Sometimes an incomplete version of thefunction provided by the communication systemmay be useful as a performance enhancement.).We call this ... ’the end-to-end argument.”’• Example: file transferFile Transfer• What can go wrong?• How can we be sure a file arrives successfully?• Why do something in the middle?Strong End-to-End• “The network’s job is to transmit datagrams asefficiently and flexibly as possible. Everything elseshould be done at the fringes..” (RFC 1958)• Why?Net Neutrality• Problem: Preferential treatment of some trafficover others• Allows IP service providers to control applications• Provider goals are not the same as end user’s• Comcast spurious BitTorrent RSTs (now fixed)• April 17, FCC is holding a hearing here atStanford!Performance definitions• Throughput – Number of bits/time you cantransmit- Improves with technology• Latency – How long for message to cross network- Propagation + Transmit + Queue- We are stuck with speed of light. . .10s of milliseconds to cross country• Goodput – TransferSize/Latency• Jitter – Variation in latency• What matters most for your application?Telnet• Server listens on port 23• On connection, provides a login prompt• Allows insecure remote logins• Telnet client is a text interface- Allows session management- Handles terminal control signals, etc.• What matters most?client serverInternetWeb/HTTP• Server lists on port 80• On connection, waits for a request• Protocol (but not data...) is in ASCII• Sends response, maybe closes connection (clientcan ask it to stay open)Parsing a URLhttp://cs144.s cs.stanford.edu/labs/sc .htmlFileHostProtocolHTTP Request Formatmethod URL version ←↓header field name value ←↓header field name value ←↓←↓requestheadersbodyblank line• Request types: GET, PUT, POST, HEAD, PUT,DELETE• A trivial request: GET / HTTP/1.0• A browser request: http://locallhost:8000A Browser RequestGET / HTTP/1.1Host: localhost:8000User-Agent: Mozilla/5.0 (Macinto ...Accept: text/xml,application/xm ...Accept-Language: en-us,en;q=0.5Accept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 300Connection: keep-aliveHTTP Response Formatversion status code phrase ←↓header field name value ←↓header field name value ←↓←↓statusheadersbodyblank line• 1xx codes: Informational• 2xx codes: Successes• 3xx codes: Redirection• 4xx codes: Client Error, 5xx codes: Server Errorwww.scs.stanford.edu ResponseHTTP/1.1 200 OKDate: Thu, 03 Apr 2008 21:09:57 GMTServer: ApacheLast-Modified: Thu, 03 Jan 2008 01:05:54 GMTETag: "a577678157a762e3d46afd4038d9a35bf2ae9386"Accept-Ranges: bytesContent-Length: 3586Connection: closeContent-Type: text/html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN""http://www.w3.org/TR/html4/strict.dtd">...HTTP Performance• What matters most?• Different kinds of requests- Lots of small requests (loading a page)- Big request (fetching a download)• Require different solutionsSmall Requests• Latency matters• Governed by round-trip-time (RTT) between hosts• Two major causes:- Opening a TCP connection- Data response-request• Solution: persistent connectionsBrowser Request, RevisitedGET / HTTP/1.1Host: localhost:8000User-Agent: Mozilla/5.0 (Macinto ...Accept: text/xml,application/xm ...Accept-Language: en-us,en;q=0.5Accept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 300Connection: keep-aliveBig Requests• Problem is throughput on edge link• Use an HTTP proxy cache- Can also improve latency!clientsserverInternetproxycacheStale Caches• Items in the cache can go stale (you don’t want toread yesterday’s paper)• Cache needs a way to conditionally ask for adocument• Issue a conditional GET (If-modified-sinceheader)- Server can reply with a 304 Not ModifiedGET / HTTP/1.1Host: cs144.scs.stanford.eduIf-modified-since: Wed, 2 April 2008 08:00:00Client-Server vs. Peer-to-Peer• Server can be a bottleneck- Download time can scale O (n) with n clients- Scaling up server bandwidth can be expensive (CDNs,lecture 9)- Slashdotting/flash crowds• Peer-to-peer: get a bunch of end-hosts tocollaboratively distribute content• A common peer-to-peer challenge is finding whomto collaborate withBitTorrent• Torrent file (.torrent) describes file to download- Names tracker, URL that describes who is participating- File length, piece length, SHA1 hashes of pieces- Additional metadata (who created torrent, etc.)• Client contacts tracker, starts communicating withpeersd8:announce47:http://vip.tracker.thepiratebay.org:80/announce7:comme nt20 :THANKS FOR SEEDING!10:created by13:uTorrent/177013:creationdatei1207365453e8:encoding5:UTF-84:infod6:lengthi839833600e4:name18:XXX XXXXXXXXX.avi12:piece lengthi1048576e6:pieces16020:U ....Pieces and Sub-pieces• BitTorrent breaks up a file into N pieces- For throughput, pieces are large: 256KB-1MB- For latency, broken into subpieces• Hashes of pieces in torrent provide end-to-endintegrity (HBO/Rome)- Hashes computes a short summary of a piece of data-


View Full Document

Stanford CS 144 - Lecture 2 - Applications and Application Programming

Documents in this Course
IP Review

IP Review

22 pages

Load more
Download Lecture 2 - Applications and Application Programming
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view Lecture 2 - Applications and Application Programming and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view Lecture 2 - Applications and Application Programming 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?