jarkom 1 - application layer-1 (kuroseross) - principle, http v2015.pdf

Upload: davira-laquitta

Post on 08-Jul-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    1/42

    2: Application Layer   1

    Chapter 2

    Application Layer

    Computer Networking:A Top Down Approach,5th edition.Jim Kurose, Keith RossAddison-Wesley, April2009.

    Jaringan Komputer Jurusan Ilmu Komputer/ Informatika

    Universitas Diponegoro

    2014/2015

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    2/42

    2: Application Layer   2

    Chapter 2: Application Layer

    Our goals: conceptual,

    implementationaspects of network

    application protocols transport-layer

    service models

    client-server

    paradigm peer-to-peer

    paradigm

    learn about protocolsby examining popularapplication-levelprotocols

    HTTP FTP

    SMTP / POP3 / IMAP

    DNS

    programming networkapplications

    socket API

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    3/42

    2: Application Layer   3

    Some network apps

    e-mail

    web

    instant messaging

    remote login P2P file sharing

    multi-user networkgames

    streaming stored videoclips

    social networks

    voice over IP

    real-time video

    conferencing grid computing

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    4/42

    2: Application Layer   4

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    5/42

    2: Application Layer   5

    Creating a network app

    write programs that run on (different) end

    systems 

    communicate over network

    e.g., web server softwarecommunicates with browsersoftware

    No need to write softwarefor network-core devices Network-core devices do

    not run user applications

    applications on end systemsallows for rapid appdevelopment, propagation

    applicationtransportnetworkdata link

    physical

    applicationtransportnetwork

    data linkphysical

    applicationtransportnetworkdata linkphysical

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    6/42

    2: Application Layer   6

    Chapter 2: Application layer

    Principles of networkapplications

    Web and HTTP

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    7/42

    2: Application Layer   7

    Application architectures

    Client-server Including data centers / cloud computing

    Peer-to-peer (P2P)

    Hybrid of client-server and P2P

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    8/42

    2: Application Layer   8

    Client-server architecture

    server: always-on host

    permanent IP address

    server farms forscaling

    clients: communicate with server

    may be intermittently

    connected may have dynamic IP

    addresses

    do not communicatedirectly with each other

    client/server

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    9/42

    Google Data Centers

    Estimated cost of data center: $600M

    Google spent $2.4B in 2007 on new data centers

    Each data center uses 50-100 megawatts of power

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    10/42

    2: Application Layer   10

    Pure P2P architecture

    no always-on server

    arbitrary end systemsdirectly communicate

    peers are intermittentlyconnected and change IPaddresses

    Highly scalable butdifficult to manage

    peer-peer

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    11/42

    2: Application Layer   11

    Hybrid of client-server and P2P

    Skype voice-over-IP P2P application centralized server: finding address of remote

    party: client-client connection: direct (not through

    server)Instant messaging

    chatting between two users is P2P centralized service: client presence

    detection/location• user registers its IP address with central

    server when it comes online• user contacts central server to find IP

    addresses of buddies

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    12/42

    2: Application Layer   12

    Processes communicating

    Process: program runningwithin a host.

    within same host, twoprocesses communicate

    using inter-processcommunication (definedby OS).

    processes in different

    hosts communicate byexchanging messages

    Client process: processthat initiatescommunication

    Server process: process

    that waits to becontacted

    Note: applications with

    P2P architectures haveclient processes &server processes

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    13/42

    2: Application Layer   13

    Sockets

    process sends/receivesmessages to/from itssocket

    socket analogous to door sending process shoves

    message out door

    sending process relies ontransport infrastructureon other side of door whichbrings message to socketat receiving process

     process

    TCP with

     buffers,

    variables

    socket

    host or server 

     process

    TCP with

     buffers,

    variables

    socket

    host or server 

    Internet

    controlled by OS

    controlled by

    app developer 

    API: (1) choice of transport protocol; (2) ability to fixa few parameters (lots more on this later)

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    14/42

    2: Application Layer   14

    Addressing processes

    to receive messages,process must haveidentifier 

    host device has unique32-bit IP address

    Exercise: use ipconfigfrom command prompt toget your IP address(Windows)

    Q: does IP address of

    host on which processruns suffice foridentifying the process?

    A: No, many processes

    can be running onsame

    Identifier includes bothIP address and portnumbers associated withprocess on host.

    Example port numbers: HTTP server: 80

    Mail server: 25

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    15/42

    2: Application Layer   15

    App-layer protocol Defines:

    1. Types of messagesexchanged, e.g., request, response

    2. Message syntax: what fields in messages &

    how fields are delineated

    3. Message semantics meaning of information in

    fields4. Rules for when and how

    processes send &respond to messages

    Public-domain protocols:

    defined in RFCs

    allows for

    interoperability e.g., HTTP, SMTP,

    BitTorrent

    Proprietary protocols:

    e.g., Skype, ppstream

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    16/42

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    17/42

    2: Application Layer   17

    Transport service requirements of common apps

    Application

    file transfer 

    e-mail

    Web documentsreal-time audio/video

    stored audio/video

    interactive games

    instant messaging

    Data loss

    no loss

    no loss

    no lossloss-tolerant

    loss-tolerant

    loss-tolerant

    no loss

    Throughput

    elastic

    elastic

    elasticaudio: 5kbps-1Mbps

    video:10kbps-5Mbps

    same as above

    few kbps up

    elastic

    Time Sensitive

    no

    no

    noyes, 100’s msec

    yes, few secs

    yes, 100’s msec

    yes and no

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    18/42

    2: Application Layer   18

    Internet transport protocols services

    TCP service: connection-oriented: setup

    required between client andserver processes

    reliable transport betweensending and receiving process

    flow control: sender won’toverwhelm receiver

    congestion control: throttle

    sender when networkoverloaded

    does not provide: timing,minimum throughputguarantees, security

    UDP service: unreliable data transfer

    between sending andreceiving process

    does not provide:connection setup,reliability, flow control,congestion control, timing,throughput guarantee, or

    security

    Q: why bother? Why isthere a UDP?

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    19/42

    2: Application Layer   19

    Internet apps: application, transport protocols

    Application

    e-mail

    remote terminal access

    Webfile transfer 

    streaming multimedia

    Internet telephony

    Applicationlayer protocol

    SMTP [RFC 2821]

    Telnet [RFC 854]

    HTTP [RFC 2616]FTP [RFC 959]

    HTTP (eg Youtube),

    RTP [RFC 1889]

    SIP, RTP, proprietary

    (e.g., Skype)

    Underlyingtransport protocol

    TCP

    TCP

    TCPTCP

    TCP or UDP

    typically UDP

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    20/42

    2: Application Layer   20

    Chapter 2: Application layer

    Principles of networkapplications

    Web and HTTP

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    21/42

    2: Application Layer   21

    Web and HTTP

    First some jargon

    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:www.someschool.edu/someDept/pic.gif

    host name path name

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    22/42

    2: Application Layer   22

    HTTP overview

    HTTP: hypertexttransfer protocol

    Web’s application layerprotocol

    client/server model client: browser that

    requests, receives,“displays” Web objects

    server: Web server

    sends objects inresponse to requests

    PC runningExplorer

    Serverrunning

    Apache Web

    server

    Mac runningNavigator

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    23/42

    2: Application Layer   23

    HTTP overview (continued)

    Uses TCP: client initiates TCP

    connection (creates socket)to server, port 80

    server accepts TCPconnection from client

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

    (HTTP client) and Webserver (HTTP server)

    TCP connection closed

    HTTP is “stateless” server maintains no

    information aboutpast client requests

    Protocols that maintain“state” are complex!

    past history (state) mustbe maintained

    if server/client crashes,their views of “state” maybe inconsistent, must bereconciled

    aside

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    24/42

    HTTP connections

    Nonpersistent HTTP

    At most one object issent over a TCPconnection.

    Persistent HTTP

    Multiple objects canbe sent over singleTCP connectionbetween client andserver.

    2: Application Layer   24

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    25/42

    2: Application Layer   25

    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 (containingURL) into TCP connection

    socket. Message indicatesthat client wants objectsomeDepartment/home.index

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

    for TCP connection at port 80.“accepts” connection, notifyingclient

    3. HTTP server receives request

    message, forms responsemessage containing requestedobject, and sends messageinto its socket

    time

    (contains text,

    references to 10

     jpeg images)

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    26/42

    2: Application Layer   26

    Nonpersistent HTTP (cont.)

    5. HTTP client receives responsemessage containing html file,displays html. Parsing htmlfile, finds 10 referenced jpegobjects

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

    4. HTTP server closes TCPconnection.

    time

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    27/42

    2: Application Layer   27

    Non-Persistent HTTP: Response time

    Definition of RTT: time fora small packet to travelfrom client to server andback.

    Response time:

    one RTT to initiate TCPconnection

    one RTT for HTTPrequest and first fewbytes of HTTP responseto return

    file transmission time

    total = 2RTT+transmit time

    time totransmitfile

    initiate TCPconnection

    RTT 

    requestfile

    RTT 

    file

    received

    time   time

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    28/42

    2: Application Layer   28

    Persistent HTTP

    Nonpersistent HTTP issues: requires 2 RTTs per object

    OS overhead for each TCPconnection

    browsers often open parallel

    TCP connections to fetchreferenced objects

    Persistent HTTP server leaves connection

    open after sendingresponse

    subsequent HTTP messages

    between sameclient/server sent overopen connection

    client sends requests assoon as it encounters a

    referenced object as little as one RTT for all

    the referenced objects

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    29/42

    2: Application Layer   29

    HTTP request message

    two types of HTTP messages: request , response

    HTTP request message: ASCII (human-readable format)

    GET /somedir/page.html HTTP/1.1

    Host: www.someschool.edu

    User-agent: Mozilla/4.0

    Connection: close

     Accept-language:fr

    (extra carriage return, line feed)

    request line(GET, POST,

    HEAD commands)

    header

    lines

    Carriage return,line feed

    indicates end

    of message

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    30/42

    2: Application Layer   30

    HTTP request message: general format

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    31/42

    2: Application Layer   31

    Uploading form input

    Post method:

    Web page oftenincludes form input

    Input is uploaded toserver in entity body

    URL method:

    Uses GET method

    Input is uploaded inURL field of requestline:

    www.somesite.com/animalsearch?monkeys&banana

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    32/42

    2: Application Layer   32

    Method types

    HTTP/1.0

    GET 

    POST 

    HEAD asks server to leave

    requested object out ofresponse

    HTTP/1.1

    GET, POST, HEAD

    PUT  uploads file in entity

    body to path specifiedin URL field

    DELETE deletes file specified in

    the URL field

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    33/42

    2: Application Layer   33

    HTTP response message

    HTTP/1.1 200 OK

    Connection close

    Date: 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 data data data data ...

    status line(protocolstatus code

    status phrase)

    headerlines

    data, e.g.,

    requestedHTML file

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    34/42

    2: Application Layer   34

    HTTP response status 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 server404 Not Found 

    requested document not found on this server

    505 HTTP Version Not Supported 

    In first line in server->client response message.A few sample codes:

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    35/42

    2: Application Layer   35

    Trying out HTTP (client side) for yourself

    1. Telnet to your favorite Web server:

    Opens TCP connection to port 80(default HTTP server port) at cis.poly.edu.Anything typed in sent

    to port 80 at cis.poly.edu

    telnet cis.poly.edu 80

    2. Type in a GET HTTP request:

    GET /~ross/ HTTP/1.1

    Host: cis.poly.edu

    By typing this in (hit carriagereturn twice), you send

    this minimal (but complete)GET request to HTTP server

    3. Look at response message sent by HTTP server!

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    36/42

    2: Application Layer   36

    User-server state: cookies

    Many major Web sitesuse cookies

    Four components:1) cookie header line of

    HTTP response message2) cookie header line inHTTP request message

    3) cookie file kept onuser’s host, managed byuser’s browser

    4) back-end database atWeb site

    Example: Susan always access

    Internet always from PC

    visits specific e-

    commerce site for firsttime

    when initial HTTPrequests arrives at site,

    site creates: unique ID

    entry in backenddatabase for ID

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    37/42

    2: Application Layer   37

    Cookies: keeping “state” (cont.)

    client

    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 responseSet-cookie: 1678

    ebay 8734amazon 1678

    usual http request msgcookie: 1678 cookie-

    spectificaction

    accessebay 8734

    amazon 1678

    backenddatabase

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    38/42

    2: Application Layer   38

    Cookies (continued)

    What cookies can bring: authorization

    shopping carts

    recommendations

    user session state(Web e-mail)

    Cookies and privacy: cookies permit sites to

    learn a lot about you

     you may supply name

    and e-mail to sites

    aside

    How to keep “state”:

    protocol endpoints: maintain stateat sender/receiver over multipletransactions

    cookies: http messages carry state

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    39/42

    2: Application Layer   39

    Web caches (proxy server)

    user sets browser:Web accesses viacache

    browser sends allHTTP requests tocache object in cache: cache

    returns object else cache requests

    object from originserver, then returnsobject to client

    Goal: satisfy client request without involving origin server

    client

    Proxy

    server

    clientoriginserver

    originserver

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    40/42

    2: Application Layer   40

    More about Web caching

    cache acts as bothclient and server

    typically cache isinstalled by ISP

    (university, company,residential ISP)

    Why Web caching?

    reduce response timefor client request

    reduce traffic on aninstitution’s accesslink.

    Internet dense withcaches: enables “poor”

    content providers toeffectively delivercontent (but so doesP2P file sharing)

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    41/42

    2: Application Layer   41

    Conditional GET 

    Goal: don’t send object ifcache has up-to-date cachedversion

    cache: specify date ofcached copy in HTTP requestIf-modified-since:

      

    server: response contains noobject if cached copy is up-to-date:HTTP/1.0 304 Not

     Modified 

    cache serverHTTP request msgIf-modified-since:

      

    HTTP responseHTTP/1.0

    304 Not Modified 

    objectnot

    modified

    HTTP request msgIf-modified-since:

      

    HTTP responseHTTP/1.0 200 OK 

      

    objectmodified

  • 8/19/2019 Jarkom 1 - Application Layer-1 (kuroseRoss) - Principle, HTTP V2015.pdf

    42/42

    Thank You

    NextEmail

    DNS