Docstoc

lecture8 Chapter

Document Sample
lecture8 Chapter Powered By Docstoc
					Chapter 2: Application layer
 2.1 Principles of        2.6 P2P applications
  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.5 DNS




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



                                          2: Application Layer   2
Some network apps
 e-mail                    voice over IP
 web                       real-time video
 instant messaging          conferencing
 remote login              grid computing
 P2P file sharing         
 multi-user network       
  games                    
 streaming stored video
  clips



                                        2: Application Layer   3
Creating a network app                         application
                                               transport
                                                network
                                                data link

write programs that                             physical



      run on (different) end
       systems
      communicate over network
      e.g., web server software
       communicates with browser
       software                      application

No need to write software
                                     transport
                                      network
                                      data link
  for network-core devices
                                                             application
                                      physical
                                                             transport
                                                              network
      Network-core devices do                                data link
                                                              physical
       not run user applications
      applications on end systems
       allows for rapid app
       development, propagation
                                          2: Application Layer         4
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


                                       2: Application Layer   5
  Sockets

 process sends/receives
                                      host or                                   host or
                                      server                                    server
  messages to/from its
  socket                                             controlled by
                                                     app developer
 socket analogous to door            process                                   process

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

 API: (1) choice of transport protocol; (2) ability to fix
  a few parameters (lots more on this later)
                                                              2: Application Layer    6
Addressing processes
 to receive messages,
  process must have
  identifier
 host device has unique
  32-bit IP address
 Q: does IP address of
  host suffice for
  identifying the process?




                             2: Application Layer   7
Addressing processes
 to receive messages,         identifier includes both
  process must have           IP address and port
  identifier                  numbers associated with
 host device has unique      process on host.
  32-bit IP address          Example port numbers:
 Q: does IP address of            HTTP server: 80
  host on which process            Mail server: 25
  runs suffice for           to send HTTP message
  identifying the               to gaia.cs.umass.edu web
  process?                      server:
    A: No, many                   IP address: 128.119.245.12
     processes can be              Port number: 80
     running on same host    more shortly…
                                            2: Application Layer   8
App-layer protocol defines
 Types of messages              Public-domain protocols:
  exchanged,                      defined in RFCs
      e.g., request, response    allows for
 Message syntax:                  interoperability
   what fields in messages &
                                  e.g., HTTP, SMTP
    how fields are delineated
                                 Proprietary protocols:
 Message semantics
   meaning of information in
                                  e.g., Skype
    fields
 Rules for when and how
  processes send &
  respond to messages
                                            2: Application Layer   9
 What transport service does an app need?
Data loss                       Throughput
 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       throughput to be
  100% reliable data              “effective”
  transfer
                                 other apps (“elastic apps”)
Timing                            make use of whatever
 some apps (e.g.,                throughput they get
  Internet telephony,
  interactive games)            Security
  require low delay to be        Encryption, data
  “effective”                     integrity, …

                                           2: Application Layer   10
 Transport service requirements of common apps

         Application      Data loss       Throughput           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




                                                         2: Application Layer   11
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,
                                      throughput guarantee, or
   congestion control: throttle
                                      security
    sender when network
    overloaded
   does not provide: timing,       Q: why bother? Why is
    minimum throughput                 there a UDP?
    guarantees, security
                                                  2: Application Layer   12
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      HTTP (eg Youtube),      TCP or UDP
                            RTP [RFC 1889]
     Internet telephony     SIP, RTP, proprietary
                            (e.g., Skype)           typically UDP




                                                      2: Application Layer   13
Chapter 2: Application layer
 2.1 Principles of         2.6 P2P applications
  network applications      2.7 Socket programming
      app architectures     with TCP
       app requirements
                            2.8 Socket programming
   

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

 2.5 DNS




                                        2: Application Layer   14
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

                                      2: Application Layer   15
HTTP overview

HTTP: hypertext
  transfer protocol
 Web’s application layer      PC running
  protocol                      Explorer

 client/server model
    client: browser that
      requests, receives,                                   Server
      “displays” Web objects                                running
                                                          Apache Web
    server: Web server
                                                            server
      sends objects in
      response to requests
                                Mac running
                                 Navigator



                                              2: Application Layer   16
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

                                              2: Application Layer   17
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
                            between client and
                            server.




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




                                                       2: Application Layer   20
Non-Persistent HTTP: Response time
Definition of RTT: time for
  a small packet to travel
  from client to server
  and back.                   initiate TCP
                              connection
Response time:                        RTT
 one RTT to initiate TCP         request
                                  file
  connection                                                         time to
                                      RTT
                                                                     transmit
 one RTT for HTTP                                                   file
  request and first few              file
                                     received
  bytes of HTTP response
  to return                                  time                time
 file transmission time
total = 2RTT+transmit time
                                                    2: Application Layer   21
Persistent HTTP

Nonpersistent HTTP issues:       Persistent HTTP
 requires 2 RTTs per object      server leaves connection
 OS overhead for each TCP          open after sending
  connection                        response
 browsers often open parallel    subsequent HTTP messages
  TCP connections to fetch          between same
  referenced objects                client/server sent over
                                    open connection
                                  client sends requests as
                                    soon as it encounters a
                                    referenced object
                                  as little as one RTT for all
                                    the referenced objects


                                                 2: Application Layer   22
  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
                                                     2: Application Layer   23
HTTP request message: general format




                            2: Application Layer   24
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




                                       2: Application Layer   25
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




                                                 2: Application Layer   26
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




                                          2: Application Layer   27
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
                                                  2: Application Layer   28
 Trying out HTTP (client side) for yourself

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

                                                   2: Application Layer   29

				
DOCUMENT INFO
Shared By:
Categories:
Tags:
Stats:
views:6
posted:12/10/2011
language:English
pages:29