Showing posts with label HTTP. Show all posts
Showing posts with label HTTP. Show all posts

Sunday, May 25, 2014

Cookies: Keeping “State”

Many major Web sites use cookies                                  
Four components:
1) Cookie header line in the
HTTP response message
2) Cookie header line in HTTP
request message
3) Cookie file kept on user’s host
and managed by user’s
browser
4) Back-end database at Web
site

Example:
- Susan accesses Internet always
from same PC
- She visits a specific e-commerce
site for the first time
- When initial HTTP requests arrives
at site, site creates a unique ID
and creates an entry in backend
database for ID


HTTP 0.9/1.0

● One request/response per TCP connection
– Simple to implement
● Disadvantages
– Multiple connection setups → three-way
handshake each time
● Several extra round trips added to transfer

– Multiple slow starts

Single Transfer Example


Performance Issues

● Short transfers are hard on TCP
– Stuck in slow start
● Lots of extra connections
– Increases server state/processing
● Servers also hang on to connection state after
the connection is closed
– Why must server keep these?
– Tends to be an order of magnitude greater than #

of active connections, why?

Netscape Solution
● Mosaic (original popular Web browser) fetched
one object at a time!
● Netscape uses multiple concurrent
connections to improve response time
– Different parts of Web page arrive independently
– Can grab more of the network bandwidth than
other users
● Doesn’t necessarily improve response time
– TCP loss recovery ends up being timeout

dominated because windows are small

Persistent Connection Solution
● Multiplex multiple transfers onto one TCP connection  (Fewer RTTs and less slow start)

HTTP 1.1 New Features

Newer versions of HTTP (1.1) add several  new features (persistent connections, pipelined transfers) to speed things up.

HTTP Basic

HTTP layered over bidirectional byte stream
– Almost always TCP
● Interaction
– Client sends request to server, followed by
response from server to client
– Requests/responses are encoded in text
● Stateless
– Server maintains no information about past client requests

 HTTP Request
 Request line
– Method
● GET – return URI
● HEAD – return headers only of GET response
● POST – send data to the server (forms, etc.)

– URI
● E.g. http://www.intel-iris.net/index.html with a proxy
● E.g. /index.html if no proxy
– HTTP version

● Request headers
– Authorization – authentication info
– Acceptable document types/encodings
– From – user email
– If-Modified-Since
– Referrer – what caused this page to be requested
– User-Agent – client software

Blank-line
Body

HTTP Request Example

GET /site/nqdinhddt/ HTTP/1.1
Host: sites.google.com
User-Agent: Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:15.0)
Gecko/20100101 Firefox/15.0.1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-us,en;q=0.5
Accept-Encoding: gzip, deflate
Connection: keep-alive
Cookie: [...]
If-Modified-Since: Mon, 24 Sep 2012 22:31:22 GMT

If-None-Match: "1348525882000|#public|0|en|||0"

HTTP Response
● Status-line
– HTTP version
– 3 digit response code
● 1XX – informational
● 2XX – success
– 200 OK
● 3XX – redirection
– 301 Moved Permanently
– 303 Moved Temporarily

304 Not Modified
● 4XX – client error
– 404 Not Found
● 5XX – server error
– 505 HTTP Version Not Supported
Reason phrase
● Headers
– Location – for redirection
– Server – server software
– WWW-Authenticate – request for authentication
– Allow – list of methods supported (get, head, etc)
– Content-Encoding – E.g x-gzip
– Content-Length
– Content-Type
– Expires
– Last-Modified
Blank-line
Body

HTTP/1.1 200 OK
Date: Tue, 27 Mar 2001 03:49:38 GMT
Server: Apache/1.3.14 (Unix)  (Red­Hat/Linux)
mod_ssl/2.7.1 OpenSSL/0.9.5a DAV/1.0.2 PHP/4.0.1pl2
mod_perl/1.24
Last­Modified: Mon, 29 Jan 2001 17:54:18 GMT
ETag: "7a11f­10ed­3a75ae4a"
Accept­Ranges: bytes
Content­Length: 4333
Keep­Alive: timeout=15, max=100
Connection: Keep­Alive
Content­Type: text/html
…..

Applications (Example with HTTP and FTP)

Some parts of this presentation are copied from
● Roger Dannenberg, Srinivasan Seshan, lecture notes in Computer Network,
CMU http://www.cs.cmu.edu/~srini/15-441/F11/
● Jorg Liebeherr, lecture notes in Internet Engineering, Virginia Uni.,
http://www.cs.virginia.edu/~cs458/
● TCP/IP Protocol Suite lecture notes, The McGraw-Hill Companies, Inc., 2000

Client-Server Paradigm                                                
  
Client:
• Initiates contact with server
(“speaks first”)
• Typically requests service from
server,
• For Web, client is implemented in
browser; for e-mail, in mail reader
Server:
• Provides requested service to
client
• e.g., Web server sends requested
Web page, mail server delivers e-mail




Client-Server with Socket API


What Service Does an Application Need?

Data loss
Some apps (e.g., audio) can
tolerate some loss
● Other apps (e.g., file transfer,

telnet) require 100% reliable data transfer

Timing
Some apps (e.g., Internet
telephony, interactive games)
require low delay to be
“effective”

Bandwidth
Some apps (e.g., multimedia) require minimum amount of bandwidth to
be “effective”

• Other apps (“elastic apps”) make use of whatever bandwidth they get

Transport Service Reqs of Common Apps.

Other Requirements
Network reliability
– Network service must always be available
Security: privacy, denial of service,
authentication, …
Scalability.
– Scale to large numbers of users, traffic flows, …

Manageability: monitoring, control, …

FTP: The File Transfer Protocol


Transfer file to/from remote host
● Client/server model
– Client: side that initiates transfer (either to/from remote)
– Server: remote host
● FTP: RFC 959

● FTP server: port 21

FTP: Separate Control, Data Connection
FTP client contacts FTP server                                            
at port 21, specifying TCP as
transport protocol
● Two parallel TCP connections
opened:
– Control: exchange
commands, responses
between client, server. “out
of band control”
– Data: file data to/from server
● FTP server maintains “state”:
current directory, earlier

authentication




FTP: Commands, Response


Trivial File Transfer Protocol (TFTP)

Use UDP instead of TCP
Serve at port 69