1 of 26

2: Application Layer

1

Chapter 2�Application Layer

Jaringan Komputer

Departemen Informatika

Universitas Diponegoro

2 of 26

Chapter 2: Application layer

  • Email
  • DNS

​

2: Application Layer

2

3 of 26

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, Mozilla Thunderbird
  • outgoing, incoming messages stored on server

2: Application Layer

3

user mailbox

outgoing

message queue

mail

server

user

agent

user

agent

user

agent

mail

server

user

agent

user

agent

mail

server

user

agent

SMTP

SMTP

SMTP

4 of 26

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

2: Application Layer

4

mail

server

user

agent

user

agent

user

agent

mail

server

user

agent

user

agent

mail

server

user

agent

SMTP

SMTP

SMTP

5 of 26

Electronic Mail: SMTP [RFC 5321]

  • 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

​

​

2: Application Layer

5

6 of 26

Scenario: Alice sends message to Bob

1) Alice uses UA to compose message and “to” bob@someschool.edu

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

​

2: Application Layer

6

user

agent

mail

server

mail

server

user

agent

1

2

3

4

5

6

7 of 26

Sample SMTP interaction

2: Application Layer

7

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: .

S: 250 Message accepted for delivery

C: QUIT

S: 221 hamburger.edu closing connection

8 of 26

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)

2: Application Layer

8

9 of 26

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

2: Application Layer

9

10 of 26

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

2: Application Layer

10

header

body

blank

line

11 of 26

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: gmail, Hotmail, Yahoo! Mail, etc.

​

2: Application Layer

11

user

agent

sender’s mail

server

user

agent

SMTP

SMTP

access

protocol

receiver’s mail

server

12 of 26

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

2: Application Layer

12

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

13 of 26

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

2: Application Layer

13

14 of 26

Chapter 2: Application layer

  • Email
  • DNS

​

2: Application Layer

14

15 of 26

DNS: Domain Name System

People: many identifiers:

    • SSN, name, passport #

Internet hosts, routers:

    • IP address (32 bit) - used for addressing datagrams
    • “name”, e.g., ww.yahoo.com - used by humans

Q: map between IP addresses and name ?

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”

2: Application Layer

15

16 of 26

DNS

Why not centralize DNS?

  • single point of failure
  • traffic volume
  • distant centralized database
  • Maintenance
  • doesn’t scale!

DNS services

  • hostname to IP address translation
  • host aliasing
    • Canonical, alias names
  • mail server aliasing
  • load distribution
    • replicated Web servers: set of IP addresses for one canonical name

​

2: Application Layer

16

17 of 26

Distributed, Hierarchical Database

Client wants IP for www.amazon.com; 1st approx:

  • client queries a root server to find com DNS server
  • client queries com DNS server to get amazon.com DNS server
  • client queries amazon.com DNS server to get IP address for www.amazon.com

2: Application Layer

17

Root DNS Servers

com DNS servers

org DNS servers

edu DNS servers

poly.edu

DNS servers

umass.edu

DNS servers

yahoo.com

DNS servers

amazon.com

DNS servers

pbs.org

DNS servers

18 of 26

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

2: Application Layer

18

13 root name servers worldwide

b USC-ISI Marina del Rey, CA

l ICANN Los Angeles, CA

​

e NASA Mt View, CA

f Internet Software C. Palo Alto, CA (and 36 other locations)

​

i Autonomica, Stockholm (plus 28 other locations)

k RIPE London (also 16 other locations)

m WIDE Tokyo (also Seoul, Paris, SF)

a Verisign, Dulles, VA

c Cogent, Herndon, VA (also LA)

d U Maryland College Park, MD

g US DoD Vienna, VA

h ARL Aberdeen, MD

j Verisign, ( 21 locations)

​

19 of 26

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, mail).
    • can be maintained by organization or service provider

​

2: Application Layer

19

20 of 26

Local Name Server

  • does not strictly belong to hierarchy
  • each ISP (residential ISP, company, university) has one.
    • also called “default name server”
  • when host makes DNS query, query is sent to its local DNS server
    • acts as proxy, forwards query into hierarchy

2: Application Layer

20

21 of 26

DNS name �resolution example

  • Host at cis.poly.edu wants IP address for gaia.cs.umass.edu

2: Application Layer

21

requesting host

cis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS server

dns.poly.edu

1

2

3

4

5

6

authoritative DNS server

dns.cs.umass.edu

7

8

TLD DNS server

iterated query:

  • contacted server replies with name of server to contact
  • “I don’t know this name, but ask this server”

22 of 26

DNS name �resolution example

2: Application Layer

22

requesting host

cis.poly.edu

gaia.cs.umass.edu

root DNS server

local DNS server

dns.poly.edu

1

2

4

5

6

authoritative DNS server

dns.cs.umass.edu

7

8

TLD DNS server

3

recursive query:

  • puts burden of name resolution on contacted name server
  • heavy load?

23 of 26

DNS: caching and updating records

  • once (any) name server learns mapping, it caches mapping
    • cache entries timeout (disappear) after some time
    • TLD servers typically cached in local name servers
      • Thus root name servers not often visited
  • update/notify mechanisms under design by IETF
    • RFC 2136
    • http://www.ietf.org/html.charters/dnsind-charter.html

2: Application Layer

23

24 of 26

DNS records

2: Application Layer

24

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
    • (foo.com, dns.foo.com, NS)

​

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

  • Type=A
    • name is hostname
    • value is IP address
    • (relay1.bar.foo.com, 145.37.93.126, A)

​

  • 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
    • (foo.com, relay1.bar.foo.com, CNAME)

​

  • Type=MX
    • value is name of mailserver associated with name
    • (foo.com, mail.bar.foo.com, MX)

​

25 of 26

Example 1

  • Suppose an edu TLD server is not authoritative for the host “gaia.cs.umass.edu”.
  • This edu server will contain:
    • A record for an (authoritative) domain that includes the host gaia.cs.umass.edu:

(umass.edu, dns.umass.edu, NS)

    • And the edu TLD server would also contain a Type A record, which maps the DNS server dns.umass.edu to an IP address:

(dns.umass.edu, 128.119.40.111, A)

2: Application Layer

25

26 of 26

Example 2

  • new startup “Network Utopia”
  • register name networkutopia.com at DNS registrar (e.g., Network Solutions)
    • provide names, IP addresses of authoritative name server (primary and secondary)
    • registrar inserts two RRs into com TLD server:�

(networkutopia.com, dns1.networkutopia.com, NS)

(dns1.networkutopia.com, 212.212.212.1, A)�

  • create authoritative server Type A record for www.networkuptopia.com;
  • and Type MX record for networkutopia.com
  • So, How do people get IP address of your Web site?

​

2: Application Layer

26