application layer (computer network)

Upload: akashzincle9384

Post on 04-Apr-2018

219 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/31/2019 Application Layer (Computer Network)

    1/104

    2: Application Layer 1

    Chapter 2

    Application Layer

    Computer Networking:A Top Down ApproachFeaturing the Internet,

    2nd edition.Jim Kurose, Keith RossAddison-Wesley, July2002.

    A note on the use of these ppt slides:Were making these slides freely available to all (faculty, students, readers).

    Theyre in PowerPoint form so you can add, modify, and delete slides

    (including this one) and slide content to suit your needs. They obviously

    represent a lotof work on our part. In return for use, we only ask the

    following:

    If you use these slides (e.g., in a class) in substantially unaltered form,that you mention their source (after all, wed like people to use our book!)

    If you post any slides in substantially unaltered form on a www site, that

    you note that they are adapted from (or perhaps identical to) our slides, and

    note our copyright of this material.

    Thanks and enjoy! JFK/KWR

    All material copyright 1996-2002

    J.F Kurose and K.W. Ross, All Rights Reserved

  • 7/31/2019 Application Layer (Computer Network)

    2/104

    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

  • 7/31/2019 Application Layer (Computer Network)

    3/104

    2: Application Layer 3

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP 2.4 Electronic Mail

    SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

  • 7/31/2019 Application Layer (Computer Network)

    4/104

    2: Application Layer 4

    Network applications: some jargon

    Process: program runningwithin a host.

    within same host, twoprocesses communicateusing interprocesscommunication (definedby OS).

    processes running in

    different hostscommunicate with anapplication-layerprotocol

    user agent: interfaceswith user above andnetwork below.

    implements userinterface &application-levelprotocol Web: browser

    E-mail: mail reader streaming audio/video:

    media player

  • 7/31/2019 Application Layer (Computer Network)

    5/104

    2: Application Layer 5

    Applications and application-layer protocols

    Application: communicating,distributed processes e.g., e-mail, Web, P2P file

    sharing, instant messaging running in end systems

    (hosts) exchange messages to

    implement application

    Application-layer protocols one piece of an app

    define messagesexchanged by apps andactions taken

    use communication servicesprovided by lower layer

    protocols (TCP, UDP)

    applicationtransportnetworkdata linkphysical

    applicationtransport

    networkdata linkphysical

    application

    transportnetworkdata linkphysical

  • 7/31/2019 Application Layer (Computer Network)

    6/104

    2: Application Layer 6

    App-layer protocol defines

    Types of messagesexchanged, e.g., request& response messages

    Syntax of message

    types: what fields inmessages & how fieldsare delineated

    Semantics of the fields,i.e., meaning ofinformation in fields

    Rules for when and howprocesses send &respond to messages

    Public-domain protocols:

    defined in RFCs

    allows for

    interoperability eg, HTTP, SMTP

    Proprietary protocols:

    eg, KaZaA

  • 7/31/2019 Application Layer (Computer Network)

    7/104

    2: Application Layer 7

    Client-server paradigm

    Typical network app has twopieces: clientand serverapplicationtransportnetworkdata linkphysical

    applicationtransport

    networkdata linkphysical

    Client: initiates contact with server

    (speaks first) typically requests service from

    server,

    Web: client implemented inbrowser; e-mail: in mail reader

    request

    reply

    Server: provides requested service to client

    e.g., Web server sends requested Webpage, mail server delivers e-mail

  • 7/31/2019 Application Layer (Computer Network)

    8/104

    2: Application Layer 8

    Processes communicating across network

    process sends/receivesmessages to/from itssocket

    socket analogous to door sending process shoves

    message out door

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

    controlledby OS

    process

    TCP with

    buffers,

    variables

    socket

    host orserver

    process

    TCP with

    buffers,

    variables

    socket

    host orserver

    Internet

    controlled by

    app developer

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

  • 7/31/2019 Application Layer (Computer Network)

    9/104

    2: Application Layer 9

    Addressing processes:

    For a process toreceive messages, itmust have an identifier

    Every host has a unique32-bit IP address

    Q: does the IP addressof the host on whichthe process runssuffice for identifying

    the process? Answer: No, many

    processes can berunning on same host

    Identifier includesboth the IP addressand port numbersassociated with theprocess on the host.

    Example port numbers: HTTP server: 80

    Mail server: 25

    More on this later

  • 7/31/2019 Application Layer (Computer Network)

    10/104

    2: Application Layer 10

    What transport service does an app need?

    Data loss some apps (e.g., audio) can

    tolerate some loss other apps (e.g., file

    transfer, telnet) require100% reliable datatransfer

    Timing some apps (e.g.,

    Internet telephony,interactive games)require low delay to beeffective

    Bandwidth some apps (e.g.,

    multimedia) requireminimum amount of

    bandwidth to beeffective

    other apps (elasticapps) make use of

    whatever bandwidththey get

  • 7/31/2019 Application Layer (Computer Network)

    11/104

    2: Application Layer 11

    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

    Bandwidth

    elastic

    elastic

    elasticaudio: 5kbps-1Mbps

    video:10kbps-5Mbps

    same as above

    few kbps up

    elastic

    Time Sensitive

    no

    no

    noyes, 100s msec

    yes, few secs

    yes, 100s msec

    yes and no

  • 7/31/2019 Application Layer (Computer Network)

    12/104

    2: Application Layer 12

    Internet transport protocols services

    TCP service: connection-oriented:setup

    required between client andserver processes

    reliable transportbetweensending and receiving process

    flow control:sender wontoverwhelm receiver

    congestion control:throttle

    sender when networkoverloaded

    does not providing:timing,minimum bandwidthguarantees

    UDP service: unreliable data transfer

    between sending andreceiving process

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

    Q: why bother? Why isthere a UDP?

  • 7/31/2019 Application Layer (Computer Network)

    13/104

  • 7/31/2019 Application Layer (Computer Network)

    14/104

    2: Application Layer 14

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP 2.4 Electronic Mail

    SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

  • 7/31/2019 Application Layer (Computer Network)

    15/104

    2: Application Layer 15

    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

  • 7/31/2019 Application Layer (Computer Network)

    16/104

    2: Application Layer 16

    HTTP overview

    HTTP: hypertexttransfer protocol

    Webs application layerprotocol

    client/server model client:browser that

    requests, receives,displays Web objects

    server:Web server

    sends objects inresponse to requests

    HTTP 1.0: RFC 1945

    HTTP 1.1: RFC 2068

    PC runningExplorer

    Serverrunning

    Apache Web

    server

    Mac runningNavigator

  • 7/31/2019 Application Layer (Computer Network)

    17/104

    2: Application Layer 17

    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 maintainstate are complex!

    past history (state) mustbe maintained

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

    aside

  • 7/31/2019 Application Layer (Computer Network)

    18/104

    2: Application Layer 18

    HTTP connections

    Nonpersistent HTTP

    At most one object issent over a TCPconnection.

    HTTP/1.0 usesnonpersistent HTTP

    Persistent HTTP

    Multiple objects canbe sent over singleTCP connectionbetween client andserver.

    HTTP/1.1 usespersistent connections

    in default mode

  • 7/31/2019 Application Layer (Computer Network)

    19/104

    2: Application Layer 19

    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 responsemessagecontaining requestedobject, and sends messageinto its socket

    time

    (contains text,

    references to 10

    jpeg images)

  • 7/31/2019 Application Layer (Computer Network)

    20/104

    2: Application Layer 20

    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

  • 7/31/2019 Application Layer (Computer Network)

    21/104

    2: Application Layer 21

    Response time modeling

    Definition of RTT: time tosend a small packet totravel from client toserver and back.

    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 to

    transmit

    file

    initiate TCP

    connection

    RTT

    request

    file

    RTT

    file

    received

    time time

    Repeatedfor each

    file in

    Non-

    persistent

    HTTP

  • 7/31/2019 Application Layer (Computer Network)

    22/104

    2: Application Layer 22

    Persistent HTTP

    Nonpersistent HTTP issues: requires 2 RTTs per object

    OS must work and allocatehost resources for each TCPconnection

    but browsers often openparallel TCP connections tofetch referenced objects

    Persistent HTTP

    server leaves connectionopen after sending response

    subsequent HTTP messagesbetween same client/serverare sent over connection

    Persistent without pipelining: client issues new request

    only when previousresponse has been received

    one RTT for each

    referenced objectPersistent with pipelining:

    default in HTTP/1.1

    client sends requests assoon as it encounters areferenced object

    as little as one RTT for allthe referenced objects

  • 7/31/2019 Application Layer (Computer Network)

    23/104

    2: Application Layer 23

    Persistent with(out) pipelining

    time to

    transmit

    file

    initiate TCP

    connection

    RTT

    request

    main file

    RTT

    Main file

    received

    time time

    Request and

    receive image

    files

    time to

    transmit

    file

    initiate TCP

    connection

    RTT

    request

    main file

    RTT

    Main file

    received

    time time

    Request and

    receive image

    files

    Without pipelining: With pipelining:

  • 7/31/2019 Application Layer (Computer Network)

    24/104

    2: Application Layer 24

    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

  • 7/31/2019 Application Layer (Computer Network)

    25/104

    2: Application Layer 25

    HTTP request message: general format

  • 7/31/2019 Application Layer (Computer Network)

    26/104

    2: Application Layer 26

    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

  • 7/31/2019 Application Layer (Computer Network)

    27/104

    2: Application Layer 27

    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 entitybody to path specifiedin URL field

    DELETE deletes file specified in

    the URL field

  • 7/31/2019 Application Layer (Computer Network)

    28/104

    2: Application Layer 28

    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

  • 7/31/2019 Application Layer (Computer Network)

    29/104

    2: Application Layer 29

    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:

  • 7/31/2019 Application Layer (Computer Network)

    30/104

    2: Application Layer 30

    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 www.eurecom.fr.Anything typed in sent

    to port 80 at www.eurecom.fr

    telnet www.eurecom.fr 80

    2. Type in a GET HTTP request:

    GET /~ross/index.html HTTP/1.0 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!

  • 7/31/2019 Application Layer (Computer Network)

    31/104

    2: Application Layer 31

    User-server interaction: authorization

    Authorization : control access toserver content

    authorization credentials:typically name, password

    stateless: client must present

    authorization in eachrequest authorization: header line in

    each request

    if no authorization: header,server refuses access,

    sendsWWW authenticate:

    header line in response

    client serverusual http request msg

    401: authorization req.WWW authenticate:

    usual http request msg+ Authorization:

    usual http response msg

    usual http request msg+ Authorization:

    usual http response msg time

  • 7/31/2019 Application Layer (Computer Network)

    32/104

    2: Application Layer 32

    Cookies

    Many major Web sitesuse cookies

    Four components:1) cookie header line in

    the HTTP responsemessage

    2) cookie header line inHTTP request message

    3) cookie file kept onusers host and managedby users browser

    4) back-end database atWeb site

    Example: Susan access Internet

    always from same PC

    She visits a specific e-

    commerce site for firsttime

    When initial HTTPrequests arrives at site,site creates a unique ID

    and creates an entry inbackend database forID

    Stateless State-full!

  • 7/31/2019 Application Layer (Computer Network)

    33/104

    2: Application Layer 33

    Cookies: keeping state (cont.)

    client serverusual http request msg

    usual http response +Set-cookie: 1678

    usual http request msgcookie: 1678

    usual http response msg

    usual http request msgcookie: 1678

    usual http response msg

    cookie-specificaction

    cookie-spectific

    action

    servercreates ID

    1678 for user

    Cookie file

    amazon: 1678

    ebay: 8734

    Cookie file

    ebay: 8734

    Cookie file

    amazon: 1678

    ebay: 8734

    one week later:

  • 7/31/2019 Application Layer (Computer Network)

    34/104

    2: Application Layer 34

    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 search engines use

    redirection & cookiesto learn yet more

    advertising companiesobtain info acrosssites

    aside

  • 7/31/2019 Application Layer (Computer Network)

    35/104

    2: Application Layer 35

    Conditional GET: client-side caching

    Goal:dont send object ifclient has up-to-date cachedversion

    client: stores object locally,alo

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

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

    client serverHTTP request msgIf-modified-since:

    HTTP responseHTTP/1.0

    304 Not Modified

    objectnot

    modified

    HTTP request msg

    If-modified-since:

    HTTP responseHTTP/1.0 200 OK

    objectmodified

  • 7/31/2019 Application Layer (Computer Network)

    36/104

    2: Application Layer 36

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP

    2.4 Electronic Mail SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

  • 7/31/2019 Application Layer (Computer Network)

    37/104

    2: Application Layer 37

    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

    file transferFTP

    server

    FTPuser

    interface

    FTPclient

    local file

    system

    remote file

    system

    userat host

  • 7/31/2019 Application Layer (Computer Network)

    38/104

    2: Application Layer 38

    FTP: separate control, data connections

    FTP client contacts FTPserver at port 21, specifyingTCP as transport protocol

    Client obtains authorizationover control connection

    Client browses remotedirectory by sendingcommands over controlconnection.

    When server receives acommand for a file transfer,the server opens a TCP dataconnection to client

    After transferring one file,server closes connection.

    FTPclient

    FTPserver

    TCP control connectionport 21

    TCP data connectionport 20

    Server opens a second TCPdata connection to transferanother file.

    Control connection: out of

    band FTP server maintains state:

    current directory, earlierauthentication

  • 7/31/2019 Application Layer (Computer Network)

    39/104

    2: Application Layer 39

    FTP commands, responses

    Sample commands: sent as ASCII text over

    control channel

    USERusername

    PASS password LISTreturn list of file in

    current directory

    RETR filenameretrieves

    (gets) file STOR filenamestores

    (puts) file onto remotehost

    Sample return codes status code and phrase (as

    in HTTP) 331 Username OK,

    password required 125 data connection

    already open;

    transfer starting

    425 Cant open data

    connection 452 Error writing

    file

  • 7/31/2019 Application Layer (Computer Network)

    40/104

    2: Application Layer 40

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP

    2.4 Electronic Mail SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

  • 7/31/2019 Application Layer (Computer Network)

    41/104

    2: Application Layer 41

    Electronic Mail

    Three major components: user agents

    mail servers

    simple mail transfer

    protocol: SMTP

    User Agent

    a.k.a. mail reader

    composing, editing, reading

    mail messages e.g., Eudora, Outlook, elm,

    Netscape Messenger

    outgoing, incoming messagesstored on server

    user mailbox

    outgoingmessage queue

    mail

    server

    useragent

    useragent

    useragent

    mailserver

    useragent

    useragent

    mailserver

    useragent

    SMTP

    SMTP

    SMTP

  • 7/31/2019 Application Layer (Computer Network)

    42/104

    2: Application Layer 42

    Electronic Mail: mail servers

    Mail Servers mailbox contains incoming

    messages for user

    messagequeue of outgoing

    (to be sent) mail messages SMTP protocol between mail

    servers to send emailmessages

    client: sending mail

    server server: receiving mail

    server

    mailserver

    useragent

    useragent

    useragent

    mail

    server

    useragent

    useragent

    mailserver

    useragent

    SMTP

    SMTP

    SMTP

  • 7/31/2019 Application Layer (Computer Network)

    43/104

    2: Application Layer 43

    Electronic Mail: SMTP [RFC 2821]

    uses TCP to reliably transfer email message from clientto server, port 25

    direct transfer: sending server to receiving server

    three phases of transfer

    handshaking (greeting) transfer of messages

    closure

    command/response interaction

    commands: ASCII text

    response: status code and phrase

    messages must be in 7-bit ASCII

  • 7/31/2019 Application Layer (Computer Network)

    44/104

    2: Application Layer 44

    Scenario: Alice sends message to Bob

    1) Alice uses UA to compose

    message and [email protected]

    2) Alices UA sends messageto her mail server; messageplaced in message queue

    3) Client side of SMTP opensTCP connection with Bobsmail server

    4) SMTP client sends Alices

    message over the TCPconnection

    5) Bobs mail server places themessage in Bobs mailbox

    6) Bob invokes his user agent

    to read message

    useragent

    mailserver

    mailserver user

    agent

    1

    2 3 4 56

  • 7/31/2019 Application Layer (Computer Network)

    45/104

  • 7/31/2019 Application Layer (Computer Network)

    46/104

    2: Application Layer 46

    Try SMTP interaction for yourself:

    telnet servername 25

    see 220 reply from server

    enter HELO, MAIL FROM, RCPT TO, DATA, QUIT

    commandsabove lets you send email without using email client(reader)

  • 7/31/2019 Application Layer (Computer Network)

    47/104

    2: Application Layer 47

    SMTP: final words

    SMTP uses persistentconnections

    SMTP requires message(header & body) to be in 7-bit ASCII

    SMTP server usesCRLF.CRLF to determineend of message

    Comparison with HTTP:

    HTTP: pull

    SMTP: push

    both have ASCIIcommand/responseinteraction, status codes

    HTTP: each objectencapsulated in its own

    response msg SMTP: multiple objects

    sent in multipart msg

  • 7/31/2019 Application Layer (Computer Network)

    48/104

    2: Application Layer 48

    Mail message format

    SMTP: protocol forexchanging email msgs

    RFC 822: standard for textmessage format:

    header lines, e.g., To:

    From:

    Subject:

    differentfrom SMTPcommands!

    body the message, ASCII

    characters only

    header

    body

    blankline

  • 7/31/2019 Application Layer (Computer Network)

    49/104

    2: Application Layer 49

    Message format: multimedia extensions

    MIME: multimedia mail extension, RFC 2045, 2056 additional lines in msg header declare MIME content

    type

    From: [email protected]

    To: [email protected]: Picture of yummy crepe.

    MIME-Version: 1.0

    Content-Transfer-Encoding: base64

    Content-Type: image/jpeg

    base64 encoded data ..............................

    ......base64 encoded data

    multimedia data

    type, subtype,parameter declaration

    method usedto encode data

    MIME version

    encoded data

  • 7/31/2019 Application Layer (Computer Network)

    50/104

    2: Application Layer 50

    MIME typesContent-Type: type/subtype; parameters

    Text example subtypes:plain,

    html

    Image example subtypes: jpeg,gif

    Audio

    example subtypes:basic(8-bit mu-law encoded),32kadpcm(32 kbpscoding)

    Video example subtypes:mpeg,

    quicktime

    Application other data that must be

    processed by readerbefore viewable

    example subtypes:msword, octet-stream

  • 7/31/2019 Application Layer (Computer Network)

    51/104

    2: Application Layer 51

    Multipart Type

    From: [email protected]

    To: [email protected]: Picture of yummy crepe.

    MIME-Version: 1.0

    Content-Type: multipart/mixed; boundary=StartOfNextPart

    --StartOfNextPart

    Dear Bob, Please find a picture of a crepe.

    --StartOfNextPart

    Content-Transfer-Encoding: base64

    Content-Type: image/jpeg

    base64 encoded data .....

    .........................

    ......base64 encoded data

    --StartOfNextPartDo you want the recipe?

  • 7/31/2019 Application Layer (Computer Network)

    52/104

    2: Application Layer 52

    Mail access protocols

    SMTP: delivery/storage to receivers server

    Mail access protocol: retrieval from server

    POP: Post Office Protocol [RFC 1939]

    authorization (agent server) and download

    IMAP: Internet Mail Access Protocol [RFC 1730] more features (more complex)

    manipulation of stored msgs on server

    HTTP: Hotmail , Yahoo! Mail, etc.

    useragent

    senders mailserver

    useragent

    SMTP SMTP accessprotocol

    receivers mailserver

  • 7/31/2019 Application Layer (Computer Network)

    53/104

    2: Application Layer 53

    POP3 protocol

    authorization phase client commands:

    user: declare username

    pass: password

    server responses +OK

    -ERR

    transaction phase, client: list: list message numbers

    retr: retrieve message bynumber

    dele: delete

    quit

    C: list

    S: 1 498

    S: 2 912

    S: .

    C: retr 1

    S:

    S: .

    C: dele 1

    C: retr 2

    S:

    S: .

    C: dele 2

    C: quit

    S: +OKPOP3 server signing off

    S: +OK POP3 server ready

    C: user bob

    S: +OKC: pass hungry

    S: +OKuser successfully logged on

  • 7/31/2019 Application Layer (Computer Network)

    54/104

    2: Application Layer 54

    POP3 (more) and IMAP

    More about POP3 Previous example uses

    download and deletemode.

    Bob cannot re-read e-mail if he changesclient

    Download-and-keep:copies of messages ondifferent clients

    POP3 is statelessacross sessions

    IMAP Keep all messages in

    one place: the server

    Allows user to

    organize messages infolders

    IMAP keeps user stateacross sessions:

    names of folders andmappings betweenmessage IDs and foldername

  • 7/31/2019 Application Layer (Computer Network)

    55/104

    2: Application Layer 55

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP

    2.4 Electronic Mail SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

  • 7/31/2019 Application Layer (Computer Network)

    56/104

    2: Application Layer 56

    DNS: Domain Name System

    People: many identifiers: SSN, name, passport #

    Internet hosts, routers: IP address (32 bit) -

    used for addressingdatagrams

    name, e.g.,gaia.cs.umass.edu - usedby humans

    Q: map between IPaddresses and name ?

    Domain Name System: distributed database

    implemented in hierarchy ofmany name servers

    application-layer protocolhost, routers, name servers tocommunicate to resolvenames(address/name translation)

    note: core Internet

    function, implemented asapplication-layer protocol

    complexity at networksedge

  • 7/31/2019 Application Layer (Computer Network)

    57/104

    2: Application Layer 57

    DNS name servers

    no server has all name-to-IP address mappings

    local name servers: each ISP, company has

    local (default) name server host DNS query first goes

    to local name server

    authoritative name server: for a host: stores that

    hosts IP address, name can perform name/address

    translation for that hostsname

    Why not centralize DNS? single point of failure

    traffic volume

    distant centralizeddatabase

    maintenance

    doesntscale!

  • 7/31/2019 Application Layer (Computer Network)

    58/104

    2: Application Layer 58

    DNS: Root name servers

    contacted by local name server that can not resolve name root name server:

    contacts authoritative name server if name mapping not known

    gets mapping

    returns mapping to local name server

    b USC-ISI Marina del Rey, CA

    l ICANN Marina del Rey, CA

    e NASA Mt View, CA

    f Internet Software C. Palo Alto,CA

    i NORDUnet Stockholm

    k RIPE London

    m WIDE Tokyo

    a NSI Herndon, VA

    c PSInet Herndon, VA

    d U Maryland College Park, MD

    g DISA Vienna, VA

    h ARL Aberdeen, MDj NSI (TBD) Herndon, VA

    13 root nameservers worldwide

  • 7/31/2019 Application Layer (Computer Network)

    59/104

    2: Application Layer 59

    Simple DNS example

    host surf.eurecom.frwants IP address ofgaia.cs.umass.edu

    1. contacts its local DNS

    server, dns.eurecom.fr2.dns.eurecom.fr contacts

    root name server, ifnecessary

    3. root name server contacts

    authoritative name server,dns.umass.edu, ifnecessary requesting host

    surf.eurecom.frgaia.cs.umass.edu

    root name server

    authorititive name serverdns.umass.edu

    local name serverdns.eurecom.fr

    1

    23

    4

    5

    6

  • 7/31/2019 Application Layer (Computer Network)

    60/104

    2: Application Layer 60

    DNS example

    Root name server: may not know

    authoritative nameserver

    may know

    intermediate nameserver:who tocontact to findauthoritative nameserver

    requesting hostsurf.eurecom.fr

    gaia.cs.umass.edu

    root name server

    local name serverdns.eurecom.fr

    1

    23

    4 5

    6

    authoritative name serverdns.cs.umass.edu

    intermediate name serverdns.umass.edu

    7

    8

  • 7/31/2019 Application Layer (Computer Network)

    61/104

    2: Application Layer 61

    DNS: iterated queries

    recursive query: puts burden of name

    resolution oncontacted nameserver

    heavy load?

    iterated query: contacted server

    replies with name of

    server to contact I dont know this

    name, but ask thisserver

    requesting hostsurf.eurecom.fr

    gaia.cs.umass.edu

    root name server

    local name serverdns.eurecom.fr

    1

    23

    4

    5 6

    authoritative name serverdns.cs.umass.edu

    intermediate name serverdns.umass.edu

    7

    8

    iterated query

  • 7/31/2019 Application Layer (Computer Network)

    62/104

    2: Application Layer 62

    DNS: caching and updating records

    once (any) name server learns mapping, it cachesmapping

    cache entries timeout (disappear) after sometime

    update/notify mechanisms under design by IETF RFC 2136 http://www.ietf.org/html.charters/dnsind-charter.html

  • 7/31/2019 Application Layer (Computer Network)

    63/104

    2: Application Layer 63

    DNS records

    DNS: distributed db storing resource records (RR)

    Type=NS name is domain (e.g.

    foo.com) value is IP address of

    authoritative nameserver for this domain

    RR format: (name, value, type,ttl)

    Type=A

    name is hostname value is IP address

    Type=CNAME

    name is alias name for somecanonical (the real) name

    www.ibm.com is reallyservereast.backup2.ibm.com

    value is canonical name

    Type=MX value is name of mailserver

    associated with name

  • 7/31/2019 Application Layer (Computer Network)

    64/104

    2: Application Layer 64

    DNS protocol, messages

    DNS protocol :queryand replymessages, both withsame message format

    msg header identification: 16 bit #

    for query, reply to queryuses same #

    flags:

    query or reply

    recursion desired

    recursion available

    reply is authoritative

  • 7/31/2019 Application Layer (Computer Network)

    65/104

    2: Application Layer 65

    DNS protocol, messages

    Name, type fieldsfor a query

    RRs in response

    to query

    records forauthoritative servers

    additional helpfulinfo that may be used

  • 7/31/2019 Application Layer (Computer Network)

    66/104

    2: Application Layer 66

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP

    2.4 Electronic Mail SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

    S k t i

  • 7/31/2019 Application Layer (Computer Network)

    67/104

    2: Application Layer 67

    Socket programming

    Socket API introduced in BSD4.1 UNIX,

    1981 explicitly created, used,

    released by apps

    client/server paradigm

    two types of transport

    service via socket API: unreliable datagram

    reliable, byte stream-oriented

    a host-local,

    application-created,OS-controlledinterface

    (a door) into whichapplication process can

    both send and

    receive messages to/fromanother applicationprocess

    socket

    Goal: learn how to build client/server application thatcommunicate using sockets

  • 7/31/2019 Application Layer (Computer Network)

    68/104

    2: Application Layer 68

    Socket-programming using TCP

    Socket: a door between application process and end-end-transport protocol (UCP or TCP)

    TCP service: reliable transfer of bytesfrom oneprocess to another

    process

    TCP with

    buffers,variables

    socket

    controlled byapplicationdeveloper

    controlled by

    operatingsystem

    host orserver

    process

    TCP with

    buffers,variables

    socket

    controlled byapplicationdeveloper

    controlled by

    operatingsystem

    host orserver

    internet

  • 7/31/2019 Application Layer (Computer Network)

    69/104

    2: Application Layer 69

    Socket programming with TCP

    Client must contact server

    server process must firstbe running

    server must have createdsocket (door) that

    welcomes clients contactClient contacts server by:

    creating client-local TCPsocket

    specifying IP address, port

    number of server process When client creates

    socket: client TCPestablishes connection toserver TCP

    When contacted by client,server TCP creates newsocket for server process tocommunicate with client

    allows server to talk withmultiple clients

    source port numbersused to distinguishclients (more in Chap 3)

    TCP provides reliable, in-ordertransfer of bytes (pipe)between client and server

    application viewpoint

  • 7/31/2019 Application Layer (Computer Network)

    70/104

    2: Application Layer 70

    Stream jargon

    A stream is a sequence ofcharacters that flow intoor out of a process.

    An input stream isattached to some input

    source for the process, eg,keyboard or socket.

    An output stream isattached to an outputsource, eg, monitor or

    socket.

  • 7/31/2019 Application Layer (Computer Network)

    71/104

    2: Application Layer 71

    Socket programming with TCP

    Example client-server app:1) client reads line from

    standard input (inFromUserstream) , sends to server viasocket (outToServer

    stream)2) server reads line from socket

    3) server converts line touppercase, sends back toclient

    4) client reads, prints modifiedline from socket(inFromServer stream)

    o

    utToServer

    to network from network

    inFromServer

    inFromUser

    keyboard monitor

    Process

    clientSocket

    input

    stream

    input

    stream

    output

    stream

    TCP

    socket

    Client

    process

    client TCPsocket

  • 7/31/2019 Application Layer (Computer Network)

    72/104

    2: Application Layer 72

    Client/server socket interaction: TCP

    wait for incomingconnection requestconnectionSocket =

    welcomeSocket.accept()

    create socket,port=x, for

    incoming request:welcomeSocket =

    ServerSocket()

    create socket,connect to hostid, port=xclientSocket =

    Socket()

    close

    connectionSocket

    read reply from

    clientSocket

    close

    clientSocket

    Server (running on hostid)Client

    send request using

    clientSocketread request from

    connectionSocket

    write reply to

    connectionSocket

    TCPconnection setup

    E l l ( P)

  • 7/31/2019 Application Layer (Computer Network)

    73/104

    2: Application Layer 73

    Example: Java client (TCP)

    import java.io.*;import java.net.*;

    class TCPClient {

    public static void main(String argv[]) throws Exception

    {

    String sentence;String modifiedSentence;

    BufferedReader inFromUser =

    new BufferedReader(new InputStreamReader(System.in));

    Socket clientSocket = new Socket("hostname", 6789);

    DataOutputStream outToServer =

    new DataOutputStream(clientSocket.getOutputStream());

    Createinput stream

    Create

    client socket,connect to server

    Createoutput stream

    attached to socket

    E l l ( P)

  • 7/31/2019 Application Layer (Computer Network)

    74/104

    2: Application Layer 74

    Example: Java client (TCP), cont.

    BufferedReader inFromServer =

    new BufferedReader(new

    InputStreamReader(clientSocket.getInputStream()));

    sentence = inFromUser.readLine();

    outToServer.writeBytes(sentence + '\n');

    modifiedSentence = inFromServer.readLine();

    System.out.println("FROM SERVER: " + modifiedSentence);

    clientSocket.close();

    }

    }

    Createinput stream

    attached to socket

    Send lineto server

    Read linefrom server

    E l J (TCP)

  • 7/31/2019 Application Layer (Computer Network)

    75/104

    2: Application Layer 75

    Example: Java server (TCP)import java.io.*;

    import java.net.*;

    class TCPServer {

    public static void main(String argv[]) throws Exception

    {

    String clientSentence;

    String capitalizedSentence;

    ServerSocket welcomeSocket = new ServerSocket(6789);

    while(true) {

    Socket connectionSocket = welcomeSocket.accept();

    BufferedReader inFromClient =

    new BufferedReader(new

    InputStreamReader(connectionSocket.getInputStream()));

    Createwelcoming socket

    at port 6789

    Wait, on welcomingsocket for contact

    by client

    Create inputstream, attached

    to socket

    E l J (TCP)

  • 7/31/2019 Application Layer (Computer Network)

    76/104

    2: Application Layer 76

    Example: Java server (TCP), cont

    DataOutputStream outToClient =

    new DataOutputStream(connectionSocket.getOutputStream());

    clientSentence = inFromClient.readLine();

    capitalizedSentence = clientSentence.toUpperCase() + '\n';

    outToClient.writeBytes(capitalizedSentence);

    }

    }

    }

    Read in line

    from socket

    Create outputstream, attached

    to socket

    Write out lineto socket

    End of while loop,loop back and wait foranother client connection

    Ch t 2 tli

  • 7/31/2019 Application Layer (Computer Network)

    77/104

    2: Application Layer 77

    Chapter 2 outline

    2.1 Principles of applayer protocols clients and servers

    app requirements

    2.2 Web and HTTP 2.3 FTP

    2.4 Electronic Mail SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9 Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

    S k t i ith UDP

  • 7/31/2019 Application Layer (Computer Network)

    78/104

    2: Application Layer 78

    Socket programming with UDP

    UDP: no connection betweenclient and server

    no handshaking

    sender explicitly attachesIP address and port ofdestination to each packet

    server must extract IPaddress, port of senderfrom received packet

    UDP: transmitted data may bereceived out of order, orlost

    application viewpoint

    UDP provides unreliable transferof groups of bytes (datagrams)

    between client and server

    Cli / k i i UDP

  • 7/31/2019 Application Layer (Computer Network)

    79/104

    2: Application Layer 79

    Client/server socket interaction: UDP

    close

    clientSocket

    Server (running on hostid)

    read reply fromclientSocket

    create socket,

    clientSocket =

    DatagramSocket()

    Client

    Create, address (hostid, port=x,send datagram request

    using clientSocket

    create socket,port=x, for

    incoming request:serverSocket =

    DatagramSocket()

    read request from

    serverSocket

    write reply to

    serverSocket

    specifying clienthost address,

    port number

    E l J li t (UDP)

  • 7/31/2019 Application Layer (Computer Network)

    80/104

    2: Application Layer 80

    Example: Java client (UDP)

    sendPacket

    to network from network

    receivePacket

    inFromUser

    keyboard monitor

    Process

    clientSocket

    UDP

    packet

    input

    stream

    UDP

    packet

    UDP

    socket

    Output: sendspacket (TCP sentbyte stream)

    Input: receivespacket (TCPreceived bytestream)

    Client

    process

    client UDPsocket

    E l J li t (UDP)

  • 7/31/2019 Application Layer (Computer Network)

    81/104

    2: Application Layer 81

    Example: Java client (UDP)

    import java.io.*;import java.net.*;

    class UDPClient {

    public static void main(String args[]) throws Exception

    {

    BufferedReader inFromUser =

    new BufferedReader(new InputStreamReader(System.in));

    DatagramSocket clientSocket = new DatagramSocket();

    InetAddress IPAddress = InetAddress.getByName("hostname");

    byte[] sendData = new byte[1024];

    byte[] receiveData = new byte[1024];

    String sentence = inFromUser.readLine();

    sendData = sentence.getBytes();

    Create

    input stream

    Createclient socket

    Translatehostname to IP

    address using DNS

    E l J li t (UDP) t

  • 7/31/2019 Application Layer (Computer Network)

    82/104

    2: Application Layer 82

    Example: Java client (UDP), cont.

    DatagramPacket sendPacket =

    new DatagramPacket(sendData, sendData.length, IPAddress, 9876);

    clientSocket.send(sendPacket);

    DatagramPacket receivePacket =

    new DatagramPacket(receiveData, receiveData.length);

    clientSocket.receive(receivePacket);

    String modifiedSentence =

    new String(receivePacket.getData());

    System.out.println("FROM SERVER:" + modifiedSentence);

    clientSocket.close();

    }

    }

    Create datagramwith data-to-send,length, IP addr, port

    Send datagramto server

    Read datagramfrom server

    E l J (UDP)

  • 7/31/2019 Application Layer (Computer Network)

    83/104

    2: Application Layer 83

    Example: Java server (UDP)

    import java.io.*;import java.net.*;

    class UDPServer {

    public static void main(String args[]) throws Exception

    {

    DatagramSocket serverSocket = new DatagramSocket(9876);

    byte[] receiveData = new byte[1024];

    byte[] sendData = new byte[1024];

    while(true)

    {

    DatagramPacket receivePacket =

    new DatagramPacket(receiveData, receiveData.length);

    serverSocket.receive(receivePacket);

    Create

    datagram socketat port 9876

    Create space forreceived datagram

    Receivedatagram

    E l J (UDP) t

  • 7/31/2019 Application Layer (Computer Network)

    84/104

    2: Application Layer 84

    Example: Java server (UDP), cont

    String sentence = new String(receivePacket.getData());

    InetAddress IPAddress = receivePacket.getAddress();

    int port = receivePacket.getPort();

    String capitalizedSentence = sentence.toUpperCase();

    sendData = capitalizedSentence.getBytes();

    DatagramPacket sendPacket =

    new DatagramPacket(sendData, sendData.length, IPAddress,

    port);

    serverSocket.send(sendPacket);}

    }

    }

    Get IP addrport #, of

    sender

    Write out

    datagramto socket

    End of while loop,loop back and wait foranother datagram

    Create datagramto send to client

    B ildin simpl W b s

  • 7/31/2019 Application Layer (Computer Network)

    85/104

    2: Application Layer 85

    Building a simple Web server

    handles one HTTPrequest

    accepts the request

    parses header

    obtains requested filefrom servers filesystem

    creates HTTP response

    message: header lines + file

    sends response to client

    after creating server,you can request fileusing a browser (e.g.IE explorer)

    see text for details

    S k t p mmin : f n s

  • 7/31/2019 Application Layer (Computer Network)

    86/104

    2: Application Layer 86

    Socket programming: references

    C-language tutorial (audio/slides): Unix Network Programming (J. Kurose),

    http://manic.cs.umass.edu/~amldemo/courseware/intro.

    Java-tutorials: All About Sockets (Sun tutorial),

    http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html

    Socket Programming in Java: a tutorial,http://www.javaworld.com/javaworld/jw-12-1996/jw-12-sockets.html

    Chapter 2 outline

  • 7/31/2019 Application Layer (Computer Network)

    87/104

    2: Application Layer 87

    Chapter 2 outline

    2.1 Principles of applayer protocols

    2.2 Web and HTTP

    2.3 FTP

    2.4 Electronic Mail SMTP, POP3, IMAP

    2.5 DNS

    2.6 Socket programmingwith TCP

    2.7 Socket programmingwith UDP

    2.8 Building a Webserver

    2.9Content distribution Network Web caching

    Content distributionnetworks

    P2P file sharing

    Web caches (proxy server)

  • 7/31/2019 Application Layer (Computer Network)

    88/104

    2: Application Layer 88

    Web caches (proxy server)

    user sets browser: Webaccesses via cache

    browser sends all HTTP

    requests to cache object in cache: cache

    returns object

    else cache requestsobject from originserver, then returns

    object to client

    Goal: satisfy client request without involving origin server

    client

    Proxy

    server

    clientoriginserver

    originserver

    More about Web caching

  • 7/31/2019 Application Layer (Computer Network)

    89/104

    2: Application Layer 89

    More about Web caching

    Cache acts as both clientand server

    Cache can do up-to-datecheck using If-modified-since HTTP header

    Issue: should cache takerisk and deliver cachedobject without checking?

    Heuristics are used.

    Typically cache is installed

    by ISP (university,company, residential ISP)

    Why Web caching? Reduce response time for

    client request.

    Reduce traffic on aninstitutions access link.

    Internet dense with cachesenables poor contentproviders to effectivelydeliver content

    Caching example (1)

  • 7/31/2019 Application Layer (Computer Network)

    90/104

    2: Application Layer 90

    Caching example (1)

    Assumptions

    average object size = 100,000bits

    avg. request rate frominstitutions browser to originserves = 15/sec

    delay from institutional routerto any origin server and backto router = 2 sec

    Consequences

    utilization on LAN = 15% utilization on access link = 100%

    total delay = Internet delay +access delay + LAN delay

    = 2 sec + minutes + milliseconds

    origin

    serverspublic

    Internet

    institutionalnetwork 10 Mbps LAN

    1.5 Mbpsaccess link

    institutionalcache

    Caching example (2)

  • 7/31/2019 Application Layer (Computer Network)

    91/104

    2: Application Layer 91

    Caching example (2)

    Possible solution

    increase bandwidth of accesslink to, say, 10 Mbps

    Consequences 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

    origin

    serverspublic

    Internet

    institutionalnetwork 10 Mbps LAN

    10 Mbpsaccess link

    institutionalcache

    Caching example (3)

  • 7/31/2019 Application Layer (Computer Network)

    92/104

    2: Application Layer 92

    Caching example (3)

    Install cache suppose hit rate is .4

    Consequence 40% requests will be satisfied

    almost immediately

    60% requests satisfied byorigin server

    utilization of access linkreduced to 60%, resulting innegligible delays (say 10 msec)

    total delay = Internet delay +access delay + LAN delay

    = .6*2 sec + .6*.01 secs +milliseconds < 1.3 secs

    origin

    serverspublic

    Internet

    institutionalnetwork 10 Mbps LAN

    1.5 Mbpsaccess link

    institutionalcache

    Content distribution networks (CDNs)

  • 7/31/2019 Application Layer (Computer Network)

    93/104

    2: Application Layer 93

    Content distribution networks (CDNs)

    The content providers arethe CDN customers.

    Content replication

    CDN company installshundreds of CDN servers

    throughout Internet in lower-tier ISPs, close

    to users

    CDN replicates its customerscontent in CDN servers.When provider updatescontent, CDN updatesservers

    origin server

    in North America

    CDN distribution node

    CDN server

    in S. America CDN server

    in Europe

    CDN server

    in Asia

    CDN example HTTP request for

  • 7/31/2019 Application Layer (Computer Network)

    94/104

    2: Application Layer 94

    CDN example

    origin server

    www.foo.com

    distributes HTML Replaces:

    http://www.foo.com/sports.ruth.gif

    withhttp://www.cdn.com/www.foo.com/sports/ruth.gif

    q

    www.foo.com/sports/sports.html

    DNS query for www.cdn.com

    HTTP request for

    www.cdn.com/www.foo.com/sports/ruth.gif

    1

    2

    3

    Origin server

    CDNs authoritative

    DNS server

    Nearby

    CDN server

    CDN company

    cdn.com

    distributes gif files uses its authoritative

    DNS server to routeredirect requests

    More about CDNs

  • 7/31/2019 Application Layer (Computer Network)

    95/104

    2: Application Layer 95

    More about CDNs

    routing requests CDN creates a map,

    indicating distancesfrom leaf ISPs andCDN nodes

    when query arrives atauthoritative DNSserver: server determines ISP

    from which queryoriginates

    uses map to determinebest CDN server

    not just Web pages streaming stored

    audio/video

    streaming real-time

    audio/video CDN nodes create

    application-layeroverlay network

    P2P file sharing

  • 7/31/2019 Application Layer (Computer Network)

    96/104

    2: Application Layer 96

    P2P file sharing

    Example Alice runs P2P client

    application on hernotebook computer

    Intermittentlyconnects to Internet;gets new IP addressfor each connection

    Asks for Hey Jude Application displays

    other peers that havecopy of Hey Jude.

    Alice chooses one of

    the peers, Bob. File is copied from

    Bobs PC to Alicesnotebook: HTTP

    While Alice downloads,other users uploadingfrom Alice.

    Alices peer is both a

    Web client and atransient Web server.

    All peers are servers =highly scalable!

    P2P: centralized directory

  • 7/31/2019 Application Layer (Computer Network)

    97/104

    2: Application Layer 97

    P2P: centralized directory

    original Napster design1) when peer connects, it

    informs central server: IP address

    content2) Alice queries for Hey

    Jude

    3) Alice requests file from

    Bob

    centralizeddirectory server

    peers

    Alice

    Bob

    1

    1

    1

    12

    3

    P2P: problems with centralized directory

  • 7/31/2019 Application Layer (Computer Network)

    98/104

    2: Application Layer 98

    P2P: problems with centralized directory

    Single point of failure Performance

    bottleneck

    Copyright

    infringement

    file transfer isdecentralized, butlocating content ishighly decentralized

    P2P: decentralized directory

  • 7/31/2019 Application Layer (Computer Network)

    99/104

    2: Application Layer 99

    P2P: decentralized directory

    Each peer is either agroup leader orassigned to a groupleader.

    Group leader tracksthe content in all itschildren.

    Peer queries group

    leader; group leadermay query other groupleaders.

    ordinary peer

    group-leader peer

    neighoring relationships

    in overlay network

    More about decentralized directory

  • 7/31/2019 Application Layer (Computer Network)

    100/104

    2: Application Layer 100

    More about decentralized directory

    overlay network peers are nodes

    edges between peersand their group leaders

    edges between somepairs of group leaders

    virtual neighbors

    bootstrap node

    connecting peer iseither assigned to agroup leader ordesignated as leader

    advantages of approach no centralized directory

    server location service

    distributed over peers more difficult to shut

    down

    disadvantages of approach

    bootstrap node needed group leaders can get

    overloaded

    P2P: Query flooding

  • 7/31/2019 Application Layer (Computer Network)

    101/104

    2: Application Layer 101

    P2P: Query flooding

    Gnutella no hierarchy

    use bootstrap node tolearn about others

    join message

    Send query to neighbors Neighbors forward query

    If queried peer hasobject, it sends message

    back to querying peer

    join

    P2P: more on query flooding

  • 7/31/2019 Application Layer (Computer Network)

    102/104

    2: Application Layer 102

    P2P: more on query flooding

    Pros peers have similar

    responsibilities: nogroup leaders

    highly decentralized no peer maintains

    directory info

    Cons excessive query

    traffic

    query radius: may not

    have content whenpresent

    bootstrap node

    maintenance of overlay

    network

    Chapter 2: Summary

  • 7/31/2019 Application Layer (Computer Network)

    103/104

    2: Application Layer 103

    Chapter 2: Summary

    application servicerequirements: reliability, bandwidth,

    delay client-server paradigm

    Internet transportservice model

    connection-oriented,reliable: TCP

    unreliable, datagrams:UDP

    Our study of network apps now complete! specific protocols:

    HTTP

    FTP

    SMTP, POP, IMAP DNS

    socket programming

    content distribution caches, CDNs P2P

  • 7/31/2019 Application Layer (Computer Network)

    104/104