Ch02

Document Sample
Ch02 Powered By Docstoc
					Chapter 2: Application layer
 2.1 Principles of        2.6 P2P file sharing
  network applications     2.7 Socket programming
 2.2 Web and HTTP          with TCP
 2.3 FTP                  2.8 Socket programming
 2.4 Electronic Mail       with UDP
      SMTP, POP3, IMAP    2.9 Building a Web
 2.5 DNS                   server




                                         Application Layer   2-1
Chapter 2: Application Layer
Our goals:                 learn about protocols
 conceptual,               by examining popular
  implementation            application-level
  aspects of network        protocols
  application protocols         HTTP
    transport-layer            FTP
     service models             SMTP / POP3 / IMAP
                                 DNS
    client-server
                             

     paradigm              programming network
      peer-to-peer         applications
       paradigm                 socket API



                                              Application Layer   2-2
Some network apps
 E-mail                Internet telephone
 Web                   Real-time video
 Instant messaging      conference
 Remote login          Massive parallel
 P2P file sharing
                         computing
 Multi-user network
  games
 Streaming stored
  video clips



                                      Application Layer   2-3
Creating a network app
Write programs that                 application
                                    transport
      run on different end          network
                                     data link
       systems and                   physical

      communicate over a
       network.
      e.g., Web: Web server
       software communicates
       with browser software
little software written for
   devices in network core                    application
                                                                       application
                                                                       transport
      network core devices do                transport
                                               network
                                                                        network
                                                                        data link
       not run user application                data link
                                               physical
                                                                        physical

       code
      application on end systems
       allows for rapid app
       development, propagation
                                                            Application Layer        2-4
Chapter 2: Application layer

  2.1 Principles of network applications
  2.2 Web and HTTP
  2.3 FTP
  2.4 Electronic Mail
     SMTP, POP3, IMAP

  2.5 DNS
  2.6 P2P file sharing




                                            Application Layer   2-5
Application architectures
 Client-server
 Peer-to-peer (P2P)
 Hybrid of client-server and P2P




                                    Application Layer   2-6
Client-server architecture
                 server:
                       always-on host
                       permanent IP address
                       server farms for scaling
                 clients:
                       communicate with
                        server
                       may be intermittently
                        connected
                       may have dynamic IP
                        addresses
                       do not communicate
                        directly with each other



                                  Application Layer   2-7
Pure P2P architecture
 no always-on server
 arbitrary end systems
  directly communicate
 peers are intermittently
  connected and change IP
  addresses
 example: Gnutella


Highly scalable
But difficult to manage


                             Application Layer   2-8
Hybrid of client-server and P2P
Napster
   File transfer P2P
   File search centralized:
      • Peers register content at central server
      • Peers query same central server to locate content
Instant messaging
   Chatting between two users is P2P
   Presence detection/location centralized:
      • User registers its IP address with central server
        when it comes online
      • User contacts central server to find IP addresses of
        buddies

                                                 Application Layer   2-9
Processes communicating
Process: program running    Client process: process
  within a host.               that initiates
 within same host, two
                               communication
  processes communicate     Server process: process
  using inter-process          that waits to be
  communication (defined       contacted
  by OS).
 processes in different    Note: applications with
  hosts communicate by       P2P architectures have
  exchanging messages        client processes &
                             server processes


                                        Application Layer   2-10
  Sockets
 process sends/receives              host or                                   host or
  messages to/from its                server                                    server

  socket
                                                     controlled by
 socket analogous to door                           app developer
                                                                                process
                                      process
      sending process shoves
                                                                                socket
       message out door               socket
                                                                               TCP with
      sending process relies on     TCP with
                                     buffers,                 Internet         buffers,
       transport infrastructure      variables                                 variables
       on other side of door which
       brings message to socket                  controlled
       at receiving process                      by OS

 API: (1) choice of transport protocol; (2) ability to fix
  a few parameters (lots more on this later)
                                                                 Application Layer   2-11
Addressing processes
 For a process to           Identifier includes
  receive messages, it        both the IP address
  must have an identifier     and port numbers
 A host has a unique32-      associated with the
  bit IP address              process on the host.
 Q: does the IP address     Example port numbers:
  of the host on which            HTTP server: 80
  the process runs                Mail server: 25
  suffice for identifying    More on this later
  the process?
 Answer: No, many
  processes can be
  running on same host
                                            Application Layer   2-12
App-layer protocol defines
 Types of messages          Public-domain protocols:
  exchanged, e.g., request    defined in RFCs
  & response messages         allows for
 Syntax of message            interoperability
  types: what fields in       e.g., HTTP, SMTP
  messages & how fields
                             Proprietary protocols:
  are delineated
                              e.g., KaZaA
 Semantics of the fields,
  i.e., meaning of
  information in fields
 Rules for when and how
  processes send &
  respond to messages
                                          Application Layer   2-13
What transport service does an app need?
Data loss                       Bandwidth
 some apps (e.g., audio) can    some apps (e.g.,
  tolerate some loss              multimedia) require
 other apps (e.g., file          minimum amount of
  transfer, telnet) require       bandwidth to be
  100% reliable data
                                  “effective”
  transfer
                                 other apps (“elastic
Timing                            apps”) make use of
 some apps (e.g.,                whatever bandwidth
  Internet telephony,             they get
  interactive games)
  require low delay to be
  “effective”
                                           Application Layer   2-14
 Transport service requirements of common apps

         Application      Data loss       Bandwidth            Time Sensitive

          file transfer   no loss         elastic              no
                 e-mail   no loss         elastic              no
     Web documents        no loss         elastic              no
real-time audio/video     loss-tolerant   audio: 5kbps-1Mbps   yes, 100’s msec
                                          video:10kbps-5Mbps
  stored audio/video      loss-tolerant   same as above        yes, few secs
   interactive games      loss-tolerant   few kbps up          yes, 100’s msec
  instant messaging       no loss         elastic              yes and no




                                                          Application Layer   2-15
Internet transport protocols services
TCP service:                        UDP service:
   connection-oriented: setup       unreliable data transfer
    required between client and       between sending and
    server processes                  receiving process
   reliable transport between       does not provide:
    sending and receiving process     connection setup,
   flow control: sender won’t        reliability, flow control,
    overwhelm receiver                congestion control, timing,
                                      or bandwidth guarantee
   congestion control: throttle
    sender when network
    overloaded                      Q: why bother? Why is
   does not provide: timing,          there a UDP?
    minimum bandwidth
    guarantees

                                                    Application Layer   2-16
Internet apps: application, transport protocols
                            Application                        Underlying
           Application      layer protocol                     transport protocol

                   e-mail   SMTP [RFC 2821]                    TCP
remote terminal access      Telnet [RFC 854]                   TCP
                    Web     HTTP [RFC 2616]                    TCP
            file transfer   FTP [RFC 959]                      TCP
  streaming multimedia      proprietary                        TCP or UDP
                            (e.g. RealNetworks)
     Internet telephony     proprietary
                            (e.g., Vonage,Dialpad)             typically UDP
        Application   TELNET    FTP         SMTP        HTTP      DNS      SNMP      NTP

        Transport                     TCP                                   UDP

         Network                                   IP

          Access      ARPANET   Ethernet     Token Ring        FDDI      WLAN      ATM

                                                                      Application Layer    2-17
Chapter 2: Application layer

    2.1 Principles of network applications
       app architectures
       app requirements

    2.2 Web and HTTP
    2.4 Electronic Mail
       SMTP, POP3, IMAP

    2.5 DNS
    2.6 P2P file sharing




                                         Application Layer   2-18
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

                                       Application Layer   2-19
HTTP overview
HTTP: hypertext
  transfer protocol
 Web’s application layer
  protocol                     PC running
                                Explorer
 client/server model
    client: browser that
      requests, receives,
      “displays” Web objects                             Server
                                                         running
    server: Web server
                                                       Apache Web
      sends objects in                                   server
      response to requests
 HTTP 1.0: RFC 1945            Mac running
 HTTP 1.1: RFC 2068             Navigator



                                              Application Layer   2-20
HTTP overview (continued)
Uses TCP:                        HTTP is “stateless”
 client initiates TCP            server maintains no
  connection (creates socket)       information about
  to server, port 80                past client requests
 server accepts TCP
  connection from client                                 aside
                                Protocols that maintain
 HTTP messages (application-      “state” are complex!
  layer protocol messages)       past history (state) must
  exchanged between browser        be maintained
  (HTTP client) and Web
                                 if server/client crashes,
  server (HTTP server)
                                   their views of “state” may
 TCP connection closed
                                   be inconsistent, must be
                                   reconciled

                                               Application Layer   2-21
HTTP connections
Nonpersistent HTTP        Persistent HTTP
 At most one object is    Multiple objects can
  sent over a TCP           be sent over single
  connection.               TCP connection
 HTTP/1.0 uses             between client and
  nonpersistent HTTP        server.
                           HTTP/1.1 uses
                            persistent connections
                            in default mode




                                        Application Layer   2-22
   Nonpersistent HTTP
                                                (contains text,
Suppose user enters URL                        references to 10
  www.someSchool.edu/someDepartment/home.index   jpeg images)

    1a. HTTP client initiates TCP
        connection to HTTP server
        (process) at
                                        1b. HTTP server at host
                                           www.someSchool.edu waiting
        www.someSchool.edu on port 80
                                           for TCP connection at port 80.
                                           “accepts” connection, notifying
                                           client
    2. HTTP client sends HTTP
        request message (containing
        URL) into TCP connection        3. HTTP server receives request
        socket. Message indicates         message, forms response
        that client wants object          message containing requested
        someDepartment/home.index         object, and sends message
                                          into its socket

 time
                                                         Application Layer   2-23
   Nonpersistent HTTP (cont.)

                                           4. HTTP server closes TCP
                                             connection.
       5. HTTP client receives response
          message containing html file,
          displays html. Parsing html
          file, finds 10 referenced jpeg
          objects
time 6. Steps 1-5 repeated for each
          of 10 jpeg objects




                                                           Application Layer   2-24
Response time modeling
Definition of RTT: time to
  send a small packet to
  travel from client to
  server and back.
Response time:
                             initiate TCP
                             connection
 one RTT to initiate TCP             RTT

  connection                      request
                                  file
 one RTT for HTTP                    RTT
                                                                 time to

  request and first few
                                                                 transmit
                                                                 file
  bytes of HTTP response            file
                                    received
  to return
 file transmission time                    time             time

total = 2RTT+transmit time
                                                   Application Layer   2-25
Persistent HTTP

Nonpersistent HTTP issues:       Persistent without pipelining:
 requires 2 RTTs per object      client issues new request
 OS overhead for each TCP          only when previous
   connection                       response has been received
 browsers often open parallel    one RTT for each
   TCP connections to fetch         referenced object
   referenced objects            Persistent with pipelining:
Persistent HTTP                   default in HTTP/1.1
 server leaves connection        client sends requests as
   open after sending response      soon as it encounters a
 subsequent HTTP messages          referenced object
   between same client/server     as little as one RTT for all
   sent over open connection        the referenced objects


                                              Application Layer   2-26
  HTTP request message
   two types of HTTP messages:          request, response
   HTTP request message:
     ASCII (human-readable format)


  request line
 (GET, POST,         GET /somedir/page.html HTTP/1.1
HEAD commands)       Host: www.someschool.edu
                     User-agent: Mozilla/4.0
             header Connection: close
               lines Accept-language:fr

 Carriage return,
     line feed      (extra carriage return, line feed)
  indicates end
    of message
                                                         Application Layer   2-27
HTTP request message: general format




                             Application Layer   2-28
Uploading form input
Post method:
 Web page often
  includes form input     URL method:
 Input is uploaded to     Uses GET method
  server in entity body    Input is uploaded in
                            URL field of request
                            line:

          www.somesite.com/animalsearch?monkeys&banana




                                        Application Layer   2-29
Method types
HTTP/1.0                        HTTP/1.1
 GET                            GET, POST, HEAD
 POST                           PUT
 HEAD                                uploads file in entity
                                       body to path specified
     asks server to leave
                                       in URL field
      requested object out of
      response                   DELETE
                                    deletes file specified in
                                     the URL field




                                                  Application Layer   2-30
HTTP response message
  status line
   (protocol
 status code         HTTP/1.1 200 OK
status phrase)       Connection close
                     Date: Thu, 06 Aug 1998 12:00:15 GMT
                     Server: Apache/1.3.0 (Unix)
           header
                     Last-Modified: Mon, 22 Jun 1998 …...
             lines
                     Content-Length: 6821
                     Content-Type: text/html

 data, e.g.,         data data data data data ...
 requested
 HTML file




                                           Application Layer   2-31
HTTP response status codes
In first line in server->client response message.
A few sample 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 server
404 Not Found
      requested document not found on this server
505 HTTP Version Not Supported

                                                     Application Layer   2-32
 Trying out HTTP (client side) for yourself

1. Telnet to your favorite Web server:
  telnet cis.poly.edu 80      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


2. Type in a GET HTTP request:
       GET /~ross/ HTTP/1.1           By typing this in (hit carriage
       Host: cis.poly.edu             return twice), you send
                                      this minimal (but complete)
                                      GET request to HTTP server

3. Look at response message sent by HTTP server!

                                                        Application Layer   2-33
Let’s look at HTTP in action
 telnet example
 Ethereal example




                          Application Layer   2-34
User-server state: cookies
Many major Web sites           Example:
  use cookies                       Susan access Internet
Four components:                     always from same PC
                                    She visits a specific e-
  1) cookie header line of
                                     commerce site for first
     HTTP response message
                                     time
  2) cookie header line in
                                    When initial HTTP
     HTTP request message
                                     requests arrives at site,
  3) cookie file kept on             site creates a unique ID
     user’s host, managed by         and creates an entry in
     user’s browser                  backend database for
  4) back-end database at            ID
     Web site


                                                 Application Layer   2-35
   Cookies: keeping “state” (cont.)

                   client                        server
     Cookie file        usual http request msg      server
                        usual http response +     creates ID
  ebay: 8734            Set-cookie: 1678         1678 for user

     Cookie file
                        usual http request msg
 amazon: 1678               cookie: 1678           cookie-
 ebay: 8734                                        specific
                       usual http response msg      action
one week later:
                        usual http request msg
     Cookie file                                    cookie-
                            cookie: 1678
  amazon: 1678                                     spectific
  ebay: 8734           usual http response msg       action

                                                          Application Layer   2-36
Cookies (continued)
                                             aside
What cookies can bring:   Cookies and privacy:
 authorization            cookies permit sites to
 shopping carts
                            learn a lot about you
                           you may supply name
 recommendations
                            and e-mail to sites
 user session state
                           search engines use
  (Web e-mail)
                            redirection & cookies
                            to learn yet more
                           advertising companies
                            obtain info across
                            sites


                                      Application Layer   2-37
Web caches (proxy server)
Goal: satisfy client request without involving origin server

 user sets browser: Web                                           origin
  accesses via cache                                               server

 browser sends all HTTP                       Proxy
  requests to cache                            server
      object in cache: cache   client
       returns object
      else cache requests
       object from origin
       server, then returns
       object to client
                                 client
                                                                   origin
                                                                   server


                                                     Application Layer   2-38
More about Web caching
 Cache acts as both client      Why Web caching?
  and server                      Reduce response time for
 Typically cache is installed     client request.
  by ISP (university,             Reduce traffic on an
  company, residential ISP)        institution’s access link.
                                  Internet dense with caches
                                   enables “poor” content
                                   providers to effectively
                                   deliver content (but so
                                   does P2P file sharing)




                                                 Application Layer   2-39
Caching example
Assumptions                                                            origin
 average object size = 100,000                                      servers
  bits                                           public
 avg. request rate from                        Internet
  institution’s browsers to origin
  servers = 15/sec
 delay from institutional router                      1.5 Mbps
  to any origin server and back                        access link
  to router = 2 sec                   institutional
Consequences                            network
                                                           10 Mbps LAN
 utilization on LAN =     %
 utilization on access link =    %
 total delay = Internet delay +
   access delay + LAN delay                                  institutional
                                                                cache
 = 2 sec + minutes + milliseconds

                                                           Application Layer   2-40
Caching example (cont)
                                                                       origin
Possible solution
                                                                     servers
 increase bandwidth of access
   link to, say, 10 Mbps                         public
                                                Internet
Consequences
 utilization on LAN =        %
    utilization on access link = %
                                                       10 Mbps
    Total delay = Internet delay +                    access link
     access delay + LAN delay
                                      institutional
 =   2 sec + msecs + msecs
                                        network
    often a costly upgrade                                10 Mbps LAN




                                                             institutional
                                                                cache


                                                           Application Layer   2-41
Caching example (cont)
                                                                  origin
Install cache                                                   servers
 suppose hit rate is 0.4                   public
Consequence                                Internet
 40% requests will be
  satisfied almost immediately
 60% requests satisfied by
  origin server                                   1.5 Mbps
                                                  access link
 utilization of access link
  reduced to 60%, resulting in   institutional
  negligible delays (say 10        network
                                                      10 Mbps LAN
  msec)
 total avg delay = Internet
  delay + access delay + LAN
  delay = 0.6*(2.01) secs +
  milliseconds < 1.4 secs                               institutional
                                                           cache


                                                      Application Layer   2-42
  Conditional GET

 Goal: don’t send object if     cache                            server
  cache has up-to-date cached            HTTP request msg
  version                                If-modified-since:
                                                                     object
 cache: specify date of
                                               <date>
                                                                       not
  cached copy in HTTP request                                        modified
                                           HTTP response
   If-modified-since:
                                             HTTP/1.0
     <date>                              304 Not Modified
 server: response contains no
  object if cached copy is up-
                                         HTTP request msg
  to-date:                               If-modified-since:
   HTTP/1.0 304 Not                            <date>                 object
     Modified                                                         modified
                                           HTTP response
                                          HTTP/1.0 200 OK
                                              <data>
                                                           Application Layer   2-43
Chapter 2: Application layer
   2.1 Principles of network applications
   2.2 Web and HTTP
   2.3 FTP
   2.4 Electronic Mail
      SMTP, POP3, IMAP

   2.5 DNS
   2.6 P2P file sharing




                                             Application Layer   2-44
FTP: the file transfer protocol

                   FTP                   file transfer
                           FTP                            FTP
                   user   client                         server
                interface
      user
     at host                local file                            remote file
                            system                                system


   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

                                                          Application Layer     2-45
FTP: separate control, data connections
 FTP client contacts FTP                    TCP control connection
    server at port 21, specifying                   port 21
    TCP as transport protocol
   Client obtains authorization             TCP data connection
    over control connection          FTP           port 20           FTP
   Client browses remote           client                          server
    directory by sending
                                     Server opens a second TCP
    commands over control
                                      data connection to transfer
    connection.
                                      another file.
   When server receives a
                                     Control connection: “out of
    command for a file transfer,
                                      band”
    the server opens a TCP data
    connection to client             FTP server maintains “state”:
                                      current directory, earlier
   After transferring one file,
                                      authentication
    server closes connection.
                                                       Application Layer   2-46
FTP commands, responses

Sample commands:                Sample return codes
 sent as ASCII text over        status code and phrase (as
  control channel                   in HTTP)
 USER username                    331 Username OK,
 PASS password                     password required
                                   125 data connection
 LIST return list of file in
                                    already open;
  current directory
                                    transfer starting
 RETR filename retrieves          425 Can’t open data
  (gets) file                       connection
 STOR filename stores             452 Error writing
  (puts) file onto remote           file
  host

                                                 Application Layer   2-47
Chapter 2: Application layer
 2.1 Principles of network applications
 2.2 Web and HTTP
 2.3 FTP
 2.4 Electronic Mail
    SMTP, POP3, IMAP

 2.5 DNS
 2.6 P2P file sharing




                                           Application Layer   2-48
Electronic Mail                                              outgoing
                                                        message queue
                                                          user mailbox
Three major components:                    user
 user agents                             agent

 mail servers                    mail
                                                               user
                                 server
 simple mail transfer                                        agent
  protocol: SMTP                           SMTP       mail
                                                     server      user
User Agent                    SMTP                              agent
 a.k.a. “mail reader”
 composing, editing, reading              SMTP
                                 mail                          user
  mail messages                                               agent
                                server
 e.g., Eudora, Outlook, elm,
  Netscape Messenger                        user
                                           agent
 outgoing, incoming messages
                                  user
  stored on server               agent

                                                   Application Layer   2-49
Electronic Mail: mail servers
                                           user
Mail Servers                              agent
 mailbox contains incoming       mail
                                                                  user
  messages for user              server
                                                                 agent
 message queue of outgoing
                                           SMTP
  (to be sent) mail messages                             mail
                                                        server          user
 SMTP protocol between mail
  servers to send email         SMTP                                   agent

  messages                                 SMTP
    client: sending mail         mail                            user
                                                                 agent
      server                     server
    “server”: receiving mail
                                            user
      server                               agent
                                   user
                                  agent

                                                   Application Layer    2-50
Electronic Mail: SMTP [RFC 2821]

 uses TCP to reliably transfer email message from client
  to 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



                                                   Application Layer   2-51
Scenario: Alice sends message to Bob
1) Alice uses UA to compose          4) SMTP client sends Alice’s
   message and “to”                     message over the TCP
   bob@someschool.edu                   connection
2) Alice’s UA sends message          5) Bob’s mail server places the
   to her mail server; message          message in Bob’s mailbox
   placed in message queue           6) Bob invokes his user agent
3) Client side of SMTP opens            to read message
   TCP connection with Bob’s
   mail server



       1                                  mail
                   mail
                                         server          user
       user       server
              2                                         agent
      agent         3                              6
                                 4         5


                                                       Application Layer   2-52
Try SMTP interaction for yourself:

 telnet servername 25
 see 220 reply from server
 enter HELO, MAIL FROM, RCPT TO, DATA, QUIT
  commands
above lets you send email without using email client
  (reader)




                                            Application Layer   2-53
Sample SMTP interaction
 S:   220 hamburger.edu
 C:   HELO crepes.fr
 S:   250 Hello crepes.fr, pleased to meet you
 C:   MAIL FROM: <alice@crepes.fr>
 S:   250 alice@crepes.fr... Sender ok
 C:   RCPT TO: <bob@hamburger.edu>
 S:   250 bob@hamburger.edu ... Recipient ok
 C:   DATA
 S:   354 Enter mail, end with "." on a line by itself
 C:   Do you like ketchup?
 C:   How about pickles?
 C:   .
 S:   250 Message accepted for delivery
 C:   QUIT
 S:   221 hamburger.edu closing connection


                                         Application Layer   2-54
SMTP: final words
 SMTP uses persistent          Comparison with HTTP:
  connections
                                 HTTP: pull
 SMTP requires message
  (header & body) to be in 7-    SMTP: push
  bit ASCII                      both have ASCII
 SMTP server uses                command/response
  CRLF.CRLF to determine          interaction, status codes
  end of message
                                 HTTP: each object
                                  encapsulated in its own
                                  response msg
                                 SMTP: multiple objects
                                  sent in multipart msg


                                                 Application Layer   2-55
Mail message format

SMTP: protocol for
  exchanging email msgs       header
                                                         blank
RFC 822: standard for text
                                                          line
  message format:
 header lines, e.g.,
       To:
   
                              body
      From:
      Subject:
   different from SMTP
      commands!
 body
      the “message”, ASCII
       characters only


                                     Application Layer    2-56
   Message format: multimedia extensions
    MIME: multimedia mail extension, RFC 2045, 2056
    additional lines in msg header declare MIME content
     type

                              From: alice@crepes.fr
      MIME version            To: bob@hamburger.edu
                              Subject: Picture of yummy crepe.
        method used           MIME-Version: 1.0
      to encode data          Content-Transfer-Encoding: base64
                              Content-Type: image/jpeg
     multimedia data
      type, subtype,          base64 encoded data .....
parameter declaration         .........................
                              ......base64 encoded data
       encoded data


                                                    Application Layer   2-57
Message format: base64 encoding




                          Application Layer   2-58
Mail access protocols
                 SMTP         SMTP               access     user
          user
         agent                                  protocol   agent


                  sender’s mail   receiver’s mail
                     server           server

 SMTP: delivery/storage to receiver’s 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.

                                                       Application Layer   2-59
POP3 protocol                  S:   +OK POP3 server ready
                               C:   user bob
authorization phase            S:   +OK
                               C:   pass hungry
 client commands:             S:   +OK user successfully logged     on
    user: declare username
                               C:   list
    pass: password            S:   1 498
 server responses             S:   2 912
                               S:   .
    +OK
                               C:   retr 1
    -ERR                      S:   <message 1 contents>
transaction phase, client:     S:   .
                               C:   dele 1
 list: list message numbers   C:   retr 2
 retr: retrieve message by    S:   <message 1 contents>
  number                       S:   .
                               C:   dele 2
 dele: delete
                               C:   quit
 quit                         S:   +OK POP3 server signing off
                                               Application Layer   2-60
POP3 (more) and IMAP
More about POP3           IMAP
 Previous example uses    Keep all messages in
  “download and delete”     one place: the server
  mode.                    Allows user to
 Bob cannot re-read e-     organize messages in
  mail if he changes        folders
  client                   IMAP keeps user state
 “Download-and-keep”:      across sessions:
  copies of messages on        names of folders and
  different clients             mappings between
                                message IDs and folder
 POP3 is stateless
                                name
  across sessions

                                           Application Layer   2-61
Chapter 2: Application layer
  2.1 Principles of network applications
  2.2 Web and HTTP
  2.3 FTP
  2.4 Electronic Mail
     SMTP, POP3, IMAP

  2.5 DNS
  2.6 P2P file sharing




                                            Application Layer   2-62
DNS: Domain Name System

People: many identifiers:      Domain Name System:
      SSN, name, passport #      distributed database
Internet hosts, routers:           implemented in hierarchy of
                                   many name servers
      IP address (32 bit) -
       used for addressing
                                  application-layer protocol
                                   host, routers, name servers to
       datagrams
                                   communicate to resolve names
      “name”, e.g.,               (address/name translation)
       www.yahoo.com - used
                                     note: core Internet
       by humans
                                      function, implemented as
Q: map between IP                     application-layer protocol
  addresses and name ?               complexity at network’s
                                      “edge”


                                                  Application Layer   2-63
 DNS
DNS services                 Why not centralize DNS?
 Hostname to IP              single point of failure
  address translation         traffic volume
 Host aliasing               distant centralized
      Canonical and alias     database
       names                  maintenance
 Mail server aliasing
 Load distribution
                             doesn’t scale!
    Replicated Web
     servers: set of IP
     addresses for one
     canonical name

                                              Application Layer   2-64
Distributed, Hierarchical Database
                          Root DNS Servers



   com DNS servers        org DNS servers     edu DNS servers


                             pbs.org         poly.edu   umass.edu
yahoo.com   amazon.com
                             DNS servers     DNS serversDNS servers
DNS servers DNS servers

Client wants IP for www.amazon.com; 1st approx:
 Client queries a root server to find com DNS
   server
 Client queries com DNS server to get amazon.com
   DNS server
 Client queries amazon.com DNS server to get IP
   address for www.amazon.com
                                                   Application Layer   2-65
 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
                               a Verisign, Dulles, VA
                               c Cogent, Herndon, VA (also Los Angeles)
                               d U Maryland College Park, MD
                                                                   k RIPE London (also Amsterdam, Frankfurt)
                               g US DoD Vienna, VA
                                                                  i Autonomica, Stockholm (plus 3
                               h ARL Aberdeen, MD
                               j Verisign, ( 11 locations)
                                                                                  other locations)

                                                                                     m WIDE Tokyo
e NASA Mt View, CA
f Internet Software C. Palo Alto,
 CA (and 17 other locations)

                                                                                                       13 root name
                                                                                                       servers worldwide
    b USC-ISI Marina del Rey, CA
    l ICANN Los Angeles, CA




                                                                                                          Application Layer   2-66
TLD and Authoritative Servers
 Top-level domain (TLD) servers: responsible
  for com, org, net, edu, etc, and all top-level
  country domains uk, fr, ca, jp.
   Network solutions maintains servers for com TLD
   Educause for edu TLD
 Authoritative DNS servers: organization’s
  DNS servers, providing authoritative
  hostname to IP mappings for organization’s
  servers (e.g., Web and mail).
     Can be maintained by organization or service
      provider

                                           Application Layer   2-67
Local Name Server
 Does not strictly belong to hierarchy
 Each ISP (residential ISP, company,
  university) has one.
     Also called “default name server”
 When a host makes a DNS query, query is
  sent to its local DNS server
     Acts as a proxy, forwards query into hierarchy.




                                           Application Layer   2-68
Example                                  root DNS server



                                     2
 Host at cis.poly.edu                      3
                                                    TLD DNS server
  wants IP address for                          4
  gaia.cs.umass.edu
                                                5

                         local DNS server
                          dns.poly.edu
                                                7      6
                                1    8

                                                authoritative DNS server
                                                  dns.cs.umass.edu
                         requesting host
                          cis.poly.edu

                                                    gaia.cs.umass.edu


                                                     Application Layer   2-69
Recursive queries                        root DNS server


recursive query:
                                     2
 puts burden of name                                      3
  resolution on                            7       6
  contacted name                                               TLD DNS server
  server
 heavy load?
                         local DNS server
iterated query:           dns.poly.edu                 5       4

 contacted server              1    8
  replies with name of
  server to contact                            authoritative DNS server
 “I don’t know this
                                                 dns.cs.umass.edu
                         requesting host
  name, but ask this      cis.poly.edu
  server”
                                                 gaia.cs.umass.edu

                                                       Application Layer   2-70
DNS: caching and updating records
 once (any) name server learns mapping, it             caches
  mapping
   cache entries timeout (disappear) after some
    time
   TLD servers typically cached in local name
    servers
        • Thus root name servers not often visited
 update/notify mechanisms under design by IETF
    RFC 2136
      http://www.ietf.org/html.charters/dnsind-charter.html




                                                      Application Layer   2-71
DNS records
DNS: distributed db storing resource records (RR)
           RR format: (name,    value, type, ttl)


 Type=A                       Type=CNAME
    name is hostname             name is alias name for some
    value is IP address           “canonical” (the real) name
                                   www.ibm.com is really
 Type=NS
                                     servereast.backup2.ibm.com
    name is domain (e.g.
                                    value is canonical name
     foo.com)
    value is hostname of
                               Type=MX
     authoritative name
                                  value is name of mailserver
     server for this domain
                                   associated with name

                                                  Application Layer   2-72
DNS protocol, messages
DNS protocol : query and reply messages, both with
  same message format

msg header
 identification: 16 bit #
  for query, reply to query
  uses same #
 flags:
    query or reply
    recursion desired
    recursion available
    reply is authoritative




                                         Application Layer   2-73
DNS protocol, messages

    Name, type fields
         for a query

      RRs in response
              to query

         records for
authoritative servers

   additional “helpful”
info that may be used




                          Application Layer   2-74
Inserting records into DNS
 Example: just created startup “Network Utopia”
 Register name networkuptopia.com at a registrar
  (e.g., Network Solutions)
      Need to provide registrar with names and IP addresses of
       your authoritative name server (primary and secondary)
      Registrar inserts two RRs into the com TLD server:

   (networkutopia.com, dns1.networkutopia.com, NS)
   (dns1.networkutopia.com, 212.212.212.1, A)

 Put in authoritative server Type A record for
  www.networkuptopia.com and Type MX record for
  networkutopia.com
 How do people get the IP address of your Web site?


                                                  Application Layer   2-75
Chapter 2: Application layer
  2.1 Principles of network applications
     app architectures
     app requirements

  2.2 Web and HTTP
  2.4 Electronic Mail
     SMTP, POP3, IMAP

  2.5 DNS
  2.6 P2P file sharing




                                            Application Layer   2-76
P2P file sharing
                           Alice chooses one of
Example
                            the peers, Bob.
 Alice runs P2P client
                           File is copied from
  application on her
  notebook computer         Bob’s PC to Alice’s
                            notebook: HTTP
 Intermittently
                           While Alice downloads,
  connects to Internet;
  gets new IP address       other users uploading
  for each connection       from Alice.
                           Alice’s peer is both a
 Asks for “Hey Jude”
                            Web client and a
 Application displays
                            transient Web server.
  other peers that have
  copy of Hey Jude.       All peers are servers =
                            highly scalable!
                                        Application Layer   2-77
P2P: centralized directory
                                                                        Bob
original “Napster” design        centralized
1) when peer connects, it     directory server
                                                     1
   informs central server:                                             peers

      IP address                                    1

      content
                                                     1           3
2) Alice queries for “Hey
                                           2
   Jude”                                         1


3) Alice requests file from
   Bob

                                                         Alice




                                                         Application Layer     2-78
P2P: problems with centralized directory

 Single point of failure   file transfer is
 Performance               decentralized, but
  bottleneck                locating content is
 Copyright
                            highly centralized
  infringement




                                       Application Layer   2-79
Query flooding: Gnutella
 fully distributed        overlay network: graph
    no central server      edge between peer X
 public domain protocol     and Y if there’s a TCP
 many Gnutella clients      connection
  implementing protocol     all active peers and
                             edges is overlay net
                            Edge is not a physical
                             link
                            Given peer will
                             typically be connected
                             with < 10 overlay
                             neighbors

                                         Application Layer   2-80
Gnutella: protocol
                                 File transfer:
 Query message                  HTTP
sent over existing TCP
connections                      Query
 peers forward                  QueryHit
Query message
 QueryHit
sent over
reverse                  Query
path
                     QueryHit
Scalability:
limited scope
flooding

                                  Application Layer   2-81
Gnutella: Peer joining
1. Joining peer X must find some other peer in
   Gnutella network: use list of candidate peers
2. X sequentially attempts to make TCP with peers
   on list until connection setup with Y
3. X sends Ping message to Y; Y forwards Ping
   message.
4. All peers receiving Ping message respond with
   Pong message
5. X receives many Pong messages. It can then
   setup additional TCP connections
Peer leaving: see homework problem!

                                         Application Layer   2-82
Exploiting heterogeneity: KaZaA

 Each peer is either a
  group leader or assigned
  to a group leader.
      TCP connection between
       peer and its group leader.
      TCP connections between
       some pairs of group
       leaders.
 Group leader tracks the
  content in all its                ordinary peer

  children.                         group-leader peer

                                    neighoring relationships
                                       in overlay network



                                                Application Layer   2-83
KaZaA: Querying
 Each file has a hash and a descriptor
 Client sends keyword query to its group
  leader
 Group leader responds with matches:
     For each match: metadata, hash, IP address
 If group leader forwards query to other
  group leaders, they respond with matches
 Client then selects files for downloading
     HTTP requests using hash as identifier sent to
      peers holding desired file

                                           Application Layer   2-84
KaZaA tricks
 Limitations on simultaneous uploads
 Request queuing
 Incentive priorities
 Parallel downloading




                                    Application Layer   2-85

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:4
posted:11/27/2010
language:English
pages:85