DOC PREVIEW
Stanford CS 144 - Applications and Reliable Transport Basics

This preview shows page 1-2-3-20-21-40-41-42 out of 42 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 42 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

Applications and Reliable Transport BasicsOverview• Lookup and shutdown• Applications: power of reliable sockets- Telnet- Web/HTTP- BitTorrent- Skype• Challenges of reliable transport• Next lecture: Reliable transport detailsAddress lookup details• getaddrinfo notes:- Can specify port as service name or number (e.g., "80" or"http", allows possibility of dynamically looking up port)- May return multiple addresses (chained with ai next field)- You must free structure with freeaddrinfo• Other useful functions to know about- getnameinfo – Lookup hostname based on address- inet ntop – convert IPv4 or 6 address to printable form- inetpton – convert string to IPv4 or 6 addressEOF in more detail• Simple client-server application- Client sends request- Server reads request, sends response- Client reads response• What happens when you’re done?- Client wants server to read EOF to say request is done- But still needs to be able to read server reply – fd is notclosed!shutdown system call• int shutdown (int fd, int how);- Shuts down a socket w/o closing file descriptor- how: 0 = reading, 1 = writing, 2 = both- Note: Applies to socket, not descriptor—so copies ofdescriptor (through dup or fork) affected- Note 2: With TCP, can’t detect if other side shuts forreading, so in practice 1 is only useful how argument• Play with uc from Lab 1 to see this- Pressing Ctrl-D at beginning of line sends EOF- uc reads EOF from standard input, uses shutdown to writeEOF to TCP socketReview• The Internet is a network of networks• Hourglass/narrow waist:host-host delivery- IP protocol to deliver packets tohosts- Transport above for service/process demultiplexing- Link layer below for a single hop• Sockets are system call interface for communication…FTPTCPUDPIPNET1NET2NETnHTTP NV TFTPApplications• Simple socket abstraction is very powerful- Applications can use them in many ways- We’ll go through four examples• “the intelligence is end to end rather than hiddenin the network.”– [RFC 1958] (architectural principles doc)• Two basic questions for an application- What do you send?- Whom do you send it to?An Reliable Socket View of the Worldclient serverInternet• Telnet: simple text stream• HTTP: downloading documents• BitTorrent: swarming large documents• Skype: IP telephony/lookupTelnet• 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 for performance?client serverInternetWeb/HTTP• Server listens 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, POST, HEAD, PUT, DELETE• A URL given to browser: http://localhost:8000/• Resulting request: GET / HTTP/1.1- Someday, requests will contain the full URL not just pathA 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-alive[LiveHTTPHeaders for Firefox is good way to see this]HTTP 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 for performance?• Depends on types 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(TCP requires 7 messages even with no data, including oneround-trip even before you can send request)- Actually sending request and receiving response• Mitigate first cost with 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 (or cache locally)- 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, 02 Apr 2008 08:00:00 GMTClient-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 12)- Slashdotting/flash crowds• Peer-to-peer: get a bunch of end-hosts to distributecontent collaboratively• A common peer-to-peer challenge is finding whomto collaborate withBitTorrent• Torrent file (.torrent) describes file to download- Names tracker, server tracking who is participating- File length, piece length, SHA1 hashes of pieces- Additional metadata (who created torrent, etc.)- Also specifies tracker• Client contacts tracker, starts communicating withpeersd8:announce47:http://vip.tracker.thepiratebay.org:80/announce7:comment20: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


View Full Document

Stanford CS 144 - Applications and Reliable Transport Basics

Documents in this Course
IP Review

IP Review

22 pages

Load more
Download Applications and Reliable Transport Basics
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 Applications and Reliable Transport Basics 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 Applications and Reliable Transport Basics 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?