Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS 372 – introduction to computer networks* Wednesday June 30

Similar presentations


Presentation on theme: "CS 372 – introduction to computer networks* Wednesday June 30"— Presentation transcript:

1 CS 372 – introduction to computer networks* Wednesday June 30
Announcements: Assignment 2 is posted. * Based in part on slides by Bechir Hamdaoui and Paul D. Paulson. Acknowledgement: slides drawn heavily from Kurose & Ross Chapter 2, slide:

2 Chapter 2: Application layer
Principles of network applications app architectures app requirements Web and HTTP File transfer: FTP P2P file sharing Socket programming with TCP Chapter 2, slide:

3 Web and HTTP First some terminologies: Web page consists of objects
Object can be HTML file, JPEG image, Java applet, audio file,… Web page consists of base HTML-file which includes several referenced objects Each object is addressable by a URL Example URL (Uniform Resource Locator): host name path name Chapter 2, slide:

4 HTTP overview: app architecture
HTTP: hypertext transfer protocol Web’s appl-layer protocol client/server model client: browser that requests, receives, “displays” Web objects server: Web server sends objects in response to requests HTTP 1.0: RFC 1945 HTTP 1.1: RFC 2068 HTTP request PC running Explorer HTTP response HTTP request Server running Apache Web server HTTP response Mac running Navigator Chapter 2, slide:

5 HTTP overview (continued)
Uses TCP: client initiates TCP connection (creates socket) to server, port 80 server accepts TCP connection from client HTTP messages exchanged between browser (HTTP client) and Web server (HTTP server) TCP connection closed HTTP is “stateless” server maintains no information about past client requests aside Protocols that maintain “state” are complex! past history (state) must be maintained if server/client crashes, their views of “state” may be inconsistent, must be reconciled Chapter 2, slide:

6 HTTP connections Nonpersistent HTTP
At most one object is sent over a TCP connection. HTTP/1.0 uses nonpersistent HTTP Persistent HTTP Multiple objects can be sent over single TCP connection between client and server. HTTP/1.1 uses persistent connections in default mode Chapter 2, slide:

7 Nonpersistent HTTP (contains text, references to 10 jpeg images) Suppose user enters URL 1a. HTTP client initiates TCP connection to HTTP server (process) at on port 80 1b. HTTP server at host waiting for TCP connection at port 80. “accepts” connection, notifying client 2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index 3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket time Chapter 2, slide:

8 Nonpersistent HTTP (cont.)
4. HTTP server closes TCP connection. 5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects time 6. Steps 1-5 repeated for each of 10 jpeg objects Chapter 2, slide:

9 Non-Persistent HTTP: Response time
Definition of RTT (round trip time): time to send a small packet to travel from client to server and back. Response time: one RTT to initiate TCP connection one RTT for HTTP request and first few bytes of HTTP response to return file transmission time = 2RTT + transmit time time to transmit file initiate TCP connection RTT request received time Chapter 2, slide:

10 Non-Persistent HTTP: issues
time to transmit file initiate TCP connection RTT request received time Nonpersistent HTTP: Name some issues?? requires 2 RTTs per object E.g., a 10 object-page needs ~ 20 RTTs Open/close TCP connection for each object => OS overhead Any ideas for improvement? Chapter 2, slide:

11 Persistent HTTP Persistent HTTP
server leaves connection open after sending response subsequent HTTP messages between same client/server sent over open connection reduces response time Persistent without pipelining: client issues new request only when previous response has been received one RTT for each referenced object Persistent with pipelining: default in HTTP/1.1 client sends requests as soon as it encounters a referenced object as little as one RTT for all the referenced objects Chapter 2, slide:

12 HTTP request message two types of HTTP messages: request, response
ASCII (human-readable format) request line (GET, POST, HEAD commands) GET /somedir/page.html HTTP/1.1 Host: User-agent: Mozilla/4.0 Connection: close Accept-language:fr (extra carriage return, line feed) header lines Carriage return, line feed indicates end of message Chapter 2, slide:

13 HTTP response message status line (protocol status code status phrase)
HTTP/ OK Connection close Date: Thu, 06 Aug :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 ... header lines Entity body: data, e.g., requested HTML file Chapter 2, slide:

14 HTTP response status codes
In first line in server -> client response message. A few sample codes: 200 OK request succeeded, requested object later in this message 301 Moved Permanently requested object moved, new location specified later in this message (Location:) 400 Bad Request request message not understood by server 404 Not Found requested document not found on this server 505 HTTP Version Not Supported Chapter 2, slide:

15 Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server: telnet cis.poly.edu 80 Opens TCP connection: to port 80 (default HTTP port) at cis.poly.edu (~ IP address) anything typed is sent there 2. Type in a GET HTTP request: By typing this in (hit carriage return twice), you send this minimal (but complete) GET request to HTTP server GET /~ross/ HTTP/1.1 Host: cis.poly.edu 3. Look at response message sent by HTTP server! Try it at home or lab! Chapter 2, slide:

16 Web and HTTP: Review Question
A HTTP request consists of: 1 basic html object 2 referenced JPEG objects All objects of size = 106bits RTT = 1 second Transmission rate = 1Mbps Consider transmission delay of objects only Question: how long it takes to receive the entire page: Non-persistent connection Persistent without pipelining Persistent with pipelining time to transmit file initiate TCP connection RTT request received time Chapter 2, slide:

17 Web and HTTP: Review Question
A HTTP request consists of: 1 basic html object 2 referenced JPEG objects All objects of size = 106bits RTT = 1 second Transmission rate = 1Mbps Consider transmission delay of objects only Answer: (transmit time = 1 sec) a) 3+3+3=9 sec initiate + request + transmit for each of all 3 b) =7 sec initiate + (request + transmit for each of all 3) c) 1+2+3=6 sec initiate + (request + transmit for basic) + (one request for 2 + two transmits, one for each of the 2 objects) time to transmit file initiate TCP connection RTT request received time Chapter 2, slide:

18 User-server state: cookies
Example: Susan always access Internet always from PC visits specific e-commerce site for first time when initial HTTP requests arrives at site, site creates: unique ID entry in backend database for ID Many major Web sites use cookies Four components: 1) cookie header line of HTTP response message 2) cookie header line in HTTP request message 3) cookie file kept on user’s host, managed by user’s browser 4) back-end database at Web site

19 Cookies: keeping “state” (cont.)
client server ebay 8734 usual http request msg Amazon server creates ID 1678 for user create entry cookie file usual http response Set-cookie: 1678 ebay 8734 amazon 1678 usual http request msg cookie: 1678 cookie- specific action access usual http request msg cookie: 1678 cookie- spectific action access usual http response msg backend database one week later: ebay 8734 amazon 1678 usual http response msg

20 Cookies (continued) Cookies and privacy: What cookies can bring:
aside Cookies and privacy: cookies permit sites to learn a lot about you you may supply name and to sites What cookies can bring: authorization shopping carts recommendations user session state (Web ) How to keep “state”: protocol endpoints: maintain state at sender/receiver over multiple transactions cookies: http messages carry state

21 Web caches (or proxy server)
Goal: satisfy client request without involving origin server If page is needed, browser requests it from the Web cache Q: what if object not in cache?? cache requests object from origin server, then returns object to client origin server HTTP response Proxy server HTTP request client HTTP request HTTP response client origin server Chapter 2, slide:

22 More about Web caching cache acts as both client and server
typically cache is installed by ISP (university, company, residential ISP) Why Web caching? reduce response time for client request reduce traffic on an institution’s access link. Chapter 2, slide:

23 Caching example Assumptions Consequences origin servers
avg. object size = 0.1x106bits avg. request rate from institution to origin servers = 10/sec Internet delay = 2 sec Consequences utilization on LAN = 10% (LAN: local area network) utilization on access link = 100% total delay = Internet delay + access delay + LAN delay = 2 sec + minutes + milliseconds public Internet 1 Mbps access link institutional network 10 Mbps LAN institutional cache Chapter 2, slide:

24 Caching example (cont)
origin servers possible solution increase bandwidth of access link to, say, 10 Mbps consequence utilization on LAN = 10% utilization on access link = 10% Total delay = Internet delay + access delay + LAN delay = 2 sec + msecs + msecs often a costly upgrade public Internet 10 Mbps access link institutional network 10 Mbps LAN institutional cache Chapter 2, slide:

25 Caching example (cont)
origin servers possible solution: web cache suppose hit rate is 0.4 consequence 40% requests will be satisfied almost immediately 60% requests satisfied by origin server utilization of access link reduced to 60% total avg delay will also be reduced public Internet 1 Mbps access link institutional network 10 Mbps LAN institutional cache Chapter 2, slide:

26 Web cache (cont) Solution Advantages are obvious:
Upon receiving a web request, a cache must consult origin server to check whether the requested page is up-to-date Conditional GET method What: Sent by cache to origin server: check page status When: For each new request: client checks with cache Advantages are obvious: Reduce response time Reduce internet traffic Any problems with caches?? Local cache copies of web pages may not be up-to-date?? What do we do then? Chapter 2, slide:

27 If-modified-since: <date> If-modified-since: <date>
Conditional GET cache server HTTP request msg If-modified-since: <date> HTTP response HTTP/1.0 304 Not Modified object not modified Goal: don’t send object if cache has up-to-date version How: cache specifies date of cached copy in HTTP request If-modified-since: <date> Server: response contains no object if cached copy is up-to-date: HTTP/ Not Modified HTTP request msg If-modified-since: <date> HTTP response HTTP/ OK <data> object modified Chapter 2, slide:

28 Chapter 2: Application layer
Principles of network applications Web and HTTP FTP P2P file sharing Socket programming with TCP Chapter 2, slide:

29 FTP: the file transfer protocol
user interface client file transfer FTP server user at host remote file system local file system transfer file to/from remote host client/server model client: that initiates transfer (to or from remote) server: remote host ftp: RFC 959 Chapter 2, slide:

30 FTP: separate control, data connections
FTP client contacts FTP server to open TCP control connection client browses remote directory by sending commands over the TCP control connection. TCP control connection port 21 TCP data connection port 20 FTP client FTP server when server receives file transfer command, server opens 2nd TCP data connection (for file) to client after transferring one file, server closes TCP data connection. Chapter 2, slide:

31 FTP: separate control, data connections
More on FTP server opens a separate TCP data connection for each file to transfer TCP control stays on control connection: called: “out of band” FTP client server TCP control connection port 21 TCP data connection port 20 FTP server maintains “state”: current directory, earlier authent. => limit on concurrent connections Chapter 2, slide:

32 Chapter 2: Application layer
Principles of network applications Web and HTTP FTP P2P file sharing Socket programming with TCP Chapter 2, slide:

33 File sharing approaches
server peers Alice Bob There are 2 approaches Centralized: Client-server architecture Distributed: P2P architecture (e.g., BitTorrent) obtain list of peers trading chunks peer server Chapter 2, slide:

34 File sharing: P2P vs. client-server architectures
Single point of failure Not scalable More secure Bottleneck P2P Fault-tolerant Scalable Less secure Better Robustness to failure Scalability Security Performance Chapter 2, slide:

35 Comparing Client-Server, P2P architectures
Question : What is the file distribution time: from one server to N hosts? us u2 d1 d2 u1 uN dN Server Network (with abundant bandwidth) File, size F us: server upload bandwidth ui: client/peer i upload bandwidth di: client/peer i download bandwidth Chapter 2, slide:

36 Client-server: file distribution time
server sequentially sends N copies: NF/us time client i takes F/di time to download F u2 u1 d1 d2 us Network (with abundant bandwidth) dN uN = dcs > max { NF/us, F/min(di) } i Time to distribute F to N clients using client/server approach increases linearly in N (for large N) lower bound is also achievable Chapter 2, slide:

37 P2P: file distribution time
server must send one copy: F/us time client i takes F/di time to download Server F u2 u1 d1 d2 us Network (with abundant bandwidth) dN NF bits must be downloaded - NF bits must be uploaded - Fastest possible upload rate (assuming all nodes sending file chunks to same peer) is: us + Sui uN i=1,N dP2P > max { F/us, F/min(di) , NF/(us + Sui) } i=1,N Chapter 2, slide:

38 Comparing Client-server, P2P architectures
Chapter 2, slide:

39 Chapter 2: Application layer
Principles of network applications app architectures app requirements Web and HTTP FTP P2P file sharing Socket programming with TCP (assignment 2) Chapter 2, slide:

40 Assignment 2- programming part
Building a Multi-Threaded Web Server Read Chapter 2, Section 7 first Good examples on how to write socket-programs in Java using TCP Then do your assignment Socket/Java programming: relatively simple and easy to do Chapter 2, slide:

41 Chapter 2: Summary our study of network apps now complete!
specific protocols: HTTP FTP P2P socket programming (assignment 2) application architectures client-server P2P application service requirements: reliability, bandwidth, delay Internet transport service model connection-oriented, reliable: TCP unreliable, datagrams: UDP Chapter 2, slide:


Download ppt "CS 372 – introduction to computer networks* Wednesday June 30"

Similar presentations


Ads by Google