← all topics

10 · Email + DNS

Slides 2-48 → 2-69 · HW2 P4

Part 1 · Email

Three components

ComponentWhat it is
User agent ("mail reader")Composes, edits and reads mail. E.g. Outlook, iPhone Mail
Mail serverHolds a mailbox (incoming messages for the user) and a message queue (outgoing messages waiting to be sent)
SMTPThe protocol mail servers use to send email to each other

SMTP (RFC 5321)

Alice sends email to Bob (6 steps)

  1. Alice uses her user agent to write a message to bob@someschool.edu.
  2. Her UA sends it to her mail server, where it goes in the message queue.
  3. The client side of SMTP on her server opens a TCP connection to Bob's mail server.
  4. The SMTP client sends Alice's message over that connection.
  5. Bob's mail server puts it in Bob's mailbox.
  6. Bob uses his user agent to read it.

Notice: Alice's UA → her server is one hop, and her server → Bob's server is another. The message is never sent straight from Alice's computer to Bob's.

Sample SMTP interaction

S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@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: .                              ← end of message
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection

SMTP vs HTTP

HTTPSMTP
DirectionPull (client pulls objects from the server)Push (sending server pushes mail to the receiving server)
BothASCII command/response interaction and status codes
Multiple objectsEach object in its own response messageMultiple objects in one multipart message
ConnectionsPersistent or non-persistentPersistent
DataAny data, including binaryHeader and body must be 7-bit ASCII
End of messageContent-Length: headerA line with only a period: CRLF.CRLF

Worked example: HW2 P4

Q: How does SMTP mark the end of a message body? How about HTTP? Can HTTP use the same method as SMTP?

Mail message format (RFC 822)

Mail access protocols

Full path: Alice's UA →SMTP→ Alice's server →SMTP→ Bob's server →IMAP/HTTP→ Bob's UA.

Part 2 · DNS

What DNS is

DNS services

Why not one central DNS server?

It doesn't scale:

The hierarchy

LevelWhat it doesExamples
RootContact of last resort for servers that can't resolve a name. Points you to the TLD server. 13 logical root servers, each replicated many times. Managed by ICANN.
Top-Level Domain (TLD)Responsible for one top-level domain. Points you to the authoritative server..com, .org, .net, .edu, country domains (.uk, .fr, .jp…). Network Solutions runs .com/.net, Educause runs .edu
AuthoritativeAn organization's own DNS server, with the official hostname → IP mappings for its hosts. Run by the org or a service provider.amazon.com DNS servers, umass.edu DNS servers

To find www.amazon.com: ask root → get the .com TLD server. Ask .com → get the amazon.com authoritative server. Ask that → get the IP address.

Local DNS server

Iterated vs recursive queries

Example: a host at engineering.nyu.edu wants the IP of gaia.cs.umass.edu. Local server = dns.nyu.edu, authoritative = dns.cs.umass.edu.

IteratedRecursive
Each contacted server replies with the name of the next server to ask: "I don't know this name, but ask this server."Each contacted server takes on the job itself and asks the next server on your behalf.
The local DNS server does all the asking: host → local, then local → root, local → TLD, local → authoritative, then local → host.The query chains down: host → local → root → TLD → authoritative, then the answer travels back up the same chain.
8 messages8 messages
Light load on root/TLDPuts the burden on the contacted servers → heavy load at upper levels of the hierarchy
Usually: the host → local query is recursive ("just get me the answer"), and local → everyone else is iterated.
Ties to topic 8: in HW2 P0, "n DNS servers visited, RTT₁…RTTₙ" is this lookup. Each visit costs one RTT.

Caching

DNS records

The database stores resource records (RR) in the format (name, value, type, ttl).

Typenamevalue
AhostnameIP address
NSdomain (e.g. foo.com)hostname of the authoritative name server for that domain
CNAMEalias namecanonical (real) name. E.g. www.ibm.com is really servereast.backup2.ibm.com
MXnamename of the mail server for that name
Memory hook: A = Address. NS = Name Server. CNAME = Canonical NAME. MX = Mail eXchange.

DNS messages

Query and reply use the same format. Header:

Inserting records: new startup "Network Utopia"

  1. Register networkutopia.com at a DNS registrar (e.g. Network Solutions). Give it the names and IPs of your authoritative name servers (primary and secondary).
  2. The registrar inserts an NS and an A record into the .com TLD server:
    (networkutopia.com, dns1.networkutopia.com, NS)
    (dns1.networkutopia.com, 212.212.212.1, A)
  3. Set up the authoritative server at 212.212.212.1 with an A record for www.networkutopia.com and an MX record for networkutopia.com.

DNS security

AttackWhat happens
DDoS on root serversNot successful so far: traffic filtering, and local servers cache TLD IPs, so root servers can be bypassed
DDoS on TLD serversPotentially more dangerous
SpoofingIntercept DNS queries and return bogus replies (DNS cache poisoning). Defense: DNSSEC (authentication, RFC 4033)

Quick check

1. How does SMTP mark the end of a message body? HTTP? Can HTTP use SMTP's method? (HW2 P4) SMTP: a line with only a period (CRLF.CRLF). HTTP: the Content-Length header. No: an HTTP body can be arbitrary binary data, which might contain CRLF.CRLF by accident. SMTP only carries 7-bit ASCII.
2. Name the three main components of email. User agents, mail servers, and SMTP.
3. Is SMTP push or pull? HTTP? SMTP = push. HTTP = pull.
4. Why does Bob need IMAP (or HTTP) to read his mail? Why not SMTP? SMTP is a push protocol for delivering mail to a server. Bob needs to pull mail from his server, which is what a mail access protocol (IMAP, or HTTP for webmail) does.
5. Which transport protocol and port does SMTP use? TCP, port 25.
6. Give 3 reasons DNS isn't centralized. Any three: single point of failure, huge traffic volume, distant database (slow for most users), maintenance. In short: it doesn't scale.
7. Name the 3 levels of the DNS hierarchy, top to bottom. Where does the local DNS server fit? Root → TLD → authoritative. The local DNS server isn't strictly part of the hierarchy: it's the ISP's default server that takes the host's query and forwards it in.
8. Iterated vs recursive: which one puts heavy load on the root and TLD servers? Recursive, because each contacted server has to resolve the rest of the name itself. In iterated queries, each server just says "ask this server next".
9. Which record type: (a) hostname → IP? (b) alias → real name? (c) domain → its name server? (d) domain → its mail server? (a) A (b) CNAME (c) NS (d) MX
10. Why are root servers not visited often? Local DNS servers cache TLD server addresses, so most queries skip the root.
11. A website changes its IP address. Why might some users still reach the old one? Their DNS servers still have the old mapping cached. It won't update until the cache entry's TTL expires.
Next: P2P file distribution and BitTorrent, a big calculation topic (HW2 P5–P7, sample P6).

← 9 · Web caching · all topics · 11 · P2P + BitTorrent →