Top Banner
2: Application Layer 1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004
56

2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

Dec 20, 2015

Download

Documents

Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 1

Data Communication and Networks

Lecture 3

Application Protocols(HTTP, SMTP,FTP)

September 23, 2004

Page 2: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 3: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 3

Application architectures

Client-server Peer-to-peer (P2P) Hybrid of client-server and P2P

Page 4: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 4

Client-server archictureserver:

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

Page 5: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 6: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 6

Hybrid of client-server and P2PNapster

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

Page 7: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 8: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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, SMTPProprietary protocols: eg, KaZaA

Page 9: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Timing some apps (e.g.,

Internet telephony, interactive games) require low delay to be “effective”

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

Page 10: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 10

Transport service requirements of common apps

Application

file transfere-mail

Web documentsreal-time audio/video

stored audio/videointeractive gamesinstant messaging

Data loss

no lossno lossno lossloss-tolerant

loss-tolerantloss-tolerantno loss

Bandwidth

elasticelasticelasticaudio: 5kbps-1Mbpsvideo:10kbps-5Mbpssame as above few kbps upelastic

Time Sensitive

nononoyes, 100’s msec

yes, few secsyes, 100’s msecyes and no

Page 11: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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:

www.someschool.edu/someDept/pic.gif

host name path name

Page 12: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 12

HTTP overview

HTTP: hypertext transfer protocol

Web’s 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

PC runningExplorer

Server running

Apache Webserver

Mac runningNavigator

HTTP request

HTTP request

HTTP response

HTTP response

Page 13: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 13

HTTP overview (continued)

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

HTTP is “stateless” server maintains no

information about past client requests

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

aside

Page 14: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 15: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 16: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 16

Comer advice

If the network is unreliable or machines can crash then the server should be stateless

Do you agree?

Page 17: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 18: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 18

Nonpersistent HTTPSuppose user enters URL www.someSchool.edu/someDepartment/home.index

1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80

2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index

1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client

3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket

time

(contains text, references to 10

jpeg images)

Page 19: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 19

Nonpersistent HTTP (cont.)

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

4. HTTP server closes TCP connection.

time

Page 20: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 21: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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.

Page 22: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 22

HTTP request message

two types of HTTP messages: request, response

HTTP request message: ASCII (human-readable format)

GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr

(extra carriage return, line feed)

request line(GET, POST,

HEAD commands)

header lines

Carriage return, line feed

indicates end of message

Page 23: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 23

HTTP request message: general format

Page 24: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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)

Page 25: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 25

HTTP response message

HTTP/1.1 200 OK Connection closeDate: 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 ...

status line(protocol

status codestatus phrase)

header lines

data, e.g., requestedHTML file

Page 26: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 26

HTTP response status 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

In first line in server->client response message.A few sample codes:

Page 27: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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:

GET /~ross/ HTTP/1.1Host: cis.poly.edu

By typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server

3. Look at response message sent by HTTP server!

Page 28: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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!

Page 29: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 30: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 30

Client-server interaction: cookies

server sends “cookie” to client in response mstSet-cookie: 1678453

client presents cookie in later requestscookie: 1678453

server matches presented-cookie with server-stored info authentication remembering user

preferences, previous choices

client server

usual http request msgusual http response

+Set-cookie: #

usual http request msg

cookie: #usual http response

msg

usual http request msg

cookie: #usual http response msg

cookie-spectificaction

cookie-spectificaction

Page 31: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 31

Cookie example

1. User Agent -> Server

POST /acme/login HTTP/1.1 [form data]

User identifies self via a form.

2. Server -> 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 -> 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."

Page 32: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 32

Cookie example (continued)

4. Server -> User Agent

HTTP/1.1 200 OK Set-Cookie: Part_Number="Rocket_Launcher_0001"; Version="1"; Path="/acme"

Shopping basket contains an item.

5. User Agent -> Server

POST /acme/shipping HTTP/1.1 Cookie: $Version="1"; Customer="WILE_E_COYOTE"; $Path="/acme"; Part_Number="Rocket_Launcher_0001"; $Path="/acme" [form data]

User selects shipping method from form.

Page 33: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 33

Cookie example (continued)

6. Server -> User Agent

HTTP/1.1 200 OK Set-Cookie: Shipping="FedEx"; Version="1"; Path="/acme"

New cookie reflects shipping method.

7. User Agent -> 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 -> User Agent

HTTP/1.1 200 OK

Transaction is complete.

Page 34: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 34

FTP: the file transfer protocol

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

file transfer FTPserver

FTPuser

interface

FTPclient

local filesystem

remote filesystem

user at host

Page 35: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 36: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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”

FTPclient

FTPserver

TCP control connection

port 21

TCP data connectionport 20

Page 37: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 38: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 39: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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 Can’t open data connection 452 Error writing file

Page 40: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 40

LOCAL COMMANDS BY USER ACTION INVOLVED

ftp (host) multics<CR> Connect to host S, port L, establishing control connections. <---- 220 Service ready <CRLF>. username Doe <CR> USER Doe<CRLF>----> <---- 331 User name ok, need password<CRLF>. password mumble <CR> PASS mumble<CRLF>----> <---- 230 User logged in<CRLF>. retrieve (local type) ASCII<CR> (local pathname) test 1 <CR> User-FTP opens local file in ASCII. (for. pathname) test.pl1<CR> RETR test.pl1<CRLF> ----> <---- 150 File status okay; about to open data connection<CRLF>. Server makes data connection to port U. <---- 226 Closing data connection, file transfer successful<CRLF>. type Image<CR> TYPE I<CRLF> ----> <---- 200 Command OK<CRLF> store (local type) image<CR> (local pathname) file dump<CR> User-FTP opens local file in Image. for.pathname) >udd>cn>fd<CR> STOR >udd>cn>fd<CRLF> ----> <---- 550 Access denied<CRLF> terminate QUIT <CRLF> ----> Server closes all connections.

Example Protocol Interaction

Page 41: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

user mailbox

outgoing message queue

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 42: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

mailserver

useragent

useragent

useragent

mailserver

useragent

useragent

mailserver

useragent

SMTP

SMTP

SMTP

Page 43: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 44: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 44

Scenario: Alice sends message to Bob1) Alice uses UA to compose

message and “to” [email protected]

2) Alice’s UA sends message to her mail server; message placed in message queue

3) Client side of SMTP opens TCP connection with Bob’s mail server

4) SMTP client sends Alice’s message over the TCP connection

5) Bob’s mail server places the message in Bob’s mailbox

6) Bob invokes his user agent to read message

useragent

mailserver

mailserver user

agent

1

2 3 4 56

Page 45: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 45

Sample SMTP interaction S: 220 hamburger.edu C: HELO crepes.fr S: 250 Hello crepes.fr, pleased to meet you C: MAIL FROM: <[email protected]> S: 250 [email protected]... Sender ok C: RCPT TO: <[email protected]> S: 250 [email protected] ... 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

Page 46: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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)

Page 47: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

Page 48: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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

body

blankline

Page 49: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 49

Message format: multimedia extensions MIME: multipart Internet mail extension, RFC 2045, 2056 additional lines in msg header declare MIME content type

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Transfer-Encoding: base64 Content-Type: image/jpeg

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

multimedia datatype, subtype,

parameter declaration

method usedto encode data

MIME version

encoded data

Page 50: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 50

MIME types

Text : plain, htmlImage: 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

Page 51: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 51

Multipart Type

Multipart separation boundary="------------C725BD4EC548463C“

Potentially recursive Each part described by a MIME type

Page 52: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 52

Multipart Example

From: [email protected] To: [email protected] Subject: Picture of yummy crepe. MIME-Version: 1.0 Content-Type: multipart/mixed; boundary=98766789 --98766789Content-Transfer-Encoding: quoted-printableContent-Type: text/plain

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

base64 encoded data ..... ......................... ......base64 encoded data --98766789--

Page 53: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 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 0’s.

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.

Page 54: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 54

Mail access protocols

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.

useragent

sender’s mail server

useragent

SMTP SMTP accessprotocol

receiver’s mail server

Page 55: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 55

POP3 protocol

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: <message 1 contents> S: . C: dele 1 C: retr 2 S: <message 1 contents> S: . C: dele 2 C: quit S: +OK POP3 server signing off

S: +OK POP3 server ready C: user bob S: +OK C: pass hungry S: +OK user successfully logged on

Page 56: 2: Application Layer1 Data Communication and Networks Lecture 3 Application Protocols (HTTP, SMTP,FTP) September 23, 2004.

2: Application Layer 56

POP3 (more) and IMAPMore 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