Data Communication and Networks - PowerPoint PPT Presentation

About This Presentation
Title:

Data Communication and Networks

Description:

User-agent: Mozilla/4.0. Connection: close. Accept-language:fr (extra ... User Agent. HTTP ... 5. User Agent - Server. POST /acme/shipping HTTP/1.1 ... – PowerPoint PPT presentation

Number of Views:61
Avg rating:3.0/5.0
Slides: 57
Provided by: JimKurosea280
Category:

less

Transcript and Presenter's Notes

Title: Data Communication and Networks


1
Data Communication and Networks
  • Lecture 3
  • Application Protocols
  • (HTTP, SMTP,FTP)
  • September 23, 2004

2
Some network apps
  • E-mail
  • Web
  • Instant messaging
  • Remote login
  • P2P file sharing
  • Multi-user network games
  • Streaming stored video clips
  • Internet telephone
  • Real-time video conference
  • Massive parallel computing

3
Application architectures
  • Client-server
  • Peer-to-peer (P2P)
  • Hybrid of client-server and P2P

4
Client-server archicture
  • server
  • always-on host
  • permanent IP address
  • server farms for scaling
  • clients
  • communicate with server
  • may be intermittently connected
  • may have dynamic IP addresses
  • do not communicate directly with each other

5
Pure P2P architecture
  • no always on server
  • arbitrary end systems directly communicate
  • peers are intermittently connected and change IP
    addresses
  • example Gnutella
  • Highly scalable
  • But difficult to manage

6
Hybrid of client-server and P2P
  • Napster
  • File transfer P2P
  • File search centralized
  • Peers register content at central server
  • Peers query same central server to locate content
  • Instant messaging
  • Chatting between two users is P2P
  • Presence detection/location centralized
  • User registers its IP address with central server
    when it comes online
  • User contacts central server to find IP addresses
    of buddies

7
Addressing processes
  • For a process to receive messages, it must have
    an identifier
  • A host has a unique32-bit IP address
  • Q does the IP address of the host on which the
    process runs suffice for identifying the process?
  • Answer No, many processes can be running on same
    host
  • Identifier includes both the IP address and port
    numbers associated with the process on the host.
  • Example port numbers
  • HTTP server 80
  • Mail server 25
  • More on this later

8
App-layer protocol defines
  • Types of messages exchanged, eg, request
    response messages
  • Syntax of message types what fields in messages
    how fields are delineated
  • Semantics of the fields, ie, meaning of
    information in fields
  • Rules for when and how processes send respond
    to messages
  • Public-domain protocols
  • defined in RFCs
  • allows for interoperability
  • eg, HTTP, SMTP
  • Proprietary protocols
  • eg, KaZaA

9
What transport service does an app need?
  • Data loss
  • some apps (e.g., audio) can tolerate some loss
  • other apps (e.g., file transfer, telnet) require
    100 reliable data transfer
  • Bandwidth
  • some apps (e.g., multimedia) require minimum
    amount of bandwidth to be effective
  • other apps (elastic apps) make use of whatever
    bandwidth they get
  • Timing
  • some apps (e.g., Internet telephony, interactive
    games) require low delay to be effective

10
Transport service requirements of common apps
Time Sensitive no no no yes, 100s msec yes,
few secs yes, 100s msec yes and no
Application file transfer e-mail Web
documents real-time audio/video stored
audio/video interactive games instant messaging
Bandwidth elastic elastic elastic audio
5kbps-1Mbps video10kbps-5Mbps same as above few
kbps up elastic
Data loss no loss no loss no loss loss-tolerant
loss-tolerant loss-tolerant no loss
11
Web and HTTP
  • First some jargon
  • Web page consists of objects
  • Object can be HTML file, JPEG image, Java applet,
    audio file,
  • Web page consists of base HTML-file which
    includes several referenced objects
  • Each object is addressable by a URL
  • Example URL

12
HTTP overview
  • HTTP hypertext transfer protocol
  • Webs application layer protocol
  • client/server model
  • client browser that requests, receives,
    displays Web objects
  • server Web server sends objects in response to
    requests
  • HTTP 1.0 RFC 1945
  • HTTP 1.1 RFC 2068

HTTP request
PC running Explorer
HTTP response
HTTP request
Server running Apache Web server
HTTP response
Mac running Navigator
13
HTTP overview (continued)
  • HTTP is stateless
  • server maintains no information about past client
    requests
  • Uses TCP
  • client initiates TCP connection (creates socket)
    to server, port 80
  • server accepts TCP connection from client
  • HTTP messages (application-layer protocol
    messages) exchanged between browser (HTTP client)
    and Web server (HTTP server)
  • TCP connection closed

aside
  • Protocols that maintain state are complex!
  • past history (state) must be maintained
  • if server/client crashes, their views of state
    may be inconsistent, must be reconciled

14
Stateless vs. Stateful Servers
  • Stateful
  • server remembers something about client
    transactions (control block)
  • improves efficiency by reducing transport message
    size
  • Stateless
  • server remembers nothing about client
    transactions
  • useful when transport protocols may unreliable
  • servers recover fast from crashes

15
Precise description of stateful server challenge
  • Idempotent
  • An operation which can be applied multiple times
    and still produce the same result
  • Formally, operation O is idempotent iff
  • O( a ) O( O( a ) )
  • Example
  • Idempotent x z
  • Not idempotent x x z
  • In a stateful server
  • Request operations must be idempotent, or
  • The server must recover from failures

16
Comer advice
  • If the network is unreliable or machines can
    crash then the server should be stateless
  • Do you agree?

17
HTTP connections
  • Nonpersistent HTTP
  • At most one object is sent over a TCP connection.
  • HTTP/1.0 uses nonpersistent HTTP
  • Persistent HTTP
  • Multiple objects can be sent over single TCP
    connection between client and server.
  • HTTP/1.1 uses persistent connections in default
    mode

18
Nonpersistent HTTP
(contains text, references to 10 jpeg images)
  • Suppose user enters URL www.someSchool.edu/someDep
    artment/home.index
  • 1a. HTTP client initiates TCP connection to HTTP
    server (process) at www.someSchool.edu on port 80

1b. HTTP server at host www.someSchool.edu
waiting for TCP connection at port 80. accepts
connection, notifying client
2. HTTP client sends HTTP request message
(containing URL) into TCP connection socket.
Message indicates that client wants object
someDepartment/home.index
3. HTTP server receives request message, forms
response message containing requested object, and
sends message into its socket
time
19
Nonpersistent HTTP (cont.)
4. HTTP server closes TCP connection.
  • 5. HTTP client receives response message
    containing html file, displays html. Parsing
    html file, finds 10 referenced jpeg objects

time
6. Steps 1-5 repeated for each of 10 jpeg objects
20
HTTP 1.1 Persistent Connections
  • In previous example, a connection is made for
    each request. This is bad. Why?
  • TCP 3-way hand-shake
  • TCP slow start
  • In http 1.1, persistent connections were added as
    default behavior.
  • Connection stays open unless client or server
    specify close when request satisfied
  • Header Connection close

21
HTTP 1.1 Pipelining
  • Persistent connection improves performance some,
    but connection half session is still
    under-utilized.
  • Client sends request, then waits for response
  • Server sends response, the waits for new request
  • Pipelining - send next request before previous
    response is received.
  • Studies show that persistent connections alone
    perform poorly. Pipelining improves performance
    considerably.

22
HTTP request message
  • two types of HTTP messages request, response
  • HTTP request message
  • ASCII (human-readable format)

request line (GET, POST, HEAD commands)
GET /somedir/page.html HTTP/1.1 Host
www.someschool.edu User-agent
Mozilla/4.0 Connection close Accept-languagefr
(extra carriage return, line feed)
header lines
Carriage return, line feed indicates end of
message
23
HTTP request message general format
24
HTTP Request Methods
  • First word in HTTP request is method
  • HTTP 1.1 methods are
  • GET (retrieve a resource)
  • HEAD (retrieve info about resource)
  • POST (submit an html form)
  • PUT (create/modify resources)
  • DELETE (delete a resource)
  • TRACE (trace requests in proxy chains)
  • OPTIONS (request for settings from proxy or
    server)

25
HTTP response message
status line (protocol status code status phrase)
HTTP/1.1 200 OK Connection close Date Thu, 06
Aug 1998 120015 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 ...
header lines
data, e.g., requested HTML file
26
HTTP response status codes
In first line in server-gtclient 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

27
Trying out HTTP (client side) for yourself
  • 1. Telnet to your favorite Web server

Opens TCP connection to port 80 (default HTTP
server port) at cis.poly.edu. Anything typed in
sent to port 80 at cis.poly.edu
telnet cis.poly.edu 80
2. Type in a GET HTTP request
By typing this in (hit carriage return twice),
you send this minimal (but complete) GET request
to HTTP server
GET /ross/ HTTP/1.1 Host cis.poly.edu
3. Look at response message sent by HTTP server!
28
HTTP State Management Cookies
  • We said earlier that HTTP is a stateless protocol
  • We also said that stateful protocols can provide
    improved performance. This feature is usually
    established by the idea of a session between
    client and server.
  • So, how can we get sessions in HTTP?
  • COOKIES!

29
COOKIES (briefly)
  • Cookie protocol - RFC 2109
  • A cookie is a token given to a client by a
    server.
  • Server sends Set-cookie header in response
  • Client associates cookie with issuing server
    (directory)
  • The token is just a file with a simple format
    (name/value pairs)
  • Each cookie has a unique name

30
Client-server interaction cookies
server
client
  • server sends cookie to client in response mst
  • Set-cookie 1678453
  • client presents cookie in later requests
  • cookie 1678453
  • server matches presented-cookie with
    server-stored info
  • authentication
  • remembering user preferences, previous choices

usual http request msg
usual http response Set-cookie
cookie- spectific action
cookie- spectific action
31
Cookie example
1. User Agent -gt Server POST
/acme/login HTTP/1.1 form data
User identifies self via a form. 2.
Server -gt User Agent HTTP/1.1 200 OK
Set-Cookie Customer"WILE_E_COYOTE"
Version"1" Path"/acme" Cookie
reflects user's identity. 3. User Agent -gt
Server POST /acme/pickitem HTTP/1.1
Cookie Version"1" Customer"WILE_E_COYOTE
" Path"/acme" form data
User selects an item for "shopping basket."
32
Cookie example (continued)
4. Server -gt User Agent HTTP/1.1 200
OK Set-Cookie Part_Number"Rocket_Launch
er_0001" Version"1"
Path"/acme" Shopping basket contains
an item. 5. User Agent -gt Server
POST /acme/shipping HTTP/1.1 Cookie
Version"1" Customer"WILE_E_CO
YOTE" Path"/acme"
Part_Number"Rocket_Launcher_0001"
Path"/acme" form data User
selects shipping method from form.
33
Cookie example (continued)
6. Server -gt User Agent HTTP/1.1 200
OK Set-Cookie Shipping"FedEx"
Version"1" Path"/acme" New cookie
reflects shipping method. 7. User Agent -gt
Server POST /acme/process HTTP/1.1
Cookie Version"1"
Customer"WILE_E_COYOTE" Path"/acme"
Part_Number"Rocket_Launcher_0001"
Path"/acme" Shipping"FedEx"
Path"/acme" form data User
chooses to process order. 8. Server -gt User
Agent HTTP/1.1 200 OK
Transaction is complete.
34
FTP the file transfer protocol
file transfer
user at host
remote file system
  • transfer file to/from remote host
  • client/server model
  • client side that initiates transfer (either
    to/from remote)
  • server remote host
  • ftp RFC 959
  • ftp server port 21

35
FTP Issues
  • Allow transfer of arbitrary files
  • Accommodate different file types
  • Convert between heterogeneous systems
  • Data types
  • Word lengths
  • Rules for file names
  • Provide some security (user login)
  • Permit Interactive or Batch Operation

36
FTP separate control, data connections
  • ftp client contacts ftp server at port 21
  • two parallel TCP connections opened
  • control exchange commands, responses between
    client, server.
  • out of band control
  • data file data to/from server
  • ftp server maintains state

37
FTP Using separate data connections
  • Separates commands from data
  • Client can send commands during data transfer
  • Closed connection indicates end of file
  • Control connection persists, data connections
    come and go

38
FTP commands
  • Sent as ASCII text over control channel
  • USER username
  • PASS password
  • LIST return list of file in current directory
  • RETR filename retrieves (gets) file
  • STOR filename stores (puts) file onto remote host

39
FTP return codes
  • Status code and phrase (as in smtp, http)
    returned in ASCII over control connection
  • 331 Username OK, password required
  • 125 data connection already open transfer
    starting
  • 425 Cant open data connection
  • 452 Error writing file

40
Example Protocol Interaction
LOCAL COMMANDS BY USER ACTION
INVOLVED ftp (host) multicsltCRgt
Connect to host S, port L,
establishing control connections.
lt---- 220
Service ready ltCRLFgt. username Doe ltCRgt
USER DoeltCRLFgt----gt
lt---- 331 User name ok,
need
passwordltCRLFgt. password mumble ltCRgt
PASS mumbleltCRLFgt----gt
lt---- 230 User logged inltCRLFgt.
retrieve (local type) ASCIIltCRgt (local
pathname) test 1 ltCRgt User-FTP opens local
file in ASCII. (for. pathname) test.pl1ltCRgt
RETR test.pl1ltCRLFgt ----gt
lt---- 150 File status okay
about to
open data
connectionltCRLFgt.
Server makes data connection
to port U.
lt---- 226
Closing data connection,
file transfer
successfulltCRLFgt. type ImageltCRgt
TYPE IltCRLFgt ----gt
lt---- 200 Command OKltCRLFgt
store (local type) imageltCRgt (local
pathname) file dumpltCRgt User-FTP opens local
file in Image. for.pathname) gtuddgtcngtfdltCRgt
STOR gtuddgtcngtfdltCRLFgt ----gt
lt---- 550 Access deniedltCRLFgt
terminate QUIT ltCRLFgt
----gt
Server closes all
connections.
41
Electronic Mail
  • Three major components
  • user agents
  • mail servers
  • simple mail transfer protocol SMTP
  • User Agent
  • a.k.a. mail reader
  • composing, editing, reading mail messages
  • e.g., Eudora, Outlook, elm, Netscape Messenger
  • outgoing, incoming messages stored on server

42
Electronic Mail mail servers
  • Mail Servers
  • mailbox contains incoming messages for user
  • message queue of outgoing (to be sent) mail
    messages
  • SMTP protocol between mail servers to send email
    messages
  • client sending mail server
  • server receiving mail server

43
Electronic Mail SMTP RFC 2821
  • uses TCP to reliably transfer email message 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

44
Scenario Alice sends message to Bob
  • 4) SMTP client sends Alices message over the TCP
    connection
  • 5) Bobs mail server places the message in Bobs
    mailbox
  • 6) Bob invokes his user agent to read message
  • 1) Alice uses UA to compose message and to
    bob_at_someschool.edu
  • 2) Alices UA sends message to her mail server
    message placed in message queue
  • 3) Client side of SMTP opens TCP connection with
    Bobs mail server

1
2
6
3
4
5
45
Sample SMTP interaction
S 220 hamburger.edu C HELO crepes.fr
S 250 Hello crepes.fr, pleased to meet
you C MAIL FROM ltalice_at_crepes.frgt
S 250 alice_at_crepes.fr... Sender ok C RCPT
TO ltbob_at_hamburger.edugt S 250
bob_at_hamburger.edu ... Recipient ok C DATA
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 C QUIT
S 221 hamburger.edu closing connection
46
Try SMTP interaction for yourself
  • telnet servername 25
  • see 220 reply from server
  • enter HELO, MAIL FROM, RCPT TO, DATA, QUIT
    commands
  • above lets you send email without using email
    client (reader)

47
SMTP final words
  • SMTP uses persistent connections
  • SMTP requires message (header body) to be in
    7-bit ASCII
  • SMTP server uses CRLF.CRLF to determine end of
    message
  • Comparison with HTTP
  • HTTP pull
  • SMTP push
  • both have ASCII command/response interaction,
    status codes
  • HTTP each object encapsulated in its own
    response msg
  • SMTP multiple objects sent in multipart msg

48
Mail message format
  • SMTP protocol for exchanging email msgs
  • RFC 822 standard for text message format
  • header lines, e.g.,
  • To
  • From
  • Subject
  • different from SMTP commands!
  • body
  • the message, ASCII characters only

header
blank line
body
49
Message format multimedia extensions
  • MIME multipart Internet mail extension, RFC
    2045, 2056
  • additional lines in msg header declare MIME
    content type

MIME version
method used to encode data
multimedia data type, subtype, parameter
declaration
encoded data
50
MIME types
  • Text plain, html
  • Image jpeg, gif
  • Audio basic, 32kadpcm
  • Video mpeg, quicktime
  • Application other data that must be processed by
    reader before viewable. Example subtypes
    msword, octet-stream.
  • Multipart used when sending objects of different
    types

51
Multipart Type
  • Multipart separation
  • boundary"------------C725BD4EC548463C
  • Potentially recursive
  • Each part described by a MIME type

52
Multipart Example
From alice_at_crepes.fr To bob_at_hamburger.edu
Subject Picture of yummy crepe. MIME-Version
1.0 Content-Type multipart/mixed
boundary98766789 --98766789 Content-Transfer-En
coding quoted-printable Content-Type
text/plain Dear Bob, Please find a picture of a
crepe. --98766789 Content-Transfer-Encoding
base64 Content-Type image/jpeg base64 encoded
data ..... .........................
......base64 encoded data --98766789--
53
What is base64 you ask?
  • Problem how to send binary data?
  • Base64 is hashing method to map 8 bit to 6 bit
    codes that define a subset of the ASCII
    Character space.
  • Convert each 24 bits to four 6 bit codes, pad
    trailing bits with 0s.
  • Use 6 bit code to index table for mapped ASCII
    character
  • Note base64 map table does not include CRLF or
    other RFC822 special characters (or , which is a
    base64 pad character.

54
Mail access protocols
SMTP
access protocol
receivers mail server
  • SMTP delivery/storage to receivers server
  • Mail access protocol retrieval from server
  • POP Post Office Protocol RFC 1939
  • authorization (agent lt--gtserver) and download
  • IMAP Internet Mail Access Protocol RFC 1730
  • more features (more complex)
  • manipulation of stored msgs on server
  • HTTP Hotmail , Yahoo! Mail, etc.

55
POP3 protocol
S OK POP3 server ready C user bob S OK
C pass hungry S OK user successfully logged
on
  • authorization phase
  • client commands
  • user declare username
  • pass password
  • server responses
  • OK
  • -ERR
  • transaction phase, client
  • list list message numbers
  • retr retrieve message by number
  • dele delete
  • quit

C list S 1 498 S 2 912
S . C retr 1 S ltmessage 1
contentsgt S . C dele 1 C retr
2 S ltmessage 1 contentsgt S .
C dele 2 C quit S OK POP3 server
signing off
56
POP3 (more) and IMAP
  • More about POP3
  • Previous example uses download and delete mode.
  • Bob cannot re-read e-mail if he changes client
  • Download-and-keep copies of messages on
    different clients
  • POP3 is stateless across sessions
  • IMAP
  • Keep all messages in one place the server
  • Allows user to organize messages in folders
  • IMAP keeps user state across sessions
  • names of folders and mappings between message IDs
    and folder name
Write a Comment
User Comments (0)
About PowerShow.com