Email Service

There are three major components:

  • User agent
  • Mail server
  • Mail protocols
    • Simple mail transfer protocol (SMTP)
    • Internet mail access protocol (IMAP)

User agent

  • Compose and read mail messages
    • e.g. Outlook
  • Outgoing and incoming messages are stored on server

Mail server

  • Mailbox (yellow) contains incoming messages for user
  • Message queue (green) of outgoiing mail messages
  • SMTP protocol is used between mail servers to send messages
    • client: sending mail server
    • server: receiving mail server

SMTP

  • Uses TCP to reliably transfer message from client to server
  • Three phases of transfer
    1. SMTP handshaking
    2. SMTP transfer of messages
    3. SMTP closure

IMAP

  • Mail access protocol: retrieval from server
  • IMAP provides retrieval, deletion, folrders of stored messages on server

SMTP versus HTTP

PropertySMTPHTTP
Main purposeTransfer e-mailTransfer web objects
Interaction styleASCII Command-responseASCII Request-response
Reliable transportTCPTCP
Traditional server port2580
Typical directionSender pushes messageClient requests/pulls object

HTTP adoption: gmail, outlook, etc. can provide web-based interface on top of SMTP to send and IMAP to retrieve messages

Domain Name System (DNS)

Domain Name System provides services:

  • Resolves hostname-to-IP-address translation.
  • Host aliasing.
  • Replicated Web servers: many IP addresses correspond to one name

It is enabled by:

  • Distributed database implemented in hierarchy of many name servers
    • DNS combines hierarchy, distribution, delegation, replication, and caching.
  • Applicaiton layer protocol

DNS Hierarchy

1. Root name servers

  • 13 logical root name servers worldwide and each server is replicated many times (~200 servers in US)
  • Official contract-of-last-resort by name servers that can not resolve name
  • ICANN manages root DNS domain

2. Top-level domain servers

  • Responsible for .com, .org, .edu, or
  • all top-level country domains, e.g.: .cn, .uk, .jp.

3. Authoritative servers

  • Organization’s own DNS server(s), providing authoritative hostname to IP mappings for organization’s named hosts
  • Can be maintained by organization or service provider (ISP)

4. Local DNS name servers

  • When a host needs to resolve a name, it normally sends the request to a local DNS server
  • May be operated by an ISP, university, company, etc.
  • The local server can:
    • answer from its cache
    • contact other DNS servers to resolve the name
    • cache the result

DNS Records

DNS stores resource records.
Each record can be represented as:

(name, TTL, type, data)

A type record

An A record maps a hostname to an IPv4 address:

example.com.  3600s  A  192.168.1.1

Conceptually:

hostname → IPv4 address

A records gives the final IPv4 address.

NS type record

An NS record maps a domain to an authoritative name server:

example.com.  86400  NS  ns1.example.com.
  • example.com identifies a domain or DNS zone
  • ns1.example.com is the hostname of a computer running authoritative DNS-server software
  • That server stores records belonging to the example.com zone.

CNAME type record

A CNAME record defines an alias for a canonical name.

www.example.com.  3600  CNAME  example.com.

This allows several public names to refer to a canonical hostname. For example:

www.example.com  ─┐
blog.example.com ─┼→ canonical service name
shop.example.com ─┘

Concrete example

When browser needs www.example.com:

1. Which server knows about example.com?
                 ↓ NS
   ns1.example.com

2. Where is ns1.example.com?
                 ↓ A/glue
   192.0.2.53

3. Ask 192.0.2.53:
   What is the address of www.example.com?
                 ↓ CNAME
   www.example.com is app.example.com

4. What is the address of app.example.com?
                 ↓ A
   203.0.113.25

5. Browser connects to:
   203.0.113.25

MX type record

An MX record identifies a mail server responsible for a domain.

example.com.  3600  MX  10 mail.example.com.

Suppose Alice sends mail to bob@example.com:

1. Extract recipient domain: example.com

2. Query DNS:
   What is the MX record for example.com?

3. DNS replies:
   example.com MX 10 mail.example.com

4. Resolve mail.example.com:
   mail.example.com A 192.0.2.25

5. Open a TCP connection:
   192.0.2.25, port 25

6. Transfer the message using SMTP.

7. Bob later accesses the stored message using IMAP.

Summary

RecordName representsData representsPurpose
AHostnameIPv4 addressLocate a host
NSDomainAuthoritative server nameDelegate DNS responsibility
CNAMEAliasCanonical hostnameCreate an alternate name
MXMail domainMail-server hostnameRoute e-mail

DNS Name Resolution

Iterated query

  • contacted server replies with name of server to contact

Recursive query

  • puts burden of name resolution on contacted name server
  • can cause heavy load at upper levels

DNS Caching Information

Once a DNS server learns a mapping, it can store that result temporarily.
Then, later queries can be served immediately.

Caches may exist in:

  • Browsers
  • Operating systems
  • Local DNS servers
  • Other DNS servers

Caching works especially well because DNS receives many more reads than writes.

Video Streaming and Content Delivery Network (CDN)

Fill in when needed or review the slides directly