Upload
noble-valenzuela
View
43
Download
0
Tags:
Embed Size (px)
DESCRIPTION
UCSD CSE 124 Networked Services Fall 2009. B. S. Manoj, Ph.D http://cseweb.ucsd.edu/classes/fa09/cse124. Some of these slides are adapted from various sources/individuals including but not limited to the slides from the text books by Kurose and Ross, Tanenbaum, and Peterson and Davie. - PowerPoint PPT Presentation
Citation preview
UCSD CSE 124Networked Services
Fall 2009
B. S. Manoj, Ph.Dhttp://cseweb.ucsd.edu/classes/fa09/cse124
10/1/2009 1UCSD CSE 124 Networked Services Fall 2009
Some of these slides are adapted from various sources/individuals including but not limited to the slides from the text books by Kurose and Ross, Tanenbaum, and Peterson and Davie. Use of these slides other than for pedagogical purpose for CSE 124, may require explicit permissions from the respective sources.
Design considerations for Network Protocol stack
• Design for minimum context switches– e.g., Application layer calls send(.) function with
message to be sent• The message can be sent immediately with minimal
delay
– Application layer calls receive(.): context switching can result
– Such cases, call back functions, e.g., deliver(.), can improve performance by minimizing context switches
10/1/2009 2UCSD CSE 124 Networked Services Fall 2009
Design consideration for network protocol stack
• Design for copy-free operation– Message copying is expensive– Define and use a common message abstraction
across layers and protocols of the stack• Permits passing messages up and down the stack with
minimal copying• Manipulation of the messages/packets is done in a
copy-free manner– Two approaches
• Message processing with a priori memory allocation• Message processing with linked lists
10/1/2009 3UCSD CSE 124 Networked Services Fall 2009
Application layer messagePre-assigned memory
Application
Transport
Network
Datalink
PHY
Message copy
Copy-free
Copy-free
Copy-free
Message copy
Message processing with a priori memory allocation
10/1/2009 4UCSD CSE 124 Networked Services Fall 2009
Message processing with linked-list implementation
Application layer messagePre-assigned memory
Application
Transport
Network
Datalink
PHY
Message copy
Copy-free
Copy-free
Copy-free
Message copy10/1/2009 5UCSD CSE 124 Networked Services Fall
2009
Application Layer Protocols • Hiper Text Transfer Protocol
(HTTP) is one of the most popular application layer protocols
• HTTP drives the success of WWW– Handles heterogeniety of clients
and servers
• WWW is a collection of cooperating servers and clients speaking HTTP
• A web browser software helps users to open web locations, referred to as Uniform Resource Locators (URLs)– http://www.ucsd.edu/index.html– http://cseweb.ucsd.edu/classes/
fa09/cse124
PC runningExplorer
Server running
Apache Webserver
Mac runningNavigator
HTTP request
HTTP request
HTTP response
HTTP response
10/1/2009 6UCSD CSE 124 Networked Services Fall 2009
HTTP• HTTP is a text-based protocol
– Readable text-based commands, unlike binary-commands or code-based commands, and information are used for communication
• Defines how the communication between a web browser and web server can take place
• Is stateless – It does not require any state information– However, new methods are added on to gather state or user information
• For example, cookies • Two kinds of messages used
• REQUEST messages• RESPONSE messages
• General message form• START_LINE <CRLF>• MESSAGE_HEADER <CRLF>• <CRLF>• MESSAGE_ BODY <CRLF>
10/1/2009 7UCSD CSE 124 Networked Services Fall 2009
HTTP• A webpage contains one or more objects
– Can be html files, JPEG or GIF images, JAVA applet, or a video clip
• A web page with one html file and n other number of additional objects making it n+1 total objects
• All these objects are located by URLs– e.g.,
http://classweb.ucsd.edu/classes/fa09/cse124/index.html – A URL has two parts
• A host part: classweb.ucsd.edu• A file name with path information: /classes/fa09/cse124/index/html
• A user requests a web server object by – Either entering the URL on the browser’s address bar– Or clicking a hyper link on a web page
10/1/2009 8UCSD CSE 124 Networked Services Fall 2009
UCSD CSE 124 Networked Services Fall 2009 9
An HTTP sessionSuppose user enters URL www.classweb.ucsd.edu/classes/fa09/cse124/index.html
1a. HTTP client initiates TCP connection to HTTP server (process) at www.classweb.ucsd.edu on port 80
2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object classes/fa09/cse124/index.html
1b. HTTP server at host www.classweb.ucsd.edu waiting for TCP connection at port 80. “accepts” connection, notifying client
3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket
time
(contains text, references to 10
jpeg images)
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 10
An HTTP Session (cont.)
5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects
6. Steps 1-5 repeated for each of 10 jpeg objects
4. HTTP server closes TCP connection.
time
10/1/2009
HTTP message format
• General format =>
11
GET /somedir/page.html HTTP/1.0Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:en
(extra carriage return, line feed)
request line(GET, POST,
HEAD commands)
header lines
Carriage return, line feed
indicates end of message
10/1/2009 UCSD CSE 124 Networked Services Fall 2009
HTTP REQUEST operations• GET: Fetches a specific web object
• HEAD: Fetch the status of the specific web object (such as time stamp)
• POST: Send information (filled forms, or other info) to the server
• PUT: Store documents at the specific web URL (used for uploading documents)
• DELETE: Delete a specific URL (with sufficient permissions)
• TRACE: Loop back the message (for debugging, or for security verifications)
• CONNECT: For use by proxy servers or for future purpose
• OPTIONS: Query certain options available with servers10/1/2009 12UCSD CSE 124 Networked Services Fall
2009
Response messagesCODE Type Example(s)
1xx Informational 100=Server agrees to handle the client’s request
2xx Success 200=Request successful, 204= no content present
3xx Redirection 301=page moved (see Location: ), 304= cached page still valid, further action may be required to complete the request
4xx Client error 400=Bad request, 403= forbidden pages, 404=page not found
5xx Server error 500=internal server error, 503=try again later, 505= HTTP version not supported
HTTP/1.1 200 OK Connection closeDate: 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 content here (NON textual data in MIME encoded)
status line(protocol
status codestatus phrase)
header lines
data, e.g., requestedHTML file
10/1/2009 13UCSD CSE 124 Networked Services Fall 2009
UCSD CSE 124 Networked Services Fall 2009 14
Non-Persistent HTTP: Response time
Definition of RTT: time for 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 timetotal = 2RTT+transmit time
time to transmit file
initiate TCPconnection
RTT
requestfile
RTT
filereceived
time time
10/1/2009
Non-persistent and Persistent HTTP
Non persistent HTTP (HTTP 1.0) Persistent HTTP (HTTP/1.1)
Uses separate TCP connections for each object Allows a single TCP connection to persist over multiple object transfers
High communication overhead: Too many control packets sent
Multiple request/response sessions can happen over the same socket, so less communication overhead
High computing resource overhead: Too many sockets created and closed
Low computing overhead as only fewer sockets are to be maintained
Increased response time (waits for a new connection setup for every object)
Quick response as the socket is ready for communication
Low scalability (high server load) High scalability due to low server load
Communication between a client and server can lost longer (for eg. Web-based email) thus leading to large number of sockets through out the entire session.
• Can one socket get all the data necessary ? (Multiple sockets may still be helpful in parallelizing the communication)
• How long a socket can remain open? (session TIMEOUT is necessary)
10/1/2009 15UCSD CSE 124 Networked Services Fall 2009
Data rendering using HTML• Very simple text-based
format
• Uses a set of tags to render the information in a web browser
• Supports a large number of types of data to be typed– Image, scripts, forms, etc
• Constantly being improved – For example, XML or other
dynamic forms
• Originally defined for static content
10/1/2009 16UCSD CSE 124 Networked Services Fall 2009
Dynamic content• Dynamic content are produced as a result of execution some back-end
program or script at the web-server
• Most recent web-based systems require dynamic content generation and delivery
• Two types– Server side dynamic content generation
• Many popular types– CGI Scripts– Server-based scripts
» PHP» Java Server Pages» Active Server Pages
– Client side dynamic content generation• Executed at the client web-browser• JavaScripts• ActiveX Controls
10/1/2009 17UCSD CSE 124 Networked Services Fall 2009
Common Gateway Interface (CGI) scripts
• Allows web servers to talk to back-end programs or data bases
• CGI scripts accepts data and generate HTML pages in return
• Usually implemented in Perl or scripting languages
• Usually CGI scripts are placed in a folder called CGI-bin• e.g., www.somesite.com/cgi-bin/signup.perl
10/1/2009 18UCSD CSE 124 Networked Services Fall 2009
Server-side scripts for dynamic content generation
• Simpler than CGI-scripts• Can be embedded in the HTML files
– can be executed by the web server directly for generating the dynamic content
• A popular open source solution is PHP– PHP: Hypertext Preprocessor
• Pages created by php has extension .php• An example script• Other solutions
– Java Server Pages– Active Server Pages
10/1/2009 19UCSD CSE 124 Networked Services Fall 2009
Client-side dynamic content generation
• Unlike server-side dynamic content generation, client-side dynamic content generation does not involve server interaction
• JavaScript or ActiveX controls are popular software scripts for generating client-side dynamic content generation
10/1/2009 20UCSD CSE 124 Networked Services Fall 2009
State maintenance in HTTP sessions
• Most recent web servers attempt to maintain state information– To better serve connections and users – To provide differentiated services to users
• Two main methods:– protocol endpoints: maintain state at sender/receiver over multiple transactions– cookies: carried in http messages can contain session state
• Cookies– State information is maintained by storing small text files called cookies– Server can request to store a short text file or information in the client machine’s
hard disk – For subsequent visits, the client web browser transmits the information back to the
server• Four steps for Cookies
– cookie header line of HTTP response message– cookie header line in HTTP request message– cookie file kept on user’s host, managed by user’s browser– back-end database at Web site
10/1/2009 21UCSD CSE 124 Networked Services Fall 2009
UCSD CSE 124 Networked Services Fall 2009 22
Cookies: An exampleclient
server
usual http response msg
usual http response msg
cookie file
one week later:
usual http request msgcookie: 1678 cookie-
specificaction
access
ebay 8734usual http request msg Amazon server
creates ID1678 for user create
entry
usual http response Set-cookie: 1678
ebay 8734amazon 1678
usual http request msgcookie: 1678 cookie-
spectificaction
accessebay 8734amazon 1678
backenddatabase
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 23
Web caches (proxy server)
• user sets browser: Web accesses via cache
• browser sends all HTTP requests to cache– object in cache: cache
returns object – else cache requests object
from origin server, then returns object to client
Goal: satisfy client request without involving origin server
client
Proxyserver
client
HTTP request
HTTP response
HTTP request HTTP request
origin server
origin server
HTTP response HTTP response
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 24
More about Web caching
• A Web cache acts as both client and server
• Typically Web 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.• Internet dense with caches:
enables “poor” content providers to effectively deliver content (but so does P2P file sharing)
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 25
Caching example Assumptions• average object size = 1,000,000
bits• avg. request rate from institution’s
browsers to origin servers = 15/sec• delay from institutional router to
any origin server and back to router = 2 sec
Consequences• utilization on LAN =
(15/sec)x(1Mbits)/100Mbps= 15%• utilization on access link =
(15/sec)x(1Mbits)/15Mbps =100%• total delay = Internet delay + access
delay + LAN delay = 2 sec + minutes + milliseconds
originservers
public Internet
institutionalnetwork 100 Mbps LAN
15 Mbps access link
institutionalcache
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 26
Caching example (cont)
possible solution• increase bandwidth of access link
to, say, 100 Mbps
consequence• utilization on LAN = 15%• utilization on access link = 15%• Total delay = Internet delay + access
delay + LAN delay = 2 sec + msecs + msecs• often a costly upgrade
originservers
public Internet
institutionalnetwork 100 Mbps LAN
100 Mbps access link
institutionalcache
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 27
Caching example (cont)
possible solution: install cache• suppose hit rate is 0.4consequence• 40% requests will be satisfied
almost immediately• 60% requests satisfied by origin
server• utilization 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 secs
originservers
public Internet
institutionalnetwork 100 Mbps LAN
15 Mbps access link
institutionalcache
10/1/2009
UCSD CSE 124 Networked Services Fall 2009 28
Conditional GET
• Goal: don’t send object if cache has up-to-date cached version
• cache: specify date of cached copy in HTTP requestIf-modified-since:
<date>
• server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not
Modified
cache server
HTTP request msgIf-modified-since:
<date>
HTTP responseHTTP/1.0
304 Not Modified
object not
modified
HTTP request msgIf-modified-since:
<date>
HTTP responseHTTP/1.0 200 OK
<data>
object modified
10/1/2009
Summary
• Copy free operations for protocol stack efficiency• Application layer protocol: HTTP • Dynamic content generation for HTTP• Web Caching/Proxy servers for HTTP
10/1/2009 29UCSD CSE 124 Networked Services Fall 2009
Homework-1• Capture one or more HTTP session messages using
Wireshark for the following two URLs and briefly explain the trace including the image of the trace– http://cseweb.ucsd.edu/classes/fa09/cse124/index.html– http://blink.ucsd.edu– Deadline: Next week Thursday, the 8th October, 2009– Submission by email with SUBJECT: CSE-124-Fall-2009-
HomeWork-1:<YourFirstName>
• Chapter 2, Problem P9 from Kurose and Ross (Page 183) in 5th edition• Submission either in paper or by email with SUBJECT: CSE-
124-Fall-2009-HomeWork-1:<YourFirstName>10/1/2009 30UCSD CSE 124 Networked Services Fall
2009