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
Lecture 3: Application Layer 1
מבוא לרשתות תקשורת:רמת היישום דואר אלקטרוני
( DNS)ומערכת השמות (chapter 2 – application)
פרופ' אמיר הרצברג
Computer Networking: A Top Down Approach Featuring the Internet, 2nd edition. Jim Kurose, Keith RossAddison-Wesley, July 2002.
The Simple Mail Transfer Protocol (SMTP) [RFC 2821] Uses TCP to reliably transfer email message Initiated by sending agent, called SMTP-client SMTP-server listens on port 25, receives email
MUA to MSA, MSA/MTA to MTA, MTA to MDA three phases of transfer
handshaking (greeting) transfer of messages closure
command/response interaction commands: ASCII text response: status code and phrase
Lecture 3: Application Layer 14
SMTP Phases Handshaking (greeting)
TCP Connection Setup: SMTP-server rejects if overloaded Server hello: sends 220 B.com Server may delay hello (until ready) Client hello: sends Or EHLO (extended hello, supports options)
Transfer of one or more messages: MAIL FROM: sender email (for error report) RCPT TO: recipient that Receiver-SMTP should deliver to Data: RFC 822 message (with headers), then terminator
Mail message format (RFC 822/2822)SMTP: protocol for
exchanging email msgsRFC 822/2822: standards
for text message format: header lines, e.g.,
To: From: Subject:different from SMTP
commands! Blank line body
the “message”, printable ASCII characters only
How to send non-ASCII?
header
body
blankline
Lecture 3: Application Layer 17
MIME: multimedia mail extension How to send non-ASCII data, e.g. picture, program? Encode: map data bytes to (more) printable-ASCII bytes
E.g.: Hex encoding (x’A3’”A3”); usually use base64 (more compact)
Identify in header: MIME version, encoding, data type, subtype Types: Text, Image, Audio, Video, Application, Multipart
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
Multipart: multiple parts (with separators defined in header)
Lecture 3: Application Layer 18
Envelope vs. Message [from, to] S: 220 B.com C: HELO A.com S: 250 OK C: MAIL FROM: <[email protected]> S: 250 OK C: RCPT TO: [email protected] S: 250 OK C: DATA S: 354 Enter mail, end with "." on a line by itself C: from: [email protected] C: to: [email protected], [email protected] C: C: what a wonderful message C: . S: 250 OK C: QUIT S: 221 b.com closing connection
Envelope RCPT TO: vs. Message to: S: 220 B.com C: HELO A.com S: 250 OK C: MAIL FROM: <[email protected]> S: 250 OK C: RCPT TO: [email protected] S: 250 OK C: DATA S: 354 Enter mail, end with "." on a line by itself C: from: [email protected] C: to: [email protected] C: C: what a wonderful message C: . S: 250 OK C: QUIT S: 221 b.com closing connection
Envelope RCPT TO: for Message bcc: S: 220 B.com C: HELO A.com S: 250 OK C: MAIL FROM: <[email protected]> S: 250 OK C: RCPT TO: [email protected] S: 250 OK C: RCPT TO: [email protected] C: DATA S: 354 Enter mail, end with "." on a line by itself C: from: [email protected] C: to: [email protected] C: C: I _still_ did not receive the goods you promised C: . S: 250 OK C: QUIT S: 221 b.com closing connection
Notice also multiple RCPT TO)one per recipient, all in same domain(
SMTP – Basic Entities S: 220 B.com C: HELO A.com S: 250 OK C: MAIL FROM: <[email protected]> S: 250 OK C: RCPT TO: [email protected] S: 250 OK C: DATA S: 354 Enter mail, end with "." on a line by itself C: from: [email protected] C: to: [email protected] C: C: what a wonderful message C: . S: 250 OK C: QUIT S: 221 b.com closing connection
HELO name HELO name
Message originatorMessage originator
Message RecipientMessage Recipient
Envelope RecipientEnvelope Recipient
Envelope originatorEnvelope originator
Server greeting nameServer greeting name
Lecture 3: Application Layer 22
SMTP – Basic Entities (cont’)
S: 220 B.com C: HELO A.com S: 250 OK C: MAIL FROM: <[email protected]> S: 250 OK C: RCPT TO: [email protected] S: 250 OK C: DATA S: 354 Enter mail, end with "." on a line by itself C: from: [email protected] C: to: [email protected] C: C: what a wonderful message C: . S: 250 OK …
HELO nameHELO name
Message originatorMessage originator
Message RecipientMessage Recipient
Envelope RecipientEnvelope Recipient
Envelope originatorEnvelope originator
Server greeting nameServer greeting name
TCP connection parms: SMTP-Client (33.4.5.6) connect to SMTP-Server-IP (35.6.7.8)
Lecture 3: Application Layer 23
Email Sender Identities SMTP-Client identifies only relaying agent (MTA)
Often unrelated to email sender identity MUA displays only the From: header (usually)
RFC822 From: asked for message to be sent Most MSAs allow use of any From: identity
To allow transparent mobility But, spoofing email becomes trivial… Partial alternate solution: use Reply-To: header
Several other sender-related identifiers: Sender: “entered message into email stream” Resent-from, resent-sender:
• RFC2822: identifies party (time, etc.) resending message• Specifically not intended for use for forwarding (by user or by
service)• But used, e.g. by sendmail, mailing-lists…
Internet hosts, routers: IP address (32 bit) - used
for addressing datagrams• One per network adapter
(may have two) Domain names: biu.ac.il Fully Qualified Domain
Name (FQDN) or “name”, e.g., gaia.cs.umass.edu
Names : used by humans
Q: map between IP addresses and names ?
Domain Name System: distributed names database
implemented in hierarchy of many name servers
application-layer protocol host, routers, name servers communicate to resolve names (address/name translation) Application-layer
protocol for Basic Internet function
complexity at network’s “edge”
Used to distribute other data as well
Lecture 3: Application Layer 34
DNS
Why not centralize DNS? single point of failure traffic volume Proximity (close to
client) Maintenance and
security
doesn’t scale!
DNS services Hostname to IP
address translation Host aliasing
Canonical and alias names
Mail server aliasing Load distribution
Replicated Web servers: set of IP addresses for one canonical name
Lecture 3: Application Layer 35
TLD and Authoritative Servers Top-level domain (TLD) servers: responsible
for com, org, net, edu, etc, and all top-level country domains uk, fr, ca, jp. Network solutions maintains servers for com TLD Educause for edu TLD
Authoritative DNS servers: organization’s DNS servers, providing authoritative hostname to IP mappings for organization’s servers (e.g., Web and mail). Maintained by organization or service provider
Lecture 3: Application Layer 36
Root DNS Servers
com DNS servers org DNS servers edu DNS servers
poly.eduDNS servers
umass.eduDNS servers
yahoo.comDNS servers
amazon.comDNS servers
pbs.orgDNS servers
Distributed, Hierarchical Database
Client wants IP for www.amazon.com; 1st approx: Query root server to find com DNS server Query com DNS server (TLD) to get
amazon.com DNS server Query amazon.com DNS server to get IP
address for www.amazon.com
Lecture 3: Application Layer 37
Local Name Server
Queries processed by a Local Name Server, not by DNS client
Does not strictly belong to hierarchy Each ISP (residential ISP, company,
university) has (at least) one. Also called “default name server”
When a host makes a DNS query, query is sent to its local DNS server Acts as a proxy, forwards query into
hierarchy.
Lecture 3: Application Layer 38
DNS: Root name servers contacted by local name server that can not resolve name root name servers:
if name mapping not known: get from authoritative name server
return mapping to local name server
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
13 root name servers worldwide
Lecture 3: Application Layer 39
requesting hostcis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS serverdns.poly.edu
1
23
4
5
6
authoritative DNS serverdns.cs.umass.edu
78
TLD DNS server
Example
Host at cis.poly.edu wants IP address for gaia.cs.umass.edu
Lecture 3: Application Layer 40
requesting hostcis.poly.edu
gaia.cs.umass.edu
root DNS server
local DNS serverdns.poly.edu
1
2
45
6
authoritative DNS serverdns.cs.umass.edu
7
8
TLD DNS server
3
Recursive queries
recursive query: puts burden of
name resolution on contacted name server
heavy load?
iterated query: contacted server
replies with name of server to contact
“I don’t know this name, but ask this server”
Lecture 3: Application Layer 41
DNS: caching and updating records DNS mappings are kept and sent in resource records
(RR) DNS servers cache mappings (RRs)
cache entries timeout (disappear) after ttl seconds The ttl value is specified in each DNS record
Several different types of RR Used for domain name resolution And for other purposes… where the distribution
among DNS servers is useful• E.g. distribute black list of spam mail servers• Own domain (e.g. easy.10$.com), run DNS server,
define arbitrary DNS `subtree` under it: policy.easy.10$.com,…
Lecture 3: Application Layer 42
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
Type=TXT value is some text
RR format: (name, value, type, ttl)
Type=A name is hostname value is IP address
Type=CNAME name is alias name for (real)
“canonical” name value www.ibm.com is really servereast.backup2.ibm.com