CS244a: An Introduction to Computer Networks

Document Sample
CS244a: An Introduction to Computer Networks Powered By Docstoc
• Understand
   – Service requirements applications placed on network
   – Protocols distributed applications use to implement applications
• Conceptual + implementation aspects of network
  application protocols
   – client server paradigm
   – peer-to-peer paradigm
• Learn about protocols by examining popular
  application-level protocols
   – World Wide Web
   – Electronic Mail
   – P2P File Sharing
• Application Infrastructure Services: DNS

                    CSci4211:   Application Layer                 1
2: Application Layer
          Some network apps
• e-mail                   • social networks
• web                      • voice over IP
• instant messaging        • real-time video
• remote login               conferencing
• P2P file sharing         • grid computing
• multi-user network
• streaming stored video

                                         2: Application Layer
          Creating a network app                 application

write programs that                                network
                                                  data link

   – run on (different) end

   – communicate over network
   – e.g., web server software
     communicates with browser
No need to write software          application

  for network-core devices
                                    data link
   – Network-core devices do
     not run user applications                                     data link

   – applications on end systems
     allows for rapid app
     development, propagation

                                                   2: Application Layer
  Applications and Application-Layer Protocols

Application: communicating,                 application

  distributed processes
                                             data link
   – running in network hosts in             physical

     “user space”
   – exchange messages to
     implement app
   – e.g., email, file transfer, the
Application-layer protocols
   – one “piece” of an app                                              application
   – define messages exchanged
                                                           transport      network

     by apps and actions taken
                                                            network      data link
                                                           data link     physical
   – user services provided by
     lower layer protocols

                          CSci4211:    Application Layer                         5
    App-layer protocol defines
• Types of messages
                                Public-domain protocols:
  – e.g., request, response
                                • defined in RFCs
• Message syntax:
  – what fields in messages &
                                • allows for
    how fields are delineated     interoperability
• Message semantics             • e.g., HTTP, SMTP,
  – meaning of information in     BitTorrent
    fields                      Proprietary protocols:
• Rules for when and how        • e.g., Skype, ppstream
  processes send &
  respond to messages

                                              2: Application Layer
    Application architectures
• Client-server
  – Including data centers / cloud computing
• Peer-to-peer (P2P)
• Hybrid of client-server and P2P

                                               2: Application Layer
         Application Structure
Internet application distributed in nature!
 - Set of communicating application-level processes
(usually on different hosts) provide/implement services
Programming Paradigms:
• Client-Server Model: Asymmetric
   – Server: offers service via well defined “interface”
   – Client: request service
   – Example: Web
• Peer-to-Peer: Symmetric
   – Each process is an equal
   – Example: telephone, p2p file sharing (e.g., Kazaar)

   Both require transport of “request/reply”, sharing of data!

                       CSci4211:   Application Layer             8
      Client-server architecture
                                   – always-on host
                                   – permanent IP address
                                   – server farms for scaling
                                   – communicate with server
                                   – may be intermittently
client/server                        connected
                                   – may have dynamic IP
                                   – do not communicate
                                     directly with each other

                2: Application Layer                        9
       Google Data Centers
• Estimated cost of data center: $600M
• Google spent $2.4B in 2007 on new data
• Each data center uses 50-100 megawatts
  of power

         Pure P2P architecture
• no always-on server
• arbitrary end systems
  directly communicate peer-peer
• peers are intermittently
  connected and change IP

Highly scalable but
  difficult to manage

                                   2: Application Layer
            Peer-to-Peer Paradigm
• How do we implement peer-to-peer model?
• Is email peer-to-peer or client-server application?
• How do we implement peer-to-peer using
       client-server model?
  Difficulty in implementing “pure” peer-to-peer
  • How to locate your peer?
    – Centralized “directory service:” i.e., white pages
        • Napters
    – Unstructured: e.g., “broadcast” your query: namely, ask your
      friends/neighbors, who may in turn ask their friends/neighbors,
        • Freenet
    – Structured: Distributed hashing table (DHT)

                      CSci4211:   Application Layer               12
 Hybrid of client-server and P2P
   – voice-over-IP P2P application
   – centralized server: finding address of remote party:
   – client-client connection: direct (not through server)
Instant messaging
   – chatting between two users is P2P
   – centralized service: client presence detection/location
        • user registers its IP address with central
          server when it comes online
        • user contacts central server to find IP
          addresses of buddies

                                                    2: Application Layer
       Network Applications: some jargon

• A process is a program
  that is running within a         • A user agent is an
  host.                              interface between the
• Within the same host, two          user and the network
  processes communicate              application.
  with interprocess
                                         – Web:browser
  communication defined by
                                         – E-mail: mail reader
  the OS.
                                         – streaming audio/video:
• Processes running in                     media player
  different hosts
  communicate with an
  application-layer protocol

                    CSci4211:   Application Layer                   14
     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 P2P
  hosts communicate by       architectures have client
  exchanging messages        processes & server

                                           2: Application Layer
• process sends/receives
                                                                                 host or
  messages to/from its
                                    host or
                                    server                                       server
• socket analogous to door
                                                   controlled by
                                                   app developer
   – sending process shoves

     message out door               socket                                       socket

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

                                                                 2: Application Layer
     Application Programming Interface

 API: application        Q: how does a process
   programming interface   “identify” the other
 • defines interface       process with which it
   between application     wants to communicate?
                            – IP address of host running
   and transport layer        other process
 • socket: Internet API     – “port number” - allows
     – two processes                            receiving host to
       communicate by sending                   determine to which local
       data into socket, reading                process the message
       data out of socket                       should be delivered

 API: (1) choice of transport protocol; (2) ability to fix a few
  parameters (lots more on this later)
                       CSci4211:   Application Layer                       17
          Addressing Processes
                         • Q: does IP address of
• to receive messages,     host on which process runs
  process must have        suffice for identifying the
  identifier               process?
• host device has unique    – A: No, many processes
  32-bit IP address           can be running on same
• Exercise: use ipconfig • Identifier includes both IP
  from command prompt to address and port numbers
  get your IP address      associated with process on
                         • Example port numbers:
                            – HTTP server: 80
                            – Mail server: 25

                                           2: Application Layer
 What transport service does an app need?
Data loss                       Throughput
• some apps (e.g., audio) can    some apps (e.g., multimedia)
  tolerate some loss              require minimum amount of
• other apps (e.g., file          throughput to be “effective”
  transfer, telnet) require      other apps (“elastic apps”)
  100% reliable data              make use of whatever
  transfer                        throughput they get
Timing                          Security
• some apps (e.g.,               Encryption, data integrity, …
  Internet telephony,
  interactive games)
  require low delay to be

                                               2: Application Layer
  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        loss-tolerant      elastic          no
real-time audio/video     loss-tolerant      audio: 5Kb-1Mb   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
       financial apps     no loss            elastic          yes and no

                            CSci4211:     Application Layer               20
   Network Transport Services
end host to end host communication services
• Connection-Oriented, Reliable Service
   – Mimic “dedicated link”
   – Messages delivered in correct order, without errors
   – Transport service aware of connection in progress
      • Stateful, some “state” information must be maintained
   – Require explicit connection setup and teardown
• Connectionless, Unreliable Service
   – Messages treated as independent
   – Messages may be lost, or delivered out of order
   – No connection setup or teardown, “stateless”

                     CSci4211:   Application Layer              21
       Internet Transport Protocols

TCP service:                         UDP service:
• connection-oriented: setup         • unreliable data
  required between client,             transfer between
  server                               sender and receiver
• reliable transport between         • does not provide:
  sender and receiver                  connection setup,
• flow control: sender won’t           reliability, flow
  overwhelm receiver                   control, congestion
• congestion control: throttle         control
  sender when network
                                     Q:Why UDP?
                     CSci4211:   Application Layer           22
     Internet apps: their protocols and transport
                            Application                     Underlying
           Application      layer protocol                  transport protocol

                   e-mail   smtp [RFC 821]                  TCP
remote terminal access      telnet [RFC 854]                TCP
                    Web     http [RFC 2068]                 TCP
            file transfer   ftp [RFC 959]                   TCP
  streaming multimedia      proprietary                     TCP or UDP
                            (e.g. RealNetworks)
      remote file server    NSF                             TCP or UDP
     Internet telephony     proprietary                     typically UDP
                            (e.g., Vocaltec)

                            CSci4211:   Application Layer                   23
           Client-Server Paradigm Recap
    Typical network app has two
       pieces: client and server            application
Client:                                      data link
•    initiates contact with server
     (“speaks first”)
•    typically requests service from
•    for Web, client is implemented in
     browser; for e-mail, in mail reader
Server:                                                             reply
• provides requested service to

                                                                       data link

• e.g., Web server sends
  requested Web page, mail
  server delivers e-mail
                           CSci4211:   Application Layer                     24
  Client-Server: The Web Example
some jargon
                                        • User agent for Web is
• Web page:
   – consists of “objects”
                                          called a browser:
   – addressed by a URL                       – MS Internet Explorer
                                              – Netscape Communicator
• Most Web pages
  consist of:                           • Server for Web is
   – base HTML page, and                  called Web server:
   – several referenced                       – Apache (public domain)
     objects.                                 – MS Internet Information
• URL has two                                   Server
  components: host name
  and path name:

                      CSci4211:   Application Layer                 25
       The Web: the HTTP protocol
HTTP: hypertext transfer
• Web’s application layer                PC running
  protocol                                Explorer
• client/server model
   – client: browser that
      requests, receives,
      “displays” Web objects                              Server
   – server: Web server                                   running
                                                         NCSA Web
      sends objects in                                     server
      response to requests
•   http1.0: RFC 1945
                                           Mac running
•   http1.1: RFC 2068                       Navigator

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

                    CSci4211:   Application Layer                 27
                          HTTP Example
  Suppose user enters URL
                                      (contains text, references to 10 jpeg images)

  1a. http client initiates TCP                 1b. http server at host
       connection to http server                     www.someSchool.edu waiting
       (process) at                                  for TCP connection at port 80.
  www.someSchool.edu. Port 80 is                     “accepts” connection, notifying
       default for http server.                      client

                                               3. http server receives request
 2. http client sends http request                  message, forms response
       message (containing URL) into                message containing requested
       TCP connection socket                        object
time                                                sends message into socket

                               CSci4211:   Application Layer                          28
               HTTP Example (cont.)
                                          4. http server closes TCP

   5. http client receives
       response message
       containing html file,
       displays html. Parsing html
       file, finds 10 referenced
       jpeg objects

   6. Steps 1-5 repeated for each
       of 10 jpeg objects


                            CSci4211:   Application Layer             29
   Non-persistent and persistent connections
Non-persistent                            Persistent
• HTTP/1.0                                • default for HTTP/1.1
• server parses request,                  • on same TCP connection:
  responds, and closes TCP                   server, parses request,
  connection                                 responds, parses new
• 2 RTTs to fetch each                       request,..
  object                                  • Client sends requests for
• Each object transfer                       all referenced objects as
  suffers from slow start                    soon as it receives base
  But most 1.0 browsers use               • Fewer RTTs and less slow
  parallel TCP connections.                  start.

                              CSci4211:   Application Layer              30
        http message format: request
     • two types of http messages: request, response
     • http request message:
        – ASCII (human-readable format)

  request line
                        GET /somedir/page.html HTTP/1.0
HEAD commands)
                        User-agent: Mozilla/4.0
                header Accept: text/html, image/gif,image/jpeg
                  lines Accept-language:fr
  Carriage return,
      line feed         (extra carriage return, line feed)
   indicates end
     of message

                        CSci4211:   Application Layer   31
http request message: general format

           CSci4211:   Application Layer   32
  http message format: response
  status line
 status code        HTTP/1.0 200 OK
status phrase)      Date: Thu, 06 Aug 1998 12:00:15 GMT
                    Server: Apache/1.3.0 (Unix)
                    Last-Modified: Mon, 22 Jun 1998 …...
                    Content-Length: 6821
                    Content-Type: text/html

                    data data data data data ...
data, e.g.,
 html file

                    CSci4211:   Application Layer   33
        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
                        CSci4211:   Application Layer               34
 Trying out http (client side) for yourself

1. Telnet to your favorite Web server:
 telnet www.eurecom.fr 80 Opens TCP connection to port 80
                          (default http server port) at www.eurecom.fr.
                          Anything typed in sent
                          to port 80 at www.eurecom.fr

2. Type in a GET http request:
  GET /~ross/index.html HTTP/1.0         By typing this in (hit carriage
                                         return twice), you send
                                         this minimal (but complete)
                                         GET request to http server

3. Look at response message sent by http server!

                       CSci4211:   Application Layer                       35
      Web and HTTP Summary
Transaction-oriented (request/reply), use TCP, port 80

  Client                                            Server

GET /index.html HTTP/1.0             HTTP/1.0
                                     200 Document follows
                                     Content-type: text/html
                                     Content-length: 2090
                                           -- blank line --
                                     HTML text of the Web page
                    CSci4211:   Application Layer            36
      User-server interaction: authentication

                                             client                       server
   Authentication goal: control
     access to server documents                      usual http request msg
   • stateless: client must present                  401: authorization req.
     authorization in each request                   WWW authenticate:
   • authorization: typically name,
        – authorization: header line                 usual http request msg
          in request                                 + Authorization:line
        – if no authorization                       usual http response msg
          presented, server refuses
          access, sends
            WWW authenticate:
                                                     usual http request msg
            header line in response                  + Authorization:line
Browser caches name & password so                                              time
                                                    usual http response msg
that user does not have to repeatedly enter it.

                                CSci4211:   Application Layer                  37
        User-server interaction: cookies
• server sends “cookie” to       client                         server
  client in response mst               usual http request msg
   Set-cookie: 1678453
                                        usual http response +
• client presents cookie in               Set-cookie: #
  later requests
   cookie: 1678453
                                       usual http request msg
• server matches                              cookie: #           cookie-
  presented-cookie with                                          speccific
  server-stored info                  usual http response msg      action
   – authentication
   – remembering user                  usual http request msg
     preferences, previous                                        cookie-
                                              cookie: #
     choices                                                      specific
                                      usual http response msg      action

                         CSci4211:   Application Layer               38
              Electronic Mail
                                                                  message queue
                                                                   user mailbox
Three major components:                               user
• user agents
• mail servers                          server
• simple mail transfer
  protocol: smtp                                      SMTP      mail
                                                               server      user
User Agent                     SMTP                                       agent
• a.k.a. “mail reader”
• composing, editing, reading                          SMTP
  mail messages                   mail                                   user
• e.g., Eudora, Outlook, pine,

  Netscape Messenger                                    user
• outgoing, incoming messages                          agent
  stored on server                 user
                     CSci4211:   Application Layer                          39
   Electronic Mail: mail servers
Mail Servers                                            agent
• mailbox contains incoming                     mail
  messages (yet to be read)                    server
  for user                                               SMTP
• message queue of outgoing                                        mail
                                                                  server      user
  (to be sent) mail messages                                                 agent
• smtp protocol between mail
  servers to send email                                   SMTP
  messages                                      mail                        user
   – client: sending mail server               server

   – “server”: receiving mail
     server                                               agent

                      CSci4211:    Application Layer                        40
    Electronic Mail:SMTP [RFC 821]

• uses tcp to reliably transfer email msg 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

                     CSci4211:   Application Layer         41
        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
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
S:   221 hamburger.edu closing connection

                  CSci4211:   Application Layer   42
    Try SMTP interaction yourself

• telnet servername 25
• see 220 reply from server
above lets you send email without using email client

                 CSci4211:   Application Layer    43
              SMTP: final words
• smtp uses persistent              Comparison with http
• smtp requires that                • http: pull
  message (header & body)           • email: push
  be in 7-bit ascii
• certain character strings         • both have ASCII
  are not permitted in                command/response
  message (e.g., CRLF.CRLF).          interaction, status codes
  Thus message has to be            • http: each object is
  encoded (usually into either        encapsulated in its own
  base-64 or quoted                   response message
                                    • smtp: multiple objects
• smtp server uses                    message sent in a multipart
  CRLF.CRLF to determine              message
  end of message

                     CSci4211:   Application Layer                44
                Mail message format

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

                      CSci4211:    Application Layer            45
   Message format: multimedia extensions
• MIME: multimedia mail extension, RFC 2045, 2056
• additional lines in msg header declare MIME content

                                    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

                        CSci4211:      Application Layer          46
                    MIME types
   Content-Type: type/subtype; parameters
• example subtypes: plain,        Video
  html                            • example subtypes: mpeg,
• example subtypes: jpeg,
  gif                             Application
                                  • other data that must be
Audio                               processed by reader
                                    before “viewable”
• example subtypes: basic
  (8-bit mu-law encoded),         • example subtypes:
  32kadpcm (32 kbps                 msword, octet-stream

                   CSci4211:   Application Layer              47
                  Multipart Type
From: alice@crepes.fr
To: bob@hamburger.edu
Subject: Picture of yummy crepe.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=98766789

Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain

Dear Bob,
Please find a picture of a crepe.
Content-Transfer-Encoding: base64
Content-Type: image/jpeg

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

                  CSci4211:   Application Layer    48
            Mail access protocols
                 SMTP              SMTP                   POP3 or    user
         agent                                             IMAP     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.

                          CSci4211:   Application Layer                     49
      POP3 protocol                     S:
                                              +OK POP3 server ready
                                              user alice
                                        S:    +OK
authorization phase                     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
   – +OK                                  S:    .
   – -ERR                                 C:    retr 1
                                          S:    <message 1 contents>
transaction phase,                        S:    .
client:                                   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
                      CSci4211:   Application Layer                    50
              Email Summary
          Message       SMTP                           transfer
          user agent
                         outgoing mail queue

                                                over TCP
                                                (RFC 821)

        POP3 (RFC 1225)/ IMAP (RFC 1064)                             server
                                                       port 25
        for accessing mail
 Bob                                                      Message
            Message                                       transfer
            user agent
                            user mailbox

                       CSci4211:   Application Layer                          51
          Application Layer
•   World Wide Web
•   Electronic Mail
•   Domain Name System
•   P2P File Sharing

Readings: Chapter 2: section 2.1-2.6

              CSci4211:   Application Layer   52
Internet: Naming and Addressing
• Names, addresses and routes:
   According to Shoch (1979)
   – name: identifies what you want
   – address: identifies where it is
   – route: identifies a way to get there
• Internet names and addresses
                 Example                            Organization
 MAC address                                        flat, permanent
 IP address                      2-level
 Host name       afer.cs.umn.edu                    hierarchical

                    CSci4211:   Application Layer                     53
                  IP addresses
• Two-level hierarchy: network id. + host id.
      • (or rather 3-level, subnetwork id.)
   – 32 bits long usually written in dotted decimal notation
• No two hosts have the same IP address
       • host’s IP address may change, e.g., dial-in hosts
   – a host may have multiple IP addresses
   – IP address identifies host interface
• Mapping of IP address to MAC (physical) IP done
  using IP ARP (this is called address resolution)
       • one-to-one mapping
• Mapping between IP address and host name done
  using Domain Name Servers (DNS)
       •   many-to-many mapping

                      CSci4211:   Application Layer            54
          Internet Domain Names
• Hierarchical: anywhere                                     . (root)
  from two to possibly
• Examples:                                     . com        . edu
                                                                           . uk
   –   edu, de: organization type
     or country (a “domain”)                                  umn.edu
   – umn, fokus: organization
     administering the “sub-
     domain”                                             cs.umn.edu
   – cs, fokus: organization
     administering the host
   – afer, lupus: host name (have
       IP address)

                         CSci4211:   Application Layer                             55
   Domain Name Resolution and DNS
DNS: Domain Name System:                  • hierarchy of redundant
• distributed database                      servers with time-limited
  implemented in hierarchy of
  many name servers                       • 13 root servers, each
                                            knowing the global top-level
• application-layer protocol host,          domains (e.g., edu, gov, com)
  routers, name servers to                  , refer queries to them
  communicate to resolve names            • each server knows the 13
  (address/name translation)                root servers
   – note: core Internet function         • each domain has at least 2
     implemented as application-layer       servers (often widely
     protocol                               distributed) for fault
   – complexity at network’s “edge”         distributed
                                          • DNS has info about other
                                            resources, e.g., mail servers

                        CSci4211:   Application Layer                56
                 DNS name servers
Why not centralize DNS?           • no server has all name-
• single point of failure            to-IP address mappings
• traffic volume                  local name servers:
                                         – each ISP, company has local
• distant centralized                        (default) name server
  database                               – host DNS query first goes to
                                           local name server
• maintenance
                                  authoritative name server:
                                         – for a host: stores that host’s
doesn’t scale!                             IP address, name
                                         – can perform name/address
                                           translation for that host’s

                    CSci4211:   Application Layer                    57
         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
• ~ dozen root name
  servers worldwide

                      CSci4211:   Application Layer   58
Simple DNS example                              root name server

                                            2               4
host homeboy.aol.com                             5      3
   wants IP address of
1. Contacts its local DNS
    server, dns.aol.com     local name server authorititive name server
2. dns.aol.com contacts         dns.aol.com         dns.umn.edu
    root name server, if           1    6
3. root name server contacts
    authoritative name server,
    dns.umn.edu, if            requesting host   afer.cs.umn.com
    necessary                homeboy.aol.com

                      CSci4211:   Application Layer                59
                                                        root name server

                  DNS example
Root name server:                                   2                   6
• may not know                                             7    3
  authoritative name
• may know
  intermediate name                local name server intermediate name server
  server: who to                     dns.aol.com                 dns.umn.edu.
  contact to find                                                   4       5
                                            1       8
  authoritative name
                                                           authoritative name server
                                   requesting host

                       CSci4211:       Application Layer                        60
DNS: iterated queries                                 root name server

recursive query:                                  2
                                                                   iterated query
• puts burden of name                                    3
  resolution on                                              4
  contacted name
  server                                                     7
• heavy load?                    local name server intermediate name server
                                   dns.aol.com                     dns.umn.edu
iterated query:                                                     5    6
                                          1       8
• contacted server
  replies with name of
                                                         authoritative name server
  server to contact                                               dns.cs.umn.edu
• “I don’t know this             requesting host
  name, but ask this         homeboy.aol.com
                     CSci4211:       Application Layer                           61
DNS: caching and updating records
• once (any) name server learns mapping, it caches
   – cache entries timeout (disappear) after some time
• update/notify mechanisms under design by IETF
   – RFC 2136
   – http://www.ietf.org/html.charters/dnsind-charter.html

                      CSci4211:   Application Layer          62
                     DNS records
DNS: distributed db storing resource records (RR)
           RR format: (name,        value, type,ttl)

• Type=A                              • Type=CNAME
  – name is hostname                        – name is an alias name for
  – value is IP address                       some “canonical” (the real)
• Type=NS                                   – value is canonical name
    – name is domain (e.g.
    – value is IP address of          • Type=MX
      authoritative name server
                                            – value is hostname of mailserver
      for this domain
                                              associated with name

                      CSci4211:   Application Layer                    63
             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

                          CSci4211:   Application Layer   64
            DNS protocol, messages

    Name, type fields
         for a query

       RRs in reponse
             to query

         records for
authoritative servers

   additional “helpful”
info that may be used

                          CSci4211:   Application Layer   65
            DNS Protocol

• Query/Reply: use UDP

• Transfer of DNS Records between
  authoritative and replicated servers:
  use TCP

              CSci4211:   Application Layer   66
                    P2P File Sharing

Example                           • Alice chooses one of the
                                     peers, Bob.
• Alice runs P2P client
                                  • File is copied from Bob’s PC
  application on her notebook
                                     to Alice’s notebook: HTTP
                                  • While Alice downloads,
• Intermittently connects to
                                     other users uploading from
  Internet; gets new IP
  address for each
  connection                      • Alice’s peer is both a Web
                                     client and a transient Web
• Asks for “Hey Jude”
• Application displays other
                                  All peers are servers = highly
  peers that have copy of
  Hey Jude.

                      CSci4211:   Application Layer                67
   P2P: Centralized Directory

original “Napster” design          centralized
                                directory server
1) when peer connects, it                                                  peers
   informs central server:                                 1
   – IP address
   – content                                               1           3

2) Alice queries for “Hey                          2   1
3) Alice requests file from

                   CSci4211:   Application Layer                             68
P2P: problems with centralized directory

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

                  CSci4211:   Application Layer               69
• Files are shared by many users (as chunks:
  around 256KB)
• Active participation: peers download and
  upload chunks
• A torrent is a group of peers that contain
  chunks of a file.
• Each torrent has a tracker that keeps
  track of participating peers

               CSci4211:   Application Layer   70
    Torrent Setup





            CSci4211:        Application Layer                71
               Trading chunks
• What does Alice know?
  – Subset of chunks she have.
  – Which chunks her neighbors have.
• Which chunks she requests first form
  – Use rarest first (chunks with least repeated copies).
• Which requests should Alice respond to?
  – Priority is given to neighbors supplying her data at the
    highest rate.
  – Utilize unchoked and optimistically unchocked peers.
  – Tit-for-tat
                    CSci4211:   Application Layer              72
        Query Flooding: Gnutella
                                  overlay network: graph
• fully distributed               • edge between peer X
   – no central server              and Y if there’s a TCP
• public domain protocol            connection
• many Gnutella clients           • all active peers and
  implementing protocol             edges is overlay net
                                  • Edge is not a physical
                                  • Given peer will
                                    typically be connected
                                    with < 10 overlay

                     CSci4211:   Application Layer           73
                Gnutella: protocol
                                                           File transfer:
 Query message
sent over existing TCP
connections                                                Query

 peers forward                                            QueryHit
Query message
 QueryHit
sent over
reverse                              Query
path                             QueryHit

limited scope
                         CSci4211:     Application Layer                    74
         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
4.   All peers receiving Ping message respond with
     Pong message
5.   X receives many Pong messages. It can then
     setup additional TCP connections

                  CSci4211:   Application Layer       75
 Distributed Hash Table (DHT)
• DHT = distributed P2P database
• Database has (key, value) pairs;
  – key: ss number; value: human name
  – key: content type; value: IP address
• Peers query DB with key
  – DB returns values that match the key
• Peers can also insert (key, value) peers
               DHT Identifiers
• Assign integer identifier to each peer in range
  – Each identifier can be represented by n bits.
• Require each key to be an integer in same range.
• To get integer keys, hash original key.
  – eg, key = h(“Led Zeppelin IV”)
  – This is why they call it a distributed “hash” table
  How to assign keys to peers?
• Central issue:
  – Assigning (key, value) pairs to peers.
• Rule: assign key to the peer that has the
  closest ID.
• Convention in lecture: closest is the
  immediate successor of the key.
• Ex: n=4; peers: 1,3,4,5,8,10,12,14;
  – key = 13, then successor peer = 14
  – key = 15, then successor peer = 1
           Circular DHT (1)


• Each peer only aware of immediate successor
  and predecessor.
• “Overlay network”
                           Circle DHT (2)

O(N) messages                                   0001               Who’s resp
on avg to resolve                                                  for key 1110 ?
query, when there          I am
are N peers                                               0011

                           1110                                      0100

                                                   1110            0101
Define closest                           1110

as closest                  1010
successor                                        1000
    Circular DHT with Shortcuts
                              1            Who’s resp
                                           for key 1110?

• Each peer keeps track of IP addresses of predecessor,
  successor, short cuts.
• Reduced from 6 to 2 messages.
• Possible to design shortcuts so O(log N) neighbors, O(log
  N) messages in query
                Peer Churn
                          •To handle peer churn, require
                  3       each peer to know the IP address
15                        of its two successors.
                          • Each peer periodically pings its
                      4   two successors to see if they
                          are still alive.
• Peer 5 abruptly leaves
• Peer 4 detects; makes 8 its immediate successor;
  asks 8 who its immediate successor is; makes 8’s
  immediate successor its second successor.
• What if peer 13 wants to join?
         P2P Case study: Skype
                                        Skype clients (SC)
• inherently P2P: pairs
  of users communicate.
• proprietary              Skype
  application-layer      login server           Supernode
  protocol (inferred via                        (SN)
  reverse engineering)
• hierarchical overlay
  with SNs
• Index maps usernames
  to IP addresses;
  distributed over SNs

                                           2: Application Layer
                  Peers as relays
• Problem when both
  Alice and Bob are
  behind “NATs”.
   – NAT prevents an outside
     peer from initiating a call
     to insider peer
• Solution:
   – Using Alice’s and Bob’s
     SNs, Relay is chosen
   – Each peer initiates
     session with relay.
   – Peers can now
     communicate through
     NATs via relay
                                    2: Application Layer
  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
  children.                                             ordinary peer

                                                        group-leader peer

                                                        neighoring relationships
                                                           in overlay network

                       CSci4211:    Application Layer                              85
             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

                    CSci4211:   Application Layer           86
               KaZaA Tricks
•   Limitations on simultaneous uploads
•   Request queuing
•   Incentive priorities
•   Parallel downloading

For more info:
 J. Liang, R. Kumar, K. Ross, “Understanding KaZaA,”
(available via cis.poly.edu/~ross)

                  CSci4211:   Application Layer     87
• Application Service Requirements:
   –   reliability, bandwidth, delay
• Client-server vs. Peer-to-Peer Paradigm
• Application Protocols and Their Implementation:
   –   specific formats: header, data;
   –   control vs. data messages
   –   stateful vs. stateless
   –   centralized vs. decentralized
• Specific Protocols:
   – http
   – smtp, pop3
   – dns

                       CSci4211:   Application Layer   88

Shared By: