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
    client-server

     paradigm              programming network
    peer-to-peer
     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

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

write programs that                             physical

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

No need to write software
                                      data link
  for network-core devices
      Network-core devices do                                data link
       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
  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

 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
 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 web
  process?                      server:
    A: No, many                   IP address:
     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
 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”
                                 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
  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
    sender when network
   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

 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:

          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
      sends objects in
      response to requests
                                Mac running

                                              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

                                              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

                                       2: Application Layer   18
   Nonpersistent HTTP
                                                                 (contains text,
Suppose user enters URL                                         references to 10                    jpeg images)

    1a. HTTP client initiates TCP
        connection to HTTP server
        (process) at
                                        1b. HTTP server at host
                                  waiting on port 80
                                           for TCP connection at port 80.
                                           “accepts” connection, notifying
    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

                                                       2: Application Layer   19
   Nonpersistent HTTP (cont.)

                                           4. HTTP server closes TCP
       5. HTTP client receives response
          message containing html file,
          displays html. Parsing html
          file, finds 10 referenced jpeg
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
Response time:                        RTT
 one RTT to initiate TCP         request
  connection                                                         time to
 one RTT for HTTP                                                   file
  request and first few              file
  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:
                     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

                                       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
 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)
                     Last-Modified: Mon, 22 Jun 1998 …...
                     Content-Length: 6821
                     Content-Type: text/html

 data, e.g.,         data data data data data ...
 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 80   (default HTTP server port) at
                           Anything typed in sent
                           to port 80 at

2. Type in a GET HTTP request:
       GET /~ross/ HTTP/1.1        By typing this in (hit carriage
       Host:          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

Shared By: