Application Protocols

31
Computer Networks 1 Application Protocols

description

Application Protocols. Outline. FTP Email DNS. FTP server. local file system. FTP: the File Transfer Protocol. file transfer. FTP user agent. user at host. remote file system. ftp: RFC 959 ftp client contacts ftp server, who listens at port 21 - PowerPoint PPT Presentation

Transcript of Application Protocols

Page 1: Application Protocols

Computer Networks 1

Application Protocols

Page 2: Application Protocols

2

Outline

FTP Email DNS

Page 3: Application Protocols

3

FTP: the File Transfer Protocol

ftp: RFC 959 ftp client contacts ftp server, who listens at port 21 two parallel TCP connections opened:

control port 21: exchange commands, responses data port 20: file data to/from server

file transfer FTPserver

FTPuser

agent

local filesystem

remote filesystem

user at host

Page 4: Application Protocols

4

FTP: separate control, data connections

FTP client contacts FTP server at port 21, specifying TCP as transport protocol

Client obtains authorization over control connection

Client browses remote directory by sending commands over control connection.

When server receives a command for a file transfer, the server opens a TCP data connection to client

After transferring one file, server closes connection.

FTPclient

FTPserver

TCP control connection

port 21

TCP data connectionport 20

Server opens a second TCP data connection to transfer another file.

Control connection: “out of band”

FTP server maintains “state”: current directory, earlier authentication

Page 5: Application Protocols

Computer Networks 5

Intranet

Internet

Impacts of the FTP dual connections: for system administrators

What does this bi-direction mean for firewall filters?

Can I disable all incoming connections?

What if incoming connections are all denied, can you download files?

FTPclient

FTPserver

TCP control connection

port 21

TCP data connectionport 20

Firewall

Firewall ACL rules Permit all

connections initiated from inside

Disable all connections initiated from outside

Page 6: Application Protocols

6

FTP Passive Mode

Passive (PASV) mode Client initiates control

connection by connecting to port 21 on server

Client enables “Passive” mode

Server responds with PORT command giving client the IP address and port to use for subsequent data connection (usually port 20, but can be bypassed)

Client initiates data connection by connecting to specified port on server

Most web browsers do PASV-mode ftp

FTPclient

FTPserver

TCP control connection

port 21

Client connect to some server port

Page 7: Application Protocols

7

Outline

FTP Email DNS

Page 8: Application Protocols

8

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 9: Application Protocols

9

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 10: Application Protocols

10

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 11: Application Protocols

11

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 12: Application Protocols

12

SMTP (cont.)

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 13: Application Protocols

13

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

What if I want to send data encoded other than ASCII?

header

body

blankline

Page 14: Application Protocols

14

Message format: multimedia extensions

MIME: multimedia 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 15: Application Protocols

15

MIME typesContent-Type: type/subtype; parameters

Text example subtypes:

plain, html

Image example subtypes: jpeg,

gif

Audio exampe subtypes: basic

(8-bit mu-law encoded), 32kadpcm (32 kbps coding)

Video example subtypes: mpeg,

quicktime

Application other data that must be

processed by reader before “viewable”

example subtypes: msword, octet-stream

Page 16: Application Protocols

16

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 17: Application Protocols

17

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 18: Application Protocols

18

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

Page 19: Application Protocols

19

Outline

FTP Email DNS

Page 20: Application Protocols

20

DNS: Domain Name System

Function Machine like to use fix

length number e.g., IP address (32 bit) - used for address

Human like names, e.g., church.cse.ogi.edu - used by humans

Map between names (e.g. www.cs.uga.edu) and IP addresses (e.g. 128.192.251.7)

Domain Name System: distributed database

implemented in hierarchy of many name servers

application-layer protocol host, routers, name servers to communicate to resolve names (address/name translation) note: core Internet

function, implemented as application-layer protocol

complexity at network’s “edge”

Page 21: Application Protocols

21

Original Name to Address Mapping

Flat namespace /etc/hosts SRI kept main copy Downloaded regularly

Problems Count of hosts was increasing:

• machine per domain machine per user• Many more downloads• Many more updates

Page 22: Application Protocols

22

DNS name servers

no server has all name-to-IP address mappings

local name servers: each ISP, company has local

(default) name server• /etc/resolv.conf

host DNS query first goes to local name server

authoritative name server: for a host: stores that host’s

IP address, name can perform name/address

translation for that host’s name

Why not centralize DNS? single point of failure traffic volume distant centralized database maintenance doesn’t scale!

Page 23: Application Protocols

23

DNS: Domain Name System

Basic scheme: a hierarchical name space implemented by a distributed database

called a zone

Page 24: Application Protocols

24

b USC-ISI Marina del Rey, CAl ICANN Marina del Rey, CA

e NASA Mt View, CAf Internet Software C. Palo Alto, CA

i NORDUnet Stockholm

k RIPE London

m WIDE Tokyo

a NSI Herndon, VAc PSInet Herndon, VAd U Maryland College Park, MDg DISA Vienna, VAh ARL Aberdeen, MDj NSI (TBD) Herndon, VA

DNS: Root name servers

contacted by local name server that can not resolve name

root name server: contacts authoritative name server

if name mapping not known gets mapping returns mapping to local name

server

13 root name servers worldwide

Page 25: Application Protocols

25

Simple DNS example

Host atlas.cs.uga.edu wants IP address of gaia.cs.umass.edu

1. contacts its local DNS server, dns1.uga.edu

2. dns1 contacts root name server, if necessary

3. root name server contacts authoritative name server, dns.umass.edu, if necessary

requesting hostatlas.cs.uga.edu

gaia.cs.umass.edu

root name server

authorititive name serverdns.umass.edu

local name serverdns1.uga.edu

1

23

4

5

6

Page 26: Application Protocols

26

DNS example

Root name server: may not know

authoritative name server

may know intermediate name server: who to contact to find authoritative name server

requesting hostatlas.cs.uga.edu

gaia.cs.umass.edu

root name server

local name serverdns1.uga.edu

1

23

4 5

6

authoritative name serverdns.cs.umass.edu

intermediate name serverdns.umass.edu

7

8

Page 27: Application Protocols

27

DNS: Two Types of Queries

Recursive query: puts burden of name

resolution on contacted name server

Iterated query: contacted server

replies with name of server to contact

“I don’t know this name, but ask this server”

requesting hostatlas.cs.uga.edu

gaia.cs.umass.edu

root name server

1

23

4

authoritative name serverdns.cs.umass.edu

5 6

intermediate name serverdns.umass.edu

7

8

iterated query

local name serverdns1.uga.edu

Page 28: Application Protocols

28

DNS: caching and updating records

once (any) name server learns mapping, it caches mapping cache entries timeout (disappear) after some time

update/notify mechanisms under design by IETF RFC 2136 http://www.ietf.org/html.charters/dnsind-charter.html

Page 29: Application Protocols

29

DNS records

DNS: distributed db storing resource records (RR)

Type=NS name is domain (e.g.

foo.com) value is IP address of

authoritative name server for this domain

RR format: (name, value, type,ttl)

Type=A name is hostname value is IP address

Type=CNAME name is alias name for some

“cannonical” (the real) name www.ibm.com is really servereast.backup2.ibm.com value is cannonical name

Type=MX value is name of mailserver

associated with name

Page 30: Application Protocols

30

DNS protocol, messages

DNS protocol : query and reply messages, both with same message format

msg header identification: 16 bit # for

query, reply to query uses same #

flags: query or reply recursion desired recursion available reply is authoritative

Page 31: Application Protocols

31

DNS protocol, messages

Name, type fields for a query

RRs in reponseto query

records forauthoritative servers

additional “helpful”info that may be used