SlideShare une entreprise Scribd logo
1  sur  63
Télécharger pour lire hors ligne
Application
                  Layer
                                     Raj Jain
               Washington University in Saint Louis
                      Saint Louis, MO 63130
                          Jain@wustl.edu
   Audio/Video recordings of this lecture are available on-line at:
           http://www.cse.wustl.edu/~jain/cse473-10/
Washington University in St. Louis     CSE473S              ©2010 Raj Jain
                                       2-1
Overview

1.      Network Application Architecture
2.      HyperText Transfer Protocol (HTTP)
3.      File Transfer and Email protocols
4.      Domain Name Service
5.      Peer-to-Peer Applications

Note: This class lecture is based on Chapter 2 of the textbook
   (Kurose and Ross) and the figures provided by the authors.
Washington University in St. Louis     CSE473S           ©2010 Raj Jain
                                        2-2
Overview
                   Network Application Architectures
1.      Protocol Layers
2.      Client-Server vs. Peer-to-Peer
3.      Process Communication
4.      Names, Addresses, Ports
5.      Transports




Washington University in St. Louis   CSE473S   ©2010 Raj Jain
                                     2-3
Protocol Layers
    Top-Down approach
        Application                  HTTP     FTP SMTP P2P DNS Skype

          Transport                                 TCP                      UDP

       Internetwork                                          IP

           Host to
                                      Ethernet          Point-to-Point      Wi-Fi
           Network

           Physical                    Coax              Fiber           Wireless



Washington University in St. Louis            CSE473S                          ©2010 Raj Jain
                                              2-4
Network Application Architectures
 Client-Server
 Peer-to-Peer




Washington University in St. Louis   CSE473S   ©2010 Raj Jain
                                     2-5
Client-Server
 Clients: Request service
 Server: Provides a service.
  Waits for clients
 Server is always up
 Clients do not communicate
  directly with each other    client/server
 Server = Data Center
 Example: Web Server, Search
  Engine, Social Networking

Washington University in St. Louis        CSE473S    ©2010 Raj Jain
                                          2-6
Peer-to-Peer
    Does not require always-on servers
    Hosts communicate directly
      Peers
    Hosts may come on or may go off
     at any time
    Examples: File Sharing (Bit
     Torrent, eMule, LimeWire),
     Telephony (Skype)
    Highly scalable
    Highly symmetric traffic
      ISP unfriendly
    Difficult to authenticate  Insecure
    Need incentives to share
Washington University in St. Louis       CSE473S    ©2010 Raj Jain
                                          2-7
Process Communications
    Inter-Process Communication on the Same Host
     Operating system provides message passing
    Unix provides application programming interface
     called “sockets”
    Inter-Process Communication on Different Hosts
      Network provides message passing

                    Host                                  Host
                                      controlled by
        User                process   app developer process
                             socket                 socket
Operating                   TCP/IP      Internet     TCP/IP
System
Washington University in St. Louis         CSE473S               ©2010 Raj Jain
                                           2-8
Names, Addresses, Ports
    Domain Name System: www.google.com
    IP Address: 209.85.225.147
    4 decimal numbers less than 256=8 bits each
      32-bits
    Ports: Entry point (Transport service access points)
    21=FTP, 80=HTTP



         Port 1


                                                            Port 2
Washington University in St. Louis   CSE473S                   ©2010 Raj Jain
                                     2-9
Transports
                TCP                                       UDP
  Reliable data transfer                    Unreliable Data Transfer
  Packet Sequence # required                Sequence # optional
  Every packet is acked                     Not Acked
  Lost packets are retransmitted            No Retransmission
  May cause long delay                      Quick and Lossy
  Connection-oriented service               Connection-less Service
  Good for Reliable and delay-              Good for loss-tolerant and
  insenstive applications                   delay sensitive applications
  Applications: email, http, ftp,           Telephony, Streaming
  Remote terminal access                    Multimedia



Washington University in St. Louis      CSE473S                     ©2010 Raj Jain
                                         2-10
Application Layer Protocols
 HTTP: HyperText Transfer Protocol
 FTP: File Transfer Protocol
 SMTP: Simple Mail Transfer Protocol
 DNS: Domain Name Server
  (Control Plane Application)
 P2P: Peer-to-Peer Applications
 Skype
 Each application has its own protocol, message
  format, semantics of fields

Washington University in St. Louis   CSE473S       ©2010 Raj Jain
                                     2-11
Application Arch: Summary

1. P2P applications are more scalable than client-server
2. Applications exchanges messages using operating
   system sockets
3. Applications communicate using host names,
   addresses, and ports
4. Applications use transports: TCP, UDP, …
5. TCP is used for reliable communication
   UDP for loss-tolerant delay-sensitive applications


Washington University in St. Louis        CSE473S        ©2010 Raj Jain
                                          2-12
Overview
                                     HTTP
1.      Concepts
2.      Sample Web Page
3.      HTTP Messages
4.      Cookies
5.      Proxy Servers
6.      Conditional GET




Washington University in St. Louis    CSE473S   ©2010 Raj Jain
                                      2-13
HTTP Concepts
    Client=Browser, e.g., Internet
     Explorer, Firefox
                                             HT
    HTTP Server, e.g., Microsoft                TP
                                            HT       req
     Internet Information Service PC running TP           ue s
                                                   res         t
     (IIS), Apache                 Explorer            p on
                                                            se
    Web Page=Group of objects
                                                        u e st
    Object=Text, Images, files, ...
                                                  P req onseServer
    URL: Uniform Resource                   H TT resp           running
                                                    P
     Locator                                   H TT            Apache Web
                                                                 server
     http://www.cse.wustl.edu/
     ~jain/cse473-09/sample.htm Mac running
                                                 Navigator

Washington University in St. Louis        CSE473S              ©2010 Raj Jain
                                          2-14
HTTP
 Uses TCP
 Stateless: Server does not remember previous history
 Non-Persistent: Open new TCP connection, get one
  object, close
 Persistent: Open one TCP connection, get all objects,
  close
  Server leaves the connection open after sending an
  object and closes on timeout
 Web pages are written in HyperText Markup
  Language (HTML)
Washington University in St. Louis    CSE473S    ©2010 Raj Jain
                                      2-15
Sample Web Page
<HTML>
<HEAD>
</HEAD>
                                                     Raj Jain
<BODY>
<img src=jain.jpg>
<BR>
Raj Jain
</BODY>
</HTML>

Washington University in St. Louis         CSE473S              ©2010 Raj Jain
                                           2-16
Sample HTTP Request Message
GET /~jain/cse473-09/sample.htm HTTP/1.1
Host: www.cse.wustl.edu
Connection: close
User-agent: Mozilla/4.0
Accept-Language: en

 Method = Get
 URL = /~jain/cse473-09/sample.htm
 Version = HTTP/1.1
 Header Fields = Host, Connection, User-agent, …

Washington University in St. Louis   CSE473S   ©2010 Raj Jain
                                     2-17
HTTP Request Message Format




Washington University in St. Louis   CSE473S   ©2010 Raj Jain
                                     2-18
Sample HTTP Response Message
HTTP/1.1 200 OK
Connection: close
Date: Tue, 09 Sept 2009 13:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Sun, 6 May 2009 09:23:24 GMT
                               Status Codes:
Content-Length: 6500
                                   200 OK
Content-Type: Text/html
                                                  301 Moved
                                                   Permanently
Data…                                             400 Bad Request
                                                  404 Not Found
                                                  505 HTTP Version
                                                   Not Supported
Washington University in St. Louis   CSE473S                   ©2010 Raj Jain
                                     2-19
HTTP Response Message Format
 Status                    Version sp Status code sp Phrase cr lf
 Line
                           Header field Name: sp value cr lf
 Header
 lines
                           Header field Name: sp value cr lf
 Blank                     cr lf
 line
 Entity
 body




Washington University in St. Louis        CSE473S                   ©2010 Raj Jain
                                          2-20
Hands-on HTTP
telnet www.cse.wustl.edu 80
GET /~jain/cse473-10/sample.htm HTTP/1.1
Host: www.cse.wustl.edu
HTTP/1.1 200 OK
Date: Tue, 08 Sep 2009 23:39:53 GMT
Server: Apache/2.0.52 (CentOS)
Last-Modified: Tue, 08 Sep 2009 23:38:26 GMT
ETag: "1e329a-4b-767b2080"
Accept-Ranges: bytes
Content-Length: 75
Connection: close
Content-Type: text/html; charset=UTF-8

<HTML>                                   This is a sample text.
<head>
</head>
<body>
This is a sample text.
</body>
</html>
Washington University in St. Louis          CSE473S               ©2010 Raj Jain
                                             2-21
Hands-on HTTP (cont)
telnet www.cse.wustl.edu 80
GET /~jain/cse473-08/sample.htm HTTP/1.1
Host: www.cse.wustl.edu

HTTP/1.1 404 Not Found
Date: Tue, 08 Sep 2009 23:42:48 GMT
Server: Apache/2.0.52 (CentOS)
Content-Length: 307
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>404 Not Found</title>
</head><body>
<h1>Not Found</h1>
<p>The requested URL /~jain/cse473-08/sample.htm was not found on this server.</p>
<hr>
<address>Apache/2.0.52 (CentOS) Server at www.cse.wustl.edu Port 80</address>
</body></html>

Washington University in St. Louis            CSE473S                                ©2010 Raj Jain
                                              2-22
Cookies
    Allow servers to remember previous information
     c:documents and settingsraj jaincookies
        client                              server
      ebay 8734
                                     usual http request msg
                                                               Amazon server
      cookie file                     usual http response        creates ID
                                      Set-cookie: 1678          1678 for user create
     ebay 8734                                                                   entry
     amazon 1678
                                     usual http request msg
                                        cookie: 1678              cookie-     access
                                                                  specific
one week later:                      usual http response msg       action                backend
                                                                              access     database
     ebay 8734                       usual http request msg
     amazon 1678                         cookie: 1678             cookie-
                                                                  spectific
                                     usual http response msg       action
Washington University in St. Louis                   CSE473S                           ©2010 Raj Jain
                                                     2-23
Proxy Server: Web Caching
    All requests are sent to proxy server
    Proxy server caches objects
    Only new objects are requested from origin server
    Fast, Lower traffic on the link              origin
                                                                                server


                                             HT               Proxy
                                                                               t
                                                 TP
                                                    req server           eq ues
                                           HT
                                     client TP           ues        T Pr        se
                                                 res
                                                             t    HT      es pon
                                                     pon             TPr
                                                         se       HT
                                                        st
                                                     ue
                                                 req        se
                                              TP        p on
                                           HT       res
                                                  P
                                             H TT

                                      client
Washington University in St. Louis                     CSE473S                           ©2010 Raj Jain
                                                       2-24
Conditional GET
               cache                                           server
                               HTTP request msg
                           If-modified-since: <date>
                                                                 object
                                                                  not
                                 HTTP response                  modified
                                   HTTP/1.0
                                304 Not Modified


                               HTTP request msg
                           If-modified-since: <date>
                                                                  object
                                                                 modified
                                     HTTP response
                                HTTP/1.0 200 OK
                                        <data>
Washington University in St. Louis                   CSE473S                ©2010 Raj Jain
                                                     2-25
HTTP: Summary

1. HTTP is a client-server protocol.
   Uses text-based messages
2. Web pages are generally written in HTML
3. HTTP uses non-persistent/persistent TCP
   connections
4. Cookies allow servers to maintain state
5. Proxy servers improve performance by caching
   frequently used pages
6. Conditional gets allows proxy servers to reduce
   Internet traffic
Washington University in St. Louis        CSE473S    ©2010 Raj Jain
                                          2-26
Homework 2A
P5. The text below shows the reply sent from the server in response to the HTTP GET message. Answer
     the following questions, indicating where in the message below you find the answer.
HTTP/1.1 200 OK
Date: Tue, 07 Mar 2010 12:39:45GMT
Server: Apache/2.0.52 (Fedor)
Last-Modified: Sat, 5 Jan 2007 18:27:46 GMT
Etag: “526c3-f22-a88a4c80”
Accept-ranges: bytes
Content-Length: 4060
Keep-Alive: timeout=max=100
Connection: Keep-Alive
Content-Type: text/html; charset=ISO-8859-1

<!doctype html publi “-//w3c//dtd html 4.0 transitional//en”>
    <html>
    <head>
    <much more document text following here (not shown)>

A. Was the server able to successfully find the document or not? What time was the document reply
    provided?
B. When was the document last modified?
C. How many bytes are there in the document being returned?
D. What are the first 5 bytes of the document being returned? Did the server agree to a persistent
    connection?
Washington University in St. Louis                      CSE473S                             ©2010 Raj Jain
                                                         2-27
Overview
                        File Transfer and Electronic Mail
1.     File Transfer Protocol (FTP) Commands and Replies
2.     Simple Mail Transfer Protocol (SMTP)
3.     HTTP vs. SMTP
4.     Mail Access Protocols
        Post-Office Protocol version 3 (POP3) protocol
        Internet Mail Access Protocol (IMAP)




Washington University in St. Louis   CSE473S        ©2010 Raj Jain
                                     2-28
FTP
                            FTP                   file transfer
                                    FTP                            FTP
                            user   client                         server
                         interface
       user
      at host                                                              remote file
                                     local file                            system
                                     system

    File transfer protocol. Uses Port 21
    Uses two parallel TCP connections: Control and Data
    Control is out-of-band
    HTTP uses in-band control
    Control connection is persistent
    Data connections are non-persistent: A new TCP connection is
     opened for each data file
    Stateful: Server keeps track of user name, directory, ...

Washington University in St. Louis                CSE473S                            ©2010 Raj Jain
                                                  2-29
FTP Commands and Replies
 USER username
 PASS password
 LIST
 RETR filename
 STOR filename
 Status:
    331 Username OK, password required

    125 Data connection already open; transfer starting

    425 Con't open data connection

    452 Error writing file

Washington University in St. Louis   CSE473S      ©2010 Raj Jain
                                     2-30
Electronic Mail
                                               user
                                              agent
                                      mail
                                                                          user
                                     server
                                                                         agent
                                               SMTP              mail
                                                                server      user
                                 SMTP                                      agent


                                                SMTP
                                      mail                                user
                                     server                              agent
                                                                                       outgoing
                                                 user                              message queue
                                                agent
             user                                                                  user mailbox
                                       user
                                      agent
Washington University in St. Louis                    CSE473S                             ©2010 Raj Jain
                                                      2-31
SMTP
 Simple Mail Transfer Protocol
 Old Protocol: Allows only 7-bit ASCII messages
 All binary objects have to be converted to ASCII
 Uses port 25 at the server




Washington University in St. Louis    CSE473S    ©2010 Raj Jain
                                      2-32
Sample SMTP Exchange
  S: 220 wustl.edu
  C: HELO acm.org
  S: 250 Hello acm.org, pleased to meet you
  C: MAIL FROM: <jain@acm.org>
  S: 250 jain@acm.org... Sender ok
  C: RCPT TO: <jain@wustl.edu>
  S: 250 jain@wustl.edu ... Recipient ok
  C: DATA
  S: 354 Enter mail, end with "." on a line by itself
  C: This is a test email.
  C: This serves as an example for class.
  C: .
  S: 250 Message accepted for delivery
  C: QUIT
  S: 221 wustl.edu closing connection
  Try the above client sequence by telnet wustl.edu 25
Washington University in St. Louis   CSE473S             ©2010 Raj Jain
                                      2-33
HTTP vs. SMTP

                 HTTP                                  SMTP
     Persistent/Non-Persistent TCP            Persistent TCP
     Mostly Pull                              Mostly Push
     Accepts binary objects                   Accepts only 7-bit ASCII
     One Object/response                      Multiple objects/message




Washington University in St. Louis        CSE473S                   ©2010 Raj Jain
                                          2-34
Mail Access Protocols
    SMTP can be used to send messages to destination user agent
      Requires destination to be always accessible
    Post Office Protocol - Version 3 (POP3)
    Internet Mail Access Protocol (IMAP)
    HTTP


                            SMTP                 SMTP                access     user
                   user
                  agent                                             protocol   agent


                                     sender’s mail    receiver’s mail
                                        server            server



Washington University in St. Louis                   CSE473S                           ©2010 Raj Jain
                                                     2-35
POP3 protocol
                                            S: +OK POP3 server ready
                                            C: user bob
        Authorization phase                 S: +OK
                                            C: pass hungry
                                            S: +OK user successfully logged on
                                           C: list
                                           S: 1 498
                                           S: 2 912
                                           S: .
                                           C: retr 1
                                           S: <message 1 contents>
      Transaction phase                    S: .
                                           C: dele 1
                                           C: retr 2
                                           S: <message 2 contents>
                                           S: .
                                           C: dele 2
                                           C: quit
                                           S: +OK POP3 server signing off
Washington University in St. Louis        CSE473S                           ©2010 Raj Jain
                                          2-36
IMAP
 Internet Mail Access Protocol
 More sophisticated than POP3
 Allows users to maintain folders on the server
 Messages can be moved from one folder to another
 Users can get only headers or other components of the
  message
 Official IMAP site: www.imap.org




Washington University in St. Louis    CSE473S   ©2010 Raj Jain
                                      2-37
FTP and Mail: Summary

1. FTP is a client-server protocol. Uses Port 21.
2. FTP uses two parallel TCP connections for control
   and data
3. SMTP is the protocol send email
4. SMTP uses only 7-bit ASCII messages
5. POP3, IMAP, or HTTP is used to receive email




Washington University in St. Louis   CSE473S    ©2010 Raj Jain
                                     2-38
Homework 2B
P17. Consider accessing your e-mail with POP3.
A.      Suppose you have configured your POP mail client to operate in the download and delete
        mode. Complete the following transaction:
C: list
S: 1 498
S: 2 912
S: .
C: retr 1
S: blah blah …
S: … Blah
S: .
?
?

B. Suppose you have configured your POP mail client to operate in the download and keep mode.
      Complete the above transaction.
C. Suppose you have configured your POP mail client to operate in the download-and-keep mode.
      Using your transcript in part (b), suppose you retrieve messages 1 and 2. Exit POP and then
      five minutes later you again access POP to retrieve new e-mail. Suppose that in the five-
      minute interval no new message have been sent to you. Provide a transcript of this second
      POP session.
Washington University in St. Louis            CSE473S                                 ©2010 Raj Jain
                                              2-39
Domain Name Service
1.      DNS Hierarchy
2.      How DNS Works?
3.      DNS Records
4.      DNS Message Format
5.      DNS Registration
6.      DNS Vulnerability




Washington University in St. Louis   CSE473S       ©2010 Raj Jain
                                     2-40
DNS
 Domain Name Service
 DNS servers translate a host name to IP address
  E.g., www.wustl.edu  128.252.73.216
 Distributed database of all hosts in the universe
 Other Services:
    Host Aliasing: www.rajjain.com or
     www.cse.wustl.edu/~jain/
    Mail Server Aliasing: MX record (e.g.,
     jain@wustl.edu)
    Load Distribution: Multiple addresses, rotated


Washington University in St. Louis   CSE473S    ©2010 Raj Jain
                                     2-41
DNS Hierarchy
                                       Root DNS Servers



       com DNS servers                 org DNS servers     edu DNS servers


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


 Root DNS Servers
 Top-level Domain (TLD) servers
 Authoritative DNS Servers



Washington University in St. Louis           CSE473S                    ©2010 Raj Jain
                                             2-42
How DNS Works?
                                                         root DNS server

 Redirects
 Recursive queries: Give               2
                                           3
  me an answer                                                    TLD DNS server
                                                              4
 Iterative queries: Give
                                                              5
  me an answer or a hint
                          local DNS server
 DNS responses are         Dns.wustl.edu
                                                              7     6
  cached                          1     8

                                                              authoritative DNS server
                                                                 dns.cs.umass.edu
                                          requesting host
                                          www.cse.wustl.edu

                                                                  gaia.cs.umass.edu
Washington University in St. Louis         CSE473S                        ©2010 Raj Jain
                                           2-43
DNS Records
 Resource Records=(Name, Value, Type, TTL)
 Type=A: IP Address for the host name
 Type=NS: Name server for the domain name
 TYPE=CNAME: Canonical name for a host name
 Type=MX: Canonical name of mail server




Washington University in St. Louis       CSE473S   ©2010 Raj Jain
                                         2-44
DNS Message Format
 Questions: Name, type
 Answers: Name, type, value, TTL
 Authority: Other authoritative servers
 Additional: Other information, e.g., IP address of
  canonical name in MX response
                         Identification           Flags
                        # of Questions      # of Answer RRs    12 Bytes
                      # of Authority RRs # of Additional RRs
                                      Questions
                                       Answers
                                      Authority
                               Additional Information
Washington University in St. Louis     CSE473S                 ©2010 Raj Jain
                                        2-45
DNS Registration
 Many Registrars
 Internet Corporation for Assigned Names and
  Numbers (ICANN) accredits registrars
 www.internic.net
 Registrars provide authoritative name servers, A and
  MX records for the domain




Washington University in St. Louis         CSE473S      ©2010 Raj Jain
                                            2-46
DNS Vulnerability
 Distributed Denial of service attack on Name server
 DNS cache poisoning – A server gives wrong answer




Washington University in St. Louis          CSE473S      ©2010 Raj Jain
                                            2-47
DNS: Summary
1. DNS is used to resolve names to IP address
2. Also provides Name aliasing (CNAME), Mail Server
   (MX) records
3. DNS is a distributed database
    Servers ask other servers for answers when
   needed
4. Recursive (answer only) or iterative (answer or hint)
   queries
5. Root Servers, Top level domain servers,
   Authoritative servers

Washington University in St. Louis        CSE473S   ©2010 Raj Jain
                                          2-48
Homework 2C
R19:
 Is it possible for an organization’s web server and
  mail server to have exactly the same hostname?
  (Briefly explain why or why not?)
 What would be the type of RR that contains the host
  name of the mail server?




Washington University in St. Louis       CSE473S   ©2010 Raj Jain
                                         2-49
Overview
                        Peer-to-Peer Applications
1.      Client Server vs. P2P Scalability
2.      P2P File Distribution (BitTorrent)
3.      Distributed Hash Tables (DHTs)
4.      Peer Churn
5.      Network Address Translation (NAT)
6.      Skype




Washington University in St. Louis   CSE473S        ©2010 Raj Jain
                                     2-50
P2P File Distribution (BitTorrent)
         Tracker: tracks peers                     Torrent: group of
         participating in torrent                  peers exchanging
                                                   chunks of a file


    Obtain list
    of peers
                                      trading
                                      chunks


                               peer


Washington University in St. Louis       CSE473S                  ©2010 Raj Jain
                                         2-51
Peer-to-Peer Applications
                                     Server

                                                  u1     d1   u2
                                          us                       d2
                  File, size F

                                     dN
                                                    Network (with
                                     uN             abundant bandwidth)
    N= # of peers
    F= File Size
    ui= uplink speed or ith host
    di= downlink speed of ith host
    dmin=min{d1, d2, ..., dN}
    Dcs > max{ NF/us, F/dmin}
    DP2P > max{F/us, F/dmin, NF/(us+ui)}
Washington University in St. Louis             CSE473S                    ©2010 Raj Jain
                                               2-52
Client Server vs. P2P Scalability
Client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
                                             3.5
                                                       P2P
                 Minimum Distribution Time


                                              3
                                                       Client-Server
                                             2.5

                                              2

                                             1.5

                                              1

                                             0.5

                                              0
                                                   0    5      10       15        20   25   30      35

                                                                              N

Washington University in St. Louis                                     CSE473S                           ©2010 Raj Jain
                                                                                            2: Application Layer     53
                                                                       2-53
BitTorrent P2P File Distribution
    Peers=nodes participating in a
                                               Torrent
     file distribution
                                               Directory       Tracker
    Torrent=Set of all peers
    Torrent File =a file containing                       2
     information about the tracker,             1
     object ID, and file
    Files are segmented into equal            Leecher 1             Seed 1
     size chunks (256kB)                                       3
    Seeds=Peers that have the                   Seed 2            Leecher 2
     complete file
    Leechers=Peers that have
     incomplete file
    Tracker=Has list of all peers             Leecher n             Seed m
Washington University in St. Louis   CSE473S                         ©2010 Raj Jain
                                     2-54
BitTorrent File Distribution (Cont)
1. Alice uses torrent directories (search engines) to find a torrent
   for "Raj Jain's Lecture"
2. Alice contact the tracker to get the current list of peers
   Tracker may provide random subset (say 50) peers
3. Alice sets up TCP connections with these peers in parallel and
   gets a map of available chunks
    Requests least available chunks first (rarest first)
    Every 10 seconds, Alice calculates the receiving rates
    Sends to (Unchokes) the top 4 senders
    Every 30 seconds, Alice sends to one randomly selected peer
     (optimistically unchokes)
      Helps find high-rate neighbors
    Ref: www.bittorrent.org http://en.wikipedia.org/wiki/BitTorrent_(protocol)
Washington University in St. Louis    CSE473S                          ©2010 Raj Jain
                                       2-55
Distributed Hash Tables (DHTs)
    Hash Tables are used to find an entry in a
     table of (key, value) pairs in the database
                                                  Key
    Distributed Hash Tables are used for very
     large databases
    Database is partitioned and stored in many       Hash
     peers
    Hash the key to find the peer that has the key
    Peers are numbered from 0 thru 2n-1 (n-bit)
    Objects (keys) are numbered from 0 thru 2n-1
     (n-bit)
    If some peers are missing, the keys are stored
     at the nearest peer.
    Ref: http://en.wikipedia.org/wiki/Distributed_hash_table

Washington University in St. Louis        CSE473S               ©2010 Raj Jain
                                           2-56
Circular DHT
 Circular  N/2 messages
 Shortcuts  Fewer messages
 Tradeoff between connectivity and # of messages
                                              Who’s resp                     Who’s resp
                           0001                for key                   1   for key 3?
                                                1110?
        I am
                                     0011                                    3
 1111                                                          15
                                       1110

       1110
                                               0100                              4
                                                               12
                                       1110
1100                                                                         5
            1110
                                1110          0101
         1010
                    1110
                                                                    10
                            1000                                         8
Washington University in St. Louis                   CSE473S                 ©2010 Raj Jain
                                                      2-57
Peer Churn
 How to recover when a peer leaves?
 Each peer keeps track of first and second successors
 Periodic handshakes to verify connectivity
 When first successor leaves, connect to the second
  successor
 When a new peer joins, it sends a message to peer 1,
  which gets forwarded until the right predecessor
  responds



Washington University in St. Louis      CSE473S   ©2010 Raj Jain
                                         2-58
Network Address Translation (NAT)
  192.168.0.2             192.168.0.3

                                        128.252.73.216
                                                       Internet
                                     NAT


  192.168.0.4             192.168.0.5
    Private IP addresses 192.168.x.x
    Can be used by anyone inside their networks
    Cannot be used on the public Internet
    NAT overwrites source addresses on all outgoing packets
     and overwrites destination addresses on all incoming packets
    Only outgoing connections are possible
Washington University in St. Louis           CSE473S              ©2010 Raj Jain
                                              2-59
Skype
 P2P telephony
  application
  Sky Peer-to-Peer
   Skyper  Skype
 Super-peers keep an
  index (DHT?) of all
  active Skype users
 Relays are used to
  connect NAT'ed nodes


Washington University in St. Louis    CSE473S   ©2010 Raj Jain
                                      2-60
P2P Applications: Summary

1. P2P applications are more scalable
    More efficient when the number of peers is large
2. BitTorrent has peers, trackers, seeds, and leechers
3. BitTorrent unchokes 4 top uploaders and one random
   node for load balancing
4. Distributed hash tables are used to manage large
   distributed databases used in P2P applications
5. Skype uses super-nodes to keep track of active users
   and provides relays for users behind NATs.

Washington University in St. Louis        CSE473S        ©2010 Raj Jain
                                          2-61
Homework 2D
P26. Suppose Bob joins a BitTorrent torrent, but he does
  not want to upload any data to any other peers (so
  called free-riding).
A. Bob claims that he can receive a complete copy of the
  file that is shared by the swarm. Is Bob’s claim
  possible? Why or Why not?
B. Bob further claims that he can further make his “free-
  riding” more efficient by using a collection of
  multiple computers (with distinct IP addresses) in the
  computer lab in his department. How can he do that?

Washington University in St. Louis       CSE473S   ©2010 Raj Jain
                                         2-62
Application Layer: Summary




1. Applications use TCP/UDP ports for communication
2. HTTP/FTP/SMTP are client-server protocols and use TCP
   connections
3. HTTP is stateless but cookies allows servers to maintain state
4. Proxy servers improve performance by caching
5. BitTorrent is a P2P file distribution protocol and uses trackers
   to keep list of peers

Washington University in St. Louis   CSE473S               ©2010 Raj Jain
                                     2-63

Contenu connexe

Tendances

Lecture application layer
Lecture application layerLecture application layer
Lecture application layer
Hasam Panezai
 
A SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi JinaduA SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi Jinadu
Olaniyi Jinadu
 
Record matching over query results
Record matching over query resultsRecord matching over query results
Record matching over query results
ambitlick
 

Tendances (20)

The HTTP and Web
The HTTP and Web The HTTP and Web
The HTTP and Web
 
Lecture application layer
Lecture application layerLecture application layer
Lecture application layer
 
Application layer in network system
Application layer in network systemApplication layer in network system
Application layer in network system
 
Application layer
Application layerApplication layer
Application layer
 
Jaimin chp-7 - application layer- 2011 batch
Jaimin   chp-7 - application layer- 2011 batchJaimin   chp-7 - application layer- 2011 batch
Jaimin chp-7 - application layer- 2011 batch
 
application layer
application layerapplication layer
application layer
 
Application layer
Application layerApplication layer
Application layer
 
Application layer protocol
Application layer protocolApplication layer protocol
Application layer protocol
 
A SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi JinaduA SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi Jinadu
 
Web technology-guide
Web technology-guideWeb technology-guide
Web technology-guide
 
Record matching over query results
Record matching over query resultsRecord matching over query results
Record matching over query results
 
Email
EmailEmail
Email
 
CCNA 1 Routing and Switching v5.0 Chapter 10
CCNA 1 Routing and Switching v5.0 Chapter 10CCNA 1 Routing and Switching v5.0 Chapter 10
CCNA 1 Routing and Switching v5.0 Chapter 10
 
Email
EmailEmail
Email
 
HTTP & WWW
HTTP & WWWHTTP & WWW
HTTP & WWW
 
Application layer
Application layerApplication layer
Application layer
 
Chapter3
Chapter3Chapter3
Chapter3
 
CS8651 Internet Programming - Basics of HTML, HTML5, CSS
CS8651   Internet Programming - Basics of HTML, HTML5, CSSCS8651   Internet Programming - Basics of HTML, HTML5, CSS
CS8651 Internet Programming - Basics of HTML, HTML5, CSS
 
03 network services
03 network services03 network services
03 network services
 
computer networks layers
computer networks layerscomputer networks layers
computer networks layers
 

Similaire à Application layer jain

Hasanain_Application Layer_Chapter_2_Version 7.1.ppt
Hasanain_Application Layer_Chapter_2_Version 7.1.pptHasanain_Application Layer_Chapter_2_Version 7.1.ppt
Hasanain_Application Layer_Chapter_2_Version 7.1.ppt
nadeemrana0257
 
Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2
Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2
Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2
Raga Yustia
 
applicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.pptapplicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.ppt
DEEPAK948083
 
WCF Data Services - Office Business Application &amp; iPhone
WCF Data Services - Office Business Application &amp; iPhoneWCF Data Services - Office Business Application &amp; iPhone
WCF Data Services - Office Business Application &amp; iPhone
Andri Yadi
 

Similaire à Application layer jain (20)

Server-Side Programming Primer
Server-Side Programming PrimerServer-Side Programming Primer
Server-Side Programming Primer
 
1 web technologies
1 web technologies1 web technologies
1 web technologies
 
CS3001_Computer_Networks_Chapter_2_v8.1(1).pptx
CS3001_Computer_Networks_Chapter_2_v8.1(1).pptxCS3001_Computer_Networks_Chapter_2_v8.1(1).pptx
CS3001_Computer_Networks_Chapter_2_v8.1(1).pptx
 
20CS2008 Computer Networks
20CS2008 Computer Networks 20CS2008 Computer Networks
20CS2008 Computer Networks
 
Hasanain_Application Layer_Chapter_2_Version 7.1.ppt
Hasanain_Application Layer_Chapter_2_Version 7.1.pptHasanain_Application Layer_Chapter_2_Version 7.1.ppt
Hasanain_Application Layer_Chapter_2_Version 7.1.ppt
 
Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2
Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2
Materi Perkuliahan Jaringan Komputer Teknik Informatika Chapter 2
 
Chapter_2_v8.3.pptx
Chapter_2_v8.3.pptxChapter_2_v8.3.pptx
Chapter_2_v8.3.pptx
 
Taking a Quantum Leap with Html 5 WebSocket
Taking a Quantum Leap with Html 5 WebSocketTaking a Quantum Leap with Html 5 WebSocket
Taking a Quantum Leap with Html 5 WebSocket
 
Messaging for Real-time WebApps
Messaging for Real-time WebAppsMessaging for Real-time WebApps
Messaging for Real-time WebApps
 
Chapter2 Application
Chapter2 ApplicationChapter2 Application
Chapter2 Application
 
LAN Extension and Network Virtualization for Cloud Computing using Layer 3 Pr...
LAN Extension and Network Virtualization for Cloud Computing using Layer 3 Pr...LAN Extension and Network Virtualization for Cloud Computing using Layer 3 Pr...
LAN Extension and Network Virtualization for Cloud Computing using Layer 3 Pr...
 
Computer network network edge and network
Computer network network edge and networkComputer network network edge and network
Computer network network edge and network
 
Chapter_2_v8.1.pptx
Chapter_2_v8.1.pptxChapter_2_v8.1.pptx
Chapter_2_v8.1.pptx
 
3rd edition chapter2
3rd edition chapter23rd edition chapter2
3rd edition chapter2
 
applicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.pptapplicationapplicationapplicationapplication.ppt
applicationapplicationapplicationapplication.ppt
 
Http
HttpHttp
Http
 
Introduction to HTTP for 3rd year undergraduate
Introduction to HTTP for 3rd year undergraduateIntroduction to HTTP for 3rd year undergraduate
Introduction to HTTP for 3rd year undergraduate
 
WCF Data Services - Office Business Application &amp; iPhone
WCF Data Services - Office Business Application &amp; iPhoneWCF Data Services - Office Business Application &amp; iPhone
WCF Data Services - Office Business Application &amp; iPhone
 
Hypertext transfer protocol performance analysis in traditional and software ...
Hypertext transfer protocol performance analysis in traditional and software ...Hypertext transfer protocol performance analysis in traditional and software ...
Hypertext transfer protocol performance analysis in traditional and software ...
 
33-network-intro.pdf
33-network-intro.pdf33-network-intro.pdf
33-network-intro.pdf
 

Application layer jain

  • 1. Application Layer Raj Jain Washington University in Saint Louis Saint Louis, MO 63130 Jain@wustl.edu Audio/Video recordings of this lecture are available on-line at: http://www.cse.wustl.edu/~jain/cse473-10/ Washington University in St. Louis CSE473S ©2010 Raj Jain 2-1
  • 2. Overview 1. Network Application Architecture 2. HyperText Transfer Protocol (HTTP) 3. File Transfer and Email protocols 4. Domain Name Service 5. Peer-to-Peer Applications Note: This class lecture is based on Chapter 2 of the textbook (Kurose and Ross) and the figures provided by the authors. Washington University in St. Louis CSE473S ©2010 Raj Jain 2-2
  • 3. Overview Network Application Architectures 1. Protocol Layers 2. Client-Server vs. Peer-to-Peer 3. Process Communication 4. Names, Addresses, Ports 5. Transports Washington University in St. Louis CSE473S ©2010 Raj Jain 2-3
  • 4. Protocol Layers  Top-Down approach Application HTTP FTP SMTP P2P DNS Skype Transport TCP UDP Internetwork IP Host to Ethernet Point-to-Point Wi-Fi Network Physical Coax Fiber Wireless Washington University in St. Louis CSE473S ©2010 Raj Jain 2-4
  • 5. Network Application Architectures  Client-Server  Peer-to-Peer Washington University in St. Louis CSE473S ©2010 Raj Jain 2-5
  • 6. Client-Server  Clients: Request service  Server: Provides a service. Waits for clients  Server is always up  Clients do not communicate directly with each other client/server  Server = Data Center  Example: Web Server, Search Engine, Social Networking Washington University in St. Louis CSE473S ©2010 Raj Jain 2-6
  • 7. Peer-to-Peer  Does not require always-on servers  Hosts communicate directly  Peers  Hosts may come on or may go off at any time  Examples: File Sharing (Bit Torrent, eMule, LimeWire), Telephony (Skype)  Highly scalable  Highly symmetric traffic  ISP unfriendly  Difficult to authenticate  Insecure  Need incentives to share Washington University in St. Louis CSE473S ©2010 Raj Jain 2-7
  • 8. Process Communications  Inter-Process Communication on the Same Host Operating system provides message passing  Unix provides application programming interface called “sockets”  Inter-Process Communication on Different Hosts  Network provides message passing Host Host controlled by User process app developer process socket socket Operating TCP/IP Internet TCP/IP System Washington University in St. Louis CSE473S ©2010 Raj Jain 2-8
  • 9. Names, Addresses, Ports  Domain Name System: www.google.com  IP Address: 209.85.225.147  4 decimal numbers less than 256=8 bits each  32-bits  Ports: Entry point (Transport service access points)  21=FTP, 80=HTTP Port 1 Port 2 Washington University in St. Louis CSE473S ©2010 Raj Jain 2-9
  • 10. Transports TCP UDP Reliable data transfer Unreliable Data Transfer Packet Sequence # required Sequence # optional Every packet is acked Not Acked Lost packets are retransmitted No Retransmission May cause long delay Quick and Lossy Connection-oriented service Connection-less Service Good for Reliable and delay- Good for loss-tolerant and insenstive applications delay sensitive applications Applications: email, http, ftp, Telephony, Streaming Remote terminal access Multimedia Washington University in St. Louis CSE473S ©2010 Raj Jain 2-10
  • 11. Application Layer Protocols  HTTP: HyperText Transfer Protocol  FTP: File Transfer Protocol  SMTP: Simple Mail Transfer Protocol  DNS: Domain Name Server (Control Plane Application)  P2P: Peer-to-Peer Applications  Skype  Each application has its own protocol, message format, semantics of fields Washington University in St. Louis CSE473S ©2010 Raj Jain 2-11
  • 12. Application Arch: Summary 1. P2P applications are more scalable than client-server 2. Applications exchanges messages using operating system sockets 3. Applications communicate using host names, addresses, and ports 4. Applications use transports: TCP, UDP, … 5. TCP is used for reliable communication UDP for loss-tolerant delay-sensitive applications Washington University in St. Louis CSE473S ©2010 Raj Jain 2-12
  • 13. Overview HTTP 1. Concepts 2. Sample Web Page 3. HTTP Messages 4. Cookies 5. Proxy Servers 6. Conditional GET Washington University in St. Louis CSE473S ©2010 Raj Jain 2-13
  • 14. HTTP Concepts  Client=Browser, e.g., Internet Explorer, Firefox HT  HTTP Server, e.g., Microsoft TP HT req Internet Information Service PC running TP ue s res t (IIS), Apache Explorer p on se  Web Page=Group of objects u e st  Object=Text, Images, files, ... P req onseServer  URL: Uniform Resource H TT resp running P Locator H TT Apache Web server http://www.cse.wustl.edu/ ~jain/cse473-09/sample.htm Mac running Navigator Washington University in St. Louis CSE473S ©2010 Raj Jain 2-14
  • 15. HTTP  Uses TCP  Stateless: Server does not remember previous history  Non-Persistent: Open new TCP connection, get one object, close  Persistent: Open one TCP connection, get all objects, close Server leaves the connection open after sending an object and closes on timeout  Web pages are written in HyperText Markup Language (HTML) Washington University in St. Louis CSE473S ©2010 Raj Jain 2-15
  • 16. Sample Web Page <HTML> <HEAD> </HEAD> Raj Jain <BODY> <img src=jain.jpg> <BR> Raj Jain </BODY> </HTML> Washington University in St. Louis CSE473S ©2010 Raj Jain 2-16
  • 17. Sample HTTP Request Message GET /~jain/cse473-09/sample.htm HTTP/1.1 Host: www.cse.wustl.edu Connection: close User-agent: Mozilla/4.0 Accept-Language: en  Method = Get  URL = /~jain/cse473-09/sample.htm  Version = HTTP/1.1  Header Fields = Host, Connection, User-agent, … Washington University in St. Louis CSE473S ©2010 Raj Jain 2-17
  • 18. HTTP Request Message Format Washington University in St. Louis CSE473S ©2010 Raj Jain 2-18
  • 19. Sample HTTP Response Message HTTP/1.1 200 OK Connection: close Date: Tue, 09 Sept 2009 13:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Sun, 6 May 2009 09:23:24 GMT Status Codes: Content-Length: 6500  200 OK Content-Type: Text/html  301 Moved Permanently Data…  400 Bad Request  404 Not Found  505 HTTP Version Not Supported Washington University in St. Louis CSE473S ©2010 Raj Jain 2-19
  • 20. HTTP Response Message Format Status Version sp Status code sp Phrase cr lf Line Header field Name: sp value cr lf Header lines Header field Name: sp value cr lf Blank cr lf line Entity body Washington University in St. Louis CSE473S ©2010 Raj Jain 2-20
  • 21. Hands-on HTTP telnet www.cse.wustl.edu 80 GET /~jain/cse473-10/sample.htm HTTP/1.1 Host: www.cse.wustl.edu HTTP/1.1 200 OK Date: Tue, 08 Sep 2009 23:39:53 GMT Server: Apache/2.0.52 (CentOS) Last-Modified: Tue, 08 Sep 2009 23:38:26 GMT ETag: "1e329a-4b-767b2080" Accept-Ranges: bytes Content-Length: 75 Connection: close Content-Type: text/html; charset=UTF-8 <HTML> This is a sample text. <head> </head> <body> This is a sample text. </body> </html> Washington University in St. Louis CSE473S ©2010 Raj Jain 2-21
  • 22. Hands-on HTTP (cont) telnet www.cse.wustl.edu 80 GET /~jain/cse473-08/sample.htm HTTP/1.1 Host: www.cse.wustl.edu HTTP/1.1 404 Not Found Date: Tue, 08 Sep 2009 23:42:48 GMT Server: Apache/2.0.52 (CentOS) Content-Length: 307 Connection: close Content-Type: text/html; charset=iso-8859-1 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> <html><head> <title>404 Not Found</title> </head><body> <h1>Not Found</h1> <p>The requested URL /~jain/cse473-08/sample.htm was not found on this server.</p> <hr> <address>Apache/2.0.52 (CentOS) Server at www.cse.wustl.edu Port 80</address> </body></html> Washington University in St. Louis CSE473S ©2010 Raj Jain 2-22
  • 23. Cookies  Allow servers to remember previous information c:documents and settingsraj jaincookies client server ebay 8734 usual http request msg Amazon server cookie file usual http response creates ID Set-cookie: 1678 1678 for user create ebay 8734 entry amazon 1678 usual http request msg cookie: 1678 cookie- access specific one week later: usual http response msg action backend access database ebay 8734 usual http request msg amazon 1678 cookie: 1678 cookie- spectific usual http response msg action Washington University in St. Louis CSE473S ©2010 Raj Jain 2-23
  • 24. Proxy Server: Web Caching  All requests are sent to proxy server  Proxy server caches objects  Only new objects are requested from origin server  Fast, Lower traffic on the link origin server HT Proxy t TP req server eq ues HT client TP ues T Pr se res t HT es pon pon TPr se HT st ue req se TP p on HT res P H TT client Washington University in St. Louis CSE473S ©2010 Raj Jain 2-24
  • 25. Conditional GET cache server HTTP request msg If-modified-since: <date> object not HTTP response modified HTTP/1.0 304 Not Modified HTTP request msg If-modified-since: <date> object modified HTTP response HTTP/1.0 200 OK <data> Washington University in St. Louis CSE473S ©2010 Raj Jain 2-25
  • 26. HTTP: Summary 1. HTTP is a client-server protocol. Uses text-based messages 2. Web pages are generally written in HTML 3. HTTP uses non-persistent/persistent TCP connections 4. Cookies allow servers to maintain state 5. Proxy servers improve performance by caching frequently used pages 6. Conditional gets allows proxy servers to reduce Internet traffic Washington University in St. Louis CSE473S ©2010 Raj Jain 2-26
  • 27. Homework 2A P5. The text below shows the reply sent from the server in response to the HTTP GET message. Answer the following questions, indicating where in the message below you find the answer. HTTP/1.1 200 OK Date: Tue, 07 Mar 2010 12:39:45GMT Server: Apache/2.0.52 (Fedor) Last-Modified: Sat, 5 Jan 2007 18:27:46 GMT Etag: “526c3-f22-a88a4c80” Accept-ranges: bytes Content-Length: 4060 Keep-Alive: timeout=max=100 Connection: Keep-Alive Content-Type: text/html; charset=ISO-8859-1 <!doctype html publi “-//w3c//dtd html 4.0 transitional//en”> <html> <head> <much more document text following here (not shown)> A. Was the server able to successfully find the document or not? What time was the document reply provided? B. When was the document last modified? C. How many bytes are there in the document being returned? D. What are the first 5 bytes of the document being returned? Did the server agree to a persistent connection? Washington University in St. Louis CSE473S ©2010 Raj Jain 2-27
  • 28. Overview File Transfer and Electronic Mail 1. File Transfer Protocol (FTP) Commands and Replies 2. Simple Mail Transfer Protocol (SMTP) 3. HTTP vs. SMTP 4. Mail Access Protocols  Post-Office Protocol version 3 (POP3) protocol  Internet Mail Access Protocol (IMAP) Washington University in St. Louis CSE473S ©2010 Raj Jain 2-28
  • 29. FTP FTP file transfer FTP FTP user client server interface user at host remote file local file system system  File transfer protocol. Uses Port 21  Uses two parallel TCP connections: Control and Data  Control is out-of-band  HTTP uses in-band control  Control connection is persistent  Data connections are non-persistent: A new TCP connection is opened for each data file  Stateful: Server keeps track of user name, directory, ... Washington University in St. Louis CSE473S ©2010 Raj Jain 2-29
  • 30. FTP Commands and Replies  USER username  PASS password  LIST  RETR filename  STOR filename  Status:  331 Username OK, password required  125 Data connection already open; transfer starting  425 Con't open data connection  452 Error writing file Washington University in St. Louis CSE473S ©2010 Raj Jain 2-30
  • 31. Electronic Mail user agent mail user server agent SMTP mail server user SMTP agent SMTP mail user server agent outgoing user message queue agent user user mailbox user agent Washington University in St. Louis CSE473S ©2010 Raj Jain 2-31
  • 32. SMTP  Simple Mail Transfer Protocol  Old Protocol: Allows only 7-bit ASCII messages  All binary objects have to be converted to ASCII  Uses port 25 at the server Washington University in St. Louis CSE473S ©2010 Raj Jain 2-32
  • 33. Sample SMTP Exchange S: 220 wustl.edu C: HELO acm.org S: 250 Hello acm.org, pleased to meet you C: MAIL FROM: <jain@acm.org> S: 250 jain@acm.org... Sender ok C: RCPT TO: <jain@wustl.edu> S: 250 jain@wustl.edu ... Recipient ok C: DATA S: 354 Enter mail, end with "." on a line by itself C: This is a test email. C: This serves as an example for class. C: . S: 250 Message accepted for delivery C: QUIT S: 221 wustl.edu closing connection Try the above client sequence by telnet wustl.edu 25 Washington University in St. Louis CSE473S ©2010 Raj Jain 2-33
  • 34. HTTP vs. SMTP HTTP SMTP Persistent/Non-Persistent TCP Persistent TCP Mostly Pull Mostly Push Accepts binary objects Accepts only 7-bit ASCII One Object/response Multiple objects/message Washington University in St. Louis CSE473S ©2010 Raj Jain 2-34
  • 35. Mail Access Protocols  SMTP can be used to send messages to destination user agent  Requires destination to be always accessible  Post Office Protocol - Version 3 (POP3)  Internet Mail Access Protocol (IMAP)  HTTP SMTP SMTP access user user agent protocol agent sender’s mail receiver’s mail server server Washington University in St. Louis CSE473S ©2010 Raj Jain 2-35
  • 36. POP3 protocol S: +OK POP3 server ready C: user bob Authorization phase S: +OK C: pass hungry S: +OK user successfully logged on C: list S: 1 498 S: 2 912 S: . C: retr 1 S: <message 1 contents> Transaction phase S: . C: dele 1 C: retr 2 S: <message 2 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off Washington University in St. Louis CSE473S ©2010 Raj Jain 2-36
  • 37. IMAP  Internet Mail Access Protocol  More sophisticated than POP3  Allows users to maintain folders on the server  Messages can be moved from one folder to another  Users can get only headers or other components of the message  Official IMAP site: www.imap.org Washington University in St. Louis CSE473S ©2010 Raj Jain 2-37
  • 38. FTP and Mail: Summary 1. FTP is a client-server protocol. Uses Port 21. 2. FTP uses two parallel TCP connections for control and data 3. SMTP is the protocol send email 4. SMTP uses only 7-bit ASCII messages 5. POP3, IMAP, or HTTP is used to receive email Washington University in St. Louis CSE473S ©2010 Raj Jain 2-38
  • 39. Homework 2B P17. Consider accessing your e-mail with POP3. A. Suppose you have configured your POP mail client to operate in the download and delete mode. Complete the following transaction: C: list S: 1 498 S: 2 912 S: . C: retr 1 S: blah blah … S: … Blah S: . ? ? B. Suppose you have configured your POP mail client to operate in the download and keep mode. Complete the above transaction. C. Suppose you have configured your POP mail client to operate in the download-and-keep mode. Using your transcript in part (b), suppose you retrieve messages 1 and 2. Exit POP and then five minutes later you again access POP to retrieve new e-mail. Suppose that in the five- minute interval no new message have been sent to you. Provide a transcript of this second POP session. Washington University in St. Louis CSE473S ©2010 Raj Jain 2-39
  • 40. Domain Name Service 1. DNS Hierarchy 2. How DNS Works? 3. DNS Records 4. DNS Message Format 5. DNS Registration 6. DNS Vulnerability Washington University in St. Louis CSE473S ©2010 Raj Jain 2-40
  • 41. DNS  Domain Name Service  DNS servers translate a host name to IP address E.g., www.wustl.edu  128.252.73.216  Distributed database of all hosts in the universe  Other Services:  Host Aliasing: www.rajjain.com or www.cse.wustl.edu/~jain/  Mail Server Aliasing: MX record (e.g., jain@wustl.edu)  Load Distribution: Multiple addresses, rotated Washington University in St. Louis CSE473S ©2010 Raj Jain 2-41
  • 42. DNS Hierarchy Root DNS Servers com DNS servers org DNS servers edu DNS servers pbs.org poly.edu umass.edu yahoo.com amazon.com DNS servers DNS serversDNS servers DNS servers DNS servers  Root DNS Servers  Top-level Domain (TLD) servers  Authoritative DNS Servers Washington University in St. Louis CSE473S ©2010 Raj Jain 2-42
  • 43. How DNS Works? root DNS server  Redirects  Recursive queries: Give 2 3 me an answer TLD DNS server 4  Iterative queries: Give 5 me an answer or a hint local DNS server  DNS responses are Dns.wustl.edu 7 6 cached 1 8 authoritative DNS server dns.cs.umass.edu requesting host www.cse.wustl.edu gaia.cs.umass.edu Washington University in St. Louis CSE473S ©2010 Raj Jain 2-43
  • 44. DNS Records  Resource Records=(Name, Value, Type, TTL)  Type=A: IP Address for the host name  Type=NS: Name server for the domain name  TYPE=CNAME: Canonical name for a host name  Type=MX: Canonical name of mail server Washington University in St. Louis CSE473S ©2010 Raj Jain 2-44
  • 45. DNS Message Format  Questions: Name, type  Answers: Name, type, value, TTL  Authority: Other authoritative servers  Additional: Other information, e.g., IP address of canonical name in MX response Identification Flags # of Questions # of Answer RRs 12 Bytes # of Authority RRs # of Additional RRs Questions Answers Authority Additional Information Washington University in St. Louis CSE473S ©2010 Raj Jain 2-45
  • 46. DNS Registration  Many Registrars  Internet Corporation for Assigned Names and Numbers (ICANN) accredits registrars  www.internic.net  Registrars provide authoritative name servers, A and MX records for the domain Washington University in St. Louis CSE473S ©2010 Raj Jain 2-46
  • 47. DNS Vulnerability  Distributed Denial of service attack on Name server  DNS cache poisoning – A server gives wrong answer Washington University in St. Louis CSE473S ©2010 Raj Jain 2-47
  • 48. DNS: Summary 1. DNS is used to resolve names to IP address 2. Also provides Name aliasing (CNAME), Mail Server (MX) records 3. DNS is a distributed database  Servers ask other servers for answers when needed 4. Recursive (answer only) or iterative (answer or hint) queries 5. Root Servers, Top level domain servers, Authoritative servers Washington University in St. Louis CSE473S ©2010 Raj Jain 2-48
  • 49. Homework 2C R19:  Is it possible for an organization’s web server and mail server to have exactly the same hostname? (Briefly explain why or why not?)  What would be the type of RR that contains the host name of the mail server? Washington University in St. Louis CSE473S ©2010 Raj Jain 2-49
  • 50. Overview Peer-to-Peer Applications 1. Client Server vs. P2P Scalability 2. P2P File Distribution (BitTorrent) 3. Distributed Hash Tables (DHTs) 4. Peer Churn 5. Network Address Translation (NAT) 6. Skype Washington University in St. Louis CSE473S ©2010 Raj Jain 2-50
  • 51. P2P File Distribution (BitTorrent) Tracker: tracks peers Torrent: group of participating in torrent peers exchanging chunks of a file Obtain list of peers trading chunks peer Washington University in St. Louis CSE473S ©2010 Raj Jain 2-51
  • 52. Peer-to-Peer Applications Server u1 d1 u2 us d2 File, size F dN Network (with uN abundant bandwidth)  N= # of peers  F= File Size  ui= uplink speed or ith host  di= downlink speed of ith host  dmin=min{d1, d2, ..., dN}  Dcs > max{ NF/us, F/dmin}  DP2P > max{F/us, F/dmin, NF/(us+ui)} Washington University in St. Louis CSE473S ©2010 Raj Jain 2-52
  • 53. Client Server vs. P2P Scalability Client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us 3.5 P2P Minimum Distribution Time 3 Client-Server 2.5 2 1.5 1 0.5 0 0 5 10 15 20 25 30 35 N Washington University in St. Louis CSE473S ©2010 Raj Jain 2: Application Layer 53 2-53
  • 54. BitTorrent P2P File Distribution  Peers=nodes participating in a Torrent file distribution Directory Tracker  Torrent=Set of all peers  Torrent File =a file containing 2 information about the tracker, 1 object ID, and file  Files are segmented into equal Leecher 1 Seed 1 size chunks (256kB) 3  Seeds=Peers that have the Seed 2 Leecher 2 complete file  Leechers=Peers that have incomplete file  Tracker=Has list of all peers Leecher n Seed m Washington University in St. Louis CSE473S ©2010 Raj Jain 2-54
  • 55. BitTorrent File Distribution (Cont) 1. Alice uses torrent directories (search engines) to find a torrent for "Raj Jain's Lecture" 2. Alice contact the tracker to get the current list of peers Tracker may provide random subset (say 50) peers 3. Alice sets up TCP connections with these peers in parallel and gets a map of available chunks  Requests least available chunks first (rarest first)  Every 10 seconds, Alice calculates the receiving rates  Sends to (Unchokes) the top 4 senders  Every 30 seconds, Alice sends to one randomly selected peer (optimistically unchokes)  Helps find high-rate neighbors  Ref: www.bittorrent.org http://en.wikipedia.org/wiki/BitTorrent_(protocol) Washington University in St. Louis CSE473S ©2010 Raj Jain 2-55
  • 56. Distributed Hash Tables (DHTs)  Hash Tables are used to find an entry in a table of (key, value) pairs in the database Key  Distributed Hash Tables are used for very large databases  Database is partitioned and stored in many Hash peers  Hash the key to find the peer that has the key  Peers are numbered from 0 thru 2n-1 (n-bit)  Objects (keys) are numbered from 0 thru 2n-1 (n-bit)  If some peers are missing, the keys are stored at the nearest peer.  Ref: http://en.wikipedia.org/wiki/Distributed_hash_table Washington University in St. Louis CSE473S ©2010 Raj Jain 2-56
  • 57. Circular DHT  Circular  N/2 messages  Shortcuts  Fewer messages  Tradeoff between connectivity and # of messages Who’s resp Who’s resp 0001 for key 1 for key 3? 1110? I am 0011 3 1111 15 1110 1110 0100 4 12 1110 1100 5 1110 1110 0101 1010 1110 10 1000 8 Washington University in St. Louis CSE473S ©2010 Raj Jain 2-57
  • 58. Peer Churn  How to recover when a peer leaves?  Each peer keeps track of first and second successors  Periodic handshakes to verify connectivity  When first successor leaves, connect to the second successor  When a new peer joins, it sends a message to peer 1, which gets forwarded until the right predecessor responds Washington University in St. Louis CSE473S ©2010 Raj Jain 2-58
  • 59. Network Address Translation (NAT) 192.168.0.2 192.168.0.3 128.252.73.216 Internet NAT 192.168.0.4 192.168.0.5  Private IP addresses 192.168.x.x  Can be used by anyone inside their networks  Cannot be used on the public Internet  NAT overwrites source addresses on all outgoing packets and overwrites destination addresses on all incoming packets  Only outgoing connections are possible Washington University in St. Louis CSE473S ©2010 Raj Jain 2-59
  • 60. Skype  P2P telephony application Sky Peer-to-Peer  Skyper  Skype  Super-peers keep an index (DHT?) of all active Skype users  Relays are used to connect NAT'ed nodes Washington University in St. Louis CSE473S ©2010 Raj Jain 2-60
  • 61. P2P Applications: Summary 1. P2P applications are more scalable  More efficient when the number of peers is large 2. BitTorrent has peers, trackers, seeds, and leechers 3. BitTorrent unchokes 4 top uploaders and one random node for load balancing 4. Distributed hash tables are used to manage large distributed databases used in P2P applications 5. Skype uses super-nodes to keep track of active users and provides relays for users behind NATs. Washington University in St. Louis CSE473S ©2010 Raj Jain 2-61
  • 62. Homework 2D P26. Suppose Bob joins a BitTorrent torrent, but he does not want to upload any data to any other peers (so called free-riding). A. Bob claims that he can receive a complete copy of the file that is shared by the swarm. Is Bob’s claim possible? Why or Why not? B. Bob further claims that he can further make his “free- riding” more efficient by using a collection of multiple computers (with distinct IP addresses) in the computer lab in his department. How can he do that? Washington University in St. Louis CSE473S ©2010 Raj Jain 2-62
  • 63. Application Layer: Summary 1. Applications use TCP/UDP ports for communication 2. HTTP/FTP/SMTP are client-server protocols and use TCP connections 3. HTTP is stateless but cookies allows servers to maintain state 4. Proxy servers improve performance by caching 5. BitTorrent is a P2P file distribution protocol and uses trackers to keep list of peers Washington University in St. Louis CSE473S ©2010 Raj Jain 2-63