Documents
Resources
Learning Center
Upload
Plans & pricing Sign in
Sign Out

Performance

VIEWS: 6 PAGES: 28

									Application Layer

Socket API, HTTP, VoIP, DNS



IS250
Spring 2010

John Chuang
Application Layer & Socket API
                          end-to-end                          Software
  Appl                                                Appl

                                                               Socket API

 Trans                    end-to-end                  Trans
  port                                                 port

                                                              Operating
                                                              System
  Net          Net       point-to-point    Net        Net
  work         work                        work       work


                         point-to-point
  Link         Link                        Link       Link    Hardware




Host A        Router 1                    Router 2   Host B

John Chuang                                                       2
Socket

 Socket: an API (application programming
  interface) that allows the abstraction of the
  underlying network (i.e., layers 4 and lower)
 Sockets support send and receive methods
 Sockets identified by <IP addr, TCP/UDP port>
 Two common types of sockets:
    - Stream socket (supported by TCP)
    - Datagram socket (supported by UDP)
 Read: Comer 3.13-3.23
John Chuang                                       3
Network Layers
 Application (layer 7): specific to    HTTP, FTP, NNTP, SMTP,
  application need                                telnet, ...
 Transport (layer 4): end-to-end
  delivery, congestion and flow                  TCP, UDP

  control
 Network (layer 3): addressing,                      IP

  routing                                          Wi-Fi
 Data Link (layer 2): framing, error            Ethernet
  detection                                   FDDI, SONET

 Physical (layer 1): bits (0/1),        coax, twisted pair, fiber,

  voltages, frequencies, wires, pins,           wireless, ...

  …


John Chuang                                                           4
Representation v. Transfer
 Application layer protocols specify two aspects
  of interaction:
    - Data representation: Syntax of data items that are
      exchanged, e.g., HTML
    - Data transfer: Interaction between client and server,
      e.g., HTTP




John Chuang                                                   5
L7 Alphabet Soup
 Applications:
    -   HTTP (Comer 4.4-4.10)
    -   FTP (Comer 4.11)
    -   Email, SMTP (Comer 4.12-4.16)
    -   telnet, SSH
    -   RTP, SIP (Comer 29)
    -   …
 Network support:
    - DNS (Comer 4.17-4.25)
    - BGP, RIP, OSPF (Comer 27)
    - …

John Chuang                             6
Hypertext Transfer Protocol

 HTTP specification (RFC 2616):
    - http://www.ietf.org/rfc/rfc2616.txt
 HTTP uses TCP
 Two types of HTTP messages
    - HTTP Request
    - HTTP Response
                         HTTP Request

                         HTTP Response
              Client                     Server
John Chuang                                       7
HTTP Request Format

Request line     <method><resource identifier><HTTP version><CRLF>

                 [<Header>:<value><CRLF>]
General header
Request header   …
Entity header    [<Header>:<value><CRLF>]

Blank line       <CRLF>

Entity body      [Message body]

                                     Note:
                                     • <CRLF> = carriage-return-line-feed
                                     • optional fields in []



John Chuang                                                           8
HTTP Header Fields
   HTTP Methods                Request Headers                      Entity Headers
     -   GET                      -   Accept                            -   Allow
     -   POST                     -   Accept-Charset                    -   Content-Encoding
     -   HEAD                     -   Accept-Encoding                   -   Content-Language
     -   OPTIONS                  -   Accept-Language                   -   Content-Length
     -   PUT                      -   Authorization                     -   Content-Location
     -   DELETE                   -   Cookie                            -   Content-MD5
     -   TRACE                    -   Expect                            -   Content-Range
     -   CONNECT                  -   From                              -   Content-Type
                                  -   Host *                            -   Expires
                                  -   If-Match If-Modified-Since        -   Last-Modified
   General Header Fields
     -   Cache-Control            -   If-None-Match
     -   Connection               -   If-Range
     -   Date                     -   If-Unmodified-Since
     -   Pragma                   -   Max-Forwards
     -   Trailer                  -   Proxy-Authorization
     -   Transfer-Encoding        -   Range
     -   Upgrade                  -   Referrer
     -   Via                      -   TE
     -   Warning                  -   User-Agent


                                      * Mandatory in HTTP/1.1
John Chuang                                                                                    9
HTTP Request: Example
Request line          GET /index.html HTTP/1.1<CRLF>

Request header        Host: www.sims.berkeley.edu <CRLF>

Blank line            <CRLF>


                                                               HTTP message


                                     TCP header    port        HTTP message


                     IP header TCP                 TCP segment


Ethernet header IP                     IP datagram/packet


                                Ethernet frame
John Chuang                                                                                        10
                                                  Adapted from Coulouris, Dollimore and Kindberg
                                                                    Note:

HTTP Response                                                       • <CRLF> = carriage-return-line-feed
                                                                    • optional fields in []




    Status line             <HTTP version><status code><Reason phrase><CRLF>
    General header
                            [<Header>:<value><CRLF>]
    Response header
    Entity header           …
    Blank line              <CRLF>
    Entity body             [Message body]


   Response Header Fields                        Status Codes
     - Accept-Ranges                                   -   1xx: Informational
     - Age                                             -   2xx: Success
     - Etag                                            -   3xx: Redirection
     - Location                                        -   4xx: Client error
     - Proxy-Authenticate                              -   5xx: Server error
     - Retry-After
     - Server                                     Some common codes:
     - Set-Cookie                                      -   200 OK
     - Vary                                            -   401 Unauthorized
     - WWW-Authenticate                                -   404 Not Found
John Chuang                                                                                       11
HTTP Response: Example

Status line       HTTP/1.1 200 OK
                  Date: Mon, 12 Nov 2007 20:14:04 GMT
                  Server: Apache/2.0.52 (Red Hat)
General header    X-Powered-By: PHP/4.3.9
                  Set-Cookie: PHPSESSID=f49e0b5ec; expires=Wed, 05-Dec-2007 23:47:24 GMT; path=/
Response header   Last-Modified: Mon, 12 Nov 2007 20:14:04 GMT
                  Cache-Control: no-store, no-cache, must-revalidate
                  Cache-Control: post-check=0, pre-check=0
                  Pragma: no-cache
                  Transfer-Encoding: chunked
Entity header     Content-Type: text/html; charset=utf-8
Blank line
                  <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en”>
Entity body       …
                  </html>




John Chuang                                                                             12
HTTP/1.1 and Persistent
TCP Connections

 An HTML object often has other
  embedded objects (e.g., images)
 HTTP/1.0 requires a new TCP session for
  each object
    - Overhead of session establishment
 HTTP/1.1 permits reuse of one TCP
  session for multiple requests
    - Use “Connection: Keep-Alive” header

John Chuang                                 13
L7 Alphabet Soup
 Applications:
    -   HTTP (Comer 4.4-4.10)
    -   FTP (Comer 4.11)
    -   Email, SMTP (Comer 4.12-4.16)
    -   telnet, SSH
    -   RTP, SIP (Comer 29)
    -   …
 Network support:
    - DNS (Comer 4.17-4.25)
    - BGP, RIP, OSPF (Comer 27)
    - …

John Chuang                             14
Real-Time Multimedia

 How to support real-time multimedia
  applications (e.g., video, audio) over a best-
  effort IP network?
    - Packets may be delivered out of order or lost
    - Retransmission is too slow to be helpful
 Technique: delayed playback using timestamps
  and jitter buffer




John Chuang                                                         15
                                            Source: Douglas Comer
Real-Time Transport
Protocol (RTP)

 Protocol for transport of real-time multi-
  media data
    - Sequence number and timestamp in RTP
      header




                                   Source: Douglas Comer




John Chuang                                                16
Real-Time Transport
Protocol (RTP)

 RTP messages encapsulated in UDP
  datagrams
    - Why not TCP?




                              Source: Douglas Comer

John Chuang                                           17
RTP Companion Protocols

 RTCP: Real-time Transport Control
  Protocol
    - Control packets sent periodically to report
      quality such as loss rate and jitter
 RTSP: Real-time Transport Streaming
  Protocol
    - Used by streaming media players to provide
      remote control like capabilities (e.g., play,
      stop, fast forward)

John Chuang                                           18
IP Telephony (VoIP)
 Companies around the world are replacing traditional
  telephone switches with IP routers
    - Routers cost much less than traditional telephone switches
    - Sending both data and voice as IP packets lowers cost because
      underlying infrastructure is shared
 The basic idea behind IP telephony:
    - continuously sample audio, convert to digital (PCM)
    - send digitized stream across IP network (RTP)
    - convert stream back to analog for playback
 Complications arise in signaling and backward
  compatibility with PSTN


John Chuang                                                       19
IP Telephony (VoIP)

 IP telephone
 Media gateway
  controller
 Media gateway
 Signaling gateway




                      Source: Douglas Comer
John Chuang                                   20
VoIP Protocols

 RTP for user multimedia data
 Multiple protocols for signaling:
    - SIP: Session Initiation Protocol [RFC 2543] (IETF)
    - H.323 (ITU)
    - ENUM: converts telephone number to URI; facilitates DNS lookup




John Chuang                                                              21
                                                 Source: Douglas Comer
Example
SIP
Session




John Chuang   Source: Douglas Comer   22
L7 Alphabet Soup
 Applications:
    -   HTTP (Comer 4.4-4.10)
    -   FTP (Comer 4.11)
    -   Email, SMTP (Comer 4.12-4.16)
    -   telnet, SSH
    -   RTP, SIP (Comer 29)
    -   …
 Network support:
    - DNS (Comer 4.17-4.25)
    - BGP, RIP, OSPF (Comer 27)
    - …

John Chuang                             23
Domain Name Service (DNS)

 Routers and end-hosts use IP addresses
    - e.g., 128.32.226.87
 Human beings remember hostnames
    - e.g., ischool.berkeley.edu
 Need translation service!

 Client sends query message (hostname) to
  domain name server using UDP
 Name server sends response message (with
  resolved IP address) back to client

John Chuang                                  24
    DNS Query

 Local Name Server
 (ns1.berkeley.edu)




            (1)
                  (2)


                                (3)


          Client
(client.ischool.berkeley.edu)
                                            Server
                                      (www.publisher.com)
     John Chuang                                    25
    DNS Query
                                            Root Name Server
                                            (f.root-servers.net)

 Local Name Server              (2)                                Remote Name Server
 (ns1.berkeley.edu)                   (3)                           (ns.publisher.com)
                                                    (4)
                                                      (5)

            (1)
                  (6)


                                                          (7)


          Client
(client.ischool.berkeley.edu)
                                                                          Server
                                                                    (www.publisher.com)
     John Chuang                                                                  26
              Hostnames: [a-m].root-servers.net
              Source: http://www.wia.org/pub/rootserv.html




John Chuang                                             27
Next Time: Overlays

 Build your own networks at the
  application layer




John Chuang                        28

								
To top