week 4 lec 2-bit

Upload: mni007

Post on 03-Apr-2018

215 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/29/2019 Week 4 Lec 2-Bit

    1/18

    Chapter 2Application LayerComputer Networking:A Top Down Approach,4th edition.Jim Kurose, Keith RossAddison-Wesley, July2007.

  • 7/29/2019 Week 4 Lec 2-Bit

    2/18

    HTTP overview (continued)Uses TCP:

    Client initiates TCP connection to server, port 80 Server accepts TCP connection from client

    HTTP messages (application-layer protocolmessages) exchanged between browser (HTTP

    client) and Web server (HTTP server) Advantage of Layered architecture

    HTTP does not worry about lost data or how TCPrecovers from loss

    HTTP is stateless Server maintains no information about past client

    requests

  • 7/29/2019 Week 4 Lec 2-Bit

    3/18

    HTTP connections

    Nonpersistent HTTP

    At most one object issent over a TCPconnection.

    Persistent HTTP

    Multiple objects canbe sent over singleTCP connectionbetween client andserver.

  • 7/29/2019 Week 4 Lec 2-Bit

    4/18

    Nonpersistent HTTPSuppose user enters URL

    www.someSchool.edu/someDepartment/home.index

    1a. HTTP client initiates TCPconnection to HTTP server(process) at

    www.someSchool.edu on port 80

    2. HTTP client sends HTTPrequest message (containing

    URL) into TCP connection

    socket. Message indicates thatclient wants object

    someDepartment/home.index

    1b. HTTP server at hostwww.someSchool.edu waiting

    for TCP connection at port 80.accepts connection, notifying

    client

    3. HTTP server receives request

    message, forms responsemessage containing requested

    object, and sends message to

    the client

    time

    (contains text,

    references to 10

    jpeg images)

  • 7/29/2019 Week 4 Lec 2-Bit

    5/18

    Nonpersistent HTTP (cont.)

    5. HTTP client receives responsemessage containing html file,displays html. Parsing html

    file, finds 10 referenced jpegobjects

    6.Steps 1-4 repeated for eachof 10 jpeg objects

    4. HTTP server closes TCP

    connection.

    time

    When the user requests the webpage 11 TCP connectionsare generated

  • 7/29/2019 Week 4 Lec 2-Bit

    6/18

    Non-Persistent HTTP: Response time

    Definition of RTT: time fora packet to travel fromclient to server and back.

    Response time:

    one RTT to initiate TCPconnection

    one RTT for HTTPrequest response

    total = 2RTT+transmittime

    time to

    transmit

    file

    initiate TCP

    connection

    RTTrequest

    file

    RTT

    file

    received

    time time

  • 7/29/2019 Week 4 Lec 2-Bit

    7/18

    Persistent HTTP

    Nonpersistent HTTPissues:

    Requires 2 RTTs perobject

    Maintain TCP buffers inboth client and server

    Burden on the WebServer

    High overhead

    Persistent HTTP Server leaves TCP

    connection open aftersending response

    Subsequent HTTPmessages betweensame client/serversent over open

    connection Default mode is

    Persistent withpipelining

  • 7/29/2019 Week 4 Lec 2-Bit

    8/18

    HTTP Request MessageTwo types of HTTP messages:

    Request, ResponseHTTP request message:

    Human-readable format

    A typical HTTP request message

    GET /somedir/page.html HTTP/1.1Host: www.someschool.edu

    User-agent: Mozilla/4.0Connection: closeAccept-language:fr

    (Blank Line)

    Body

  • 7/29/2019 Week 4 Lec 2-Bit

    9/18

    HTTP Request Message

    Request Line

    First Line of HTTP request message

    The request line has three fields

    Method field can take on several values

    GET,POST, PUT, DELETE etcMajority of HTTP request messages use GET

    URL field

    HTTP version field

    Header Lines Host: Host on which the object resides

    User-agent: Identifies the client program e.g. Mozilla/4.0

    Connection: Shows whether the connection should be closedor not

    Accept-language: Shows the language the client prefers

  • 7/29/2019 Week 4 Lec 2-Bit

    10/18

    HTTP Request Message

    Body is empty withGET method

    Used with the POSTmethod

    Web page oftenincludes form input

    Input is sent toserver in body

    PUT method:

    To upload objects toweb server

    DELETE method Allows a user or an

    application to deletean object on web

    server

    Find out about OPTIONS, TRACE, HEAD?

  • 7/29/2019 Week 4 Lec 2-Bit

    11/18

    HTTP Response Message

    HTTP/1.1 200 OKConnection: closeDate: Thu, 06 Aug 1998 12:00:15

    GMTServer: Apache/1.3.0 (Unix)Last-Modified: Mon, 22 Jun 1998Content-Length: 6821Content-Type: text/html

    Body contains Requested Object

  • 7/29/2019 Week 4 Lec 2-Bit

    12/18

    HTTP Response Message

    Status Line Protocol Version

    Status Code and Status MessageThe status code and associated phrase indicate the result of

    the request Header Line Connection: Shows whether the connection should be closed

    or not

    Date and time: When the HTTP response was created

    Server: Analogous to user-agent in request message

    Last-modified: When the Object was last created ormodified

    Content-length: Number of bytes in object being sent

    Content-Type: Indicates the object type (HTML text etc.)

  • 7/29/2019 Week 4 Lec 2-Bit

    13/18

    HTTP Response Status Codes

    200 OK Request succeeded and information is returned in

    response

    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 Version not supported HTTP version is not supported by the server

    The status code and associated phrase indicate the result ofthe request

  • 7/29/2019 Week 4 Lec 2-Bit

    14/18

    User-Server Interaction: Cookies

    It is often desirable for webservers to identify users Server wishes to restrict

    user access Wants to serve content as a

    function of user identity Many major Web sites use

    cookies

    Four components:

    1) Cookie header line ofHTTP responsemessage

    2) Cookie header line inHTTP requestmessage3) Cookie file kept on users

    host, managed by usersbrowser

    4) Back-end database atWeb site

    Example: Susan accesses

    Internet always from PC visits specific e-

    commerce site for firsttime When initial HTTP

    requests arrives atserver, server creates: unique ID entry in backend

    database for ID

  • 7/29/2019 Week 4 Lec 2-Bit

    15/18

    Cookies: keeping state (cont.)

    ClientServer

    usual http response msg

    usual http response msg

    cookie file

    one week later:

    usual http request msgcookie: 1678 cookie-

    specific

    action

    access

    usual http request msgAmazon server

    creates ID

    1678 for user create

    entry

    usual http responseSet-cookie: 1678

    amazon 1678

    usual http request msgcookie: 1678 cookie-

    spectific

    action

    accessamazon 1678

    backend

    database

  • 7/29/2019 Week 4 Lec 2-Bit

    16/18

    Cookies (continued)

    Cookies Pages visited in which

    order and at whattimes

    Shopping carts One click shopping Recommendations of

    other products

    Cookies and privacy: Cookies permit sites to

    learn a lot about you

    Can inform thirdparty You may supply name

    and e-mail to sites

    For more info on Cookies see RFC-2965 HTTP State Management Mechanism www.cookiecentral.com

  • 7/29/2019 Week 4 Lec 2-Bit

    17/18

    Web Caches (Proxy Server)

    Web Cache has its owndisk storage

    Keeps copies of recentlyrequested objects in

    storage User sets browser: Web

    accesses via cache

    Browser sends all HTTPrequests to cache

    object in cache: cachereturns object

    else cache requestsobject from origin

    server, then returnsobject to client

    Goal: Satisfy client request without involving origin server

    Client

    Proxy

    Server

    Client

    OriginServer

  • 7/29/2019 Week 4 Lec 2-Bit

    18/18

    More about Web Caching

    Cache acts as bothclient and server

    Typically cache isinstalled by ISP(university, company)

    Why Web Caching?

    Reduce response timefor client request

    Reduce traffic on aninstitutions access link. Does not have to upgrade

    bandwidth as quickly,thereby reducing costs.