0% found this document useful (0 votes)
34 views42 pages

Ch2 Part2

This chapter discusses the application layer, including email protocols like SMTP and IMAP. It explains that email uses three main components: user agents, mail servers, and the SMTP protocol. SMTP uses TCP to reliably transfer messages between mail servers. It also discusses DNS, which is a distributed database that translates between hostnames and IP addresses.

Uploaded by

J3fr Sory
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views42 pages

Ch2 Part2

This chapter discusses the application layer, including email protocols like SMTP and IMAP. It explains that email uses three main components: user agents, mail servers, and the SMTP protocol. SMTP uses TCP to reliably transfer messages between mail servers. It also discusses DNS, which is a distributed database that translates between hostnames and IP addresses.

Uploaded by

J3fr Sory
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 42

Chapter 2

Application
Layer

Computer Networking: A
Top-Down Approach
8th edition n
Jim Kurose, Keith Ross
Pearson, 2020
Application Layer: 2-1
Application layer: overview
 P2P applications
 Principles of network  video streaming and content
applications distribution networks
 Web and HTTP  socket programming with
 E-mail, SMTP, IMAP UDP and TCP
 The Domain Name System
DNS

Application Layer: 2-2


E-mail user
agent
Three major components: mail user
 user agents server agent

 mail servers SMTP mail user


server agent
 simple mail transfer protocol: SMTP SMTP

User Agent SMTP user


agent
mail
 a.k.a. “mail reader” server
user
 composing, editing, reading mail messages agent

 e.g., Outlook, iPhone mail client user


agent
 outgoing, incoming messages stored on outgoing
message queue
server user mailbox

Application Layer: 2-3


E-mail: mail servers user
agent
mail servers: mail user
server agent
 mailbox contains incoming
messages for user SMTP mail user
server agent
 message queue of outgoing (to be SMTP
sent) mail messages
SMTP user
SMTP protocol between mail mail
server
agent

servers to send email messages user


agent
 client: sending mail server user
 “server”: receiving mail server agent
outgoing
message queue
user mailbox

Application Layer: 2-4


SMTP RFC (5321) “client”
SMTP server
“server”
SMTP server

 uses TCP to reliably transfer email message


initiate TCP
from client (mail server initiating connection
connection) to server, port 25 RTT
 direct transfer: sending server (acting like client) TCP connection
initiated
to receiving server
 three phases of transfer 220
• SMTP handshaking (greeting) SMTP HELO
handshaking
• SMTP transfer of messages 250 Hello
• SMTP closure
 command/response interaction (like HTTP) SMTP
• commands: ASCII text transfers
• response: status code and phrase time
Application Layer: 2-5
Scenario: Alice sends e-mail to Bob
1) Alice uses UA to compose e-mail 4) SMTP client sends Alice’s message
message “to” [email protected] over the TCP connection
2) Alice’s UA sends message to her 5) Bob’s mail server places
mail server using SMTP; message the message in Bob’s
placed in message queue mailbox
3) client side of SMTP at mail server 6) Bob invokes his user
opens TCP connection with Bob’s mail agent to read message
server

1 user mail user


mail agent
agent server server
2 3 6
4
5
Alice’s mail server Bob’s mail server
Application Layer: 2-6
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
Application Layer: 2-7
SMTP: observations
comparison with HTTP:  SMTP uses persistent
 HTTP: client pull connections
 SMTP: client push  SMTP requires message
(header & body) to be in
 both have ASCII command/response 7-bit ASCII
interaction, status codes  SMTP server uses
CRLF.CRLF to determine
 HTTP: each object encapsulated in its end of message
own response message
 SMTP: multiple objects sent in
multipart message
Application Layer: 2-8
Mail message format
SMTP: protocol for exchanging e-mail messages, defined in RFC 5321
(like RFC 7231 defines HTTP)
RFC 2822 defines syntax for e-mail message itself (like HTML defines
syntax for web documents)
 header lines, e.g., header
blank
• To: line
• From:
• Subject:
these lines, within the body of the email body
message area different from SMTP MAIL FROM:,
RCPT TO: commands!
 Body: the “message” , ASCII characters only
Application Layer: 2-9
Retrieving email: mail access protocols
user
e-mail access user
SMTP SMTP protocol
agent agent
(e.g., IMAP,
HTTP)

sender’s e-mail receiver’s e-mail


server server

 SMTP: delivery/storage of e-mail messages to receiver’s server


 mail access protocol: retrieval from server
• IMAP: Internet Mail Access Protocol [RFC 3501]: messages stored on server, IMAP
provides retrieval, deletion, folders of stored messages on server
 HTTP: gmail, Hotmail, Yahoo!Mail, etc. provides web-based interface on
top of STMP (to send), IMAP (or POP) to retrieve e-mail messages
Application Layer: 2-10
Application Layer: Overview
 P2P applications
 Principles of network  video streaming and content
applications distribution networks
 Web and HTTP  socket programming with
 E-mail, SMTP, IMAP UDP and TCP
 The Domain Name System
DNS

Application Layer: 2-11


DNS: Domain Name System
people: many identifiers: Domain Name System (DNS):
• SSN, name, passport #  distributed database implemented in
Internet hosts, routers: hierarchy of many name servers
• IP address (32 bit) - used for  application-layer protocol: hosts, DNS
addressing datagrams servers communicate to resolve
• “name”, e.g., cs.umass.edu - names (address/name translation)
used by humans
• note: core Internet function,
Q: how to map between IP implemented as application-layer
address and name, and vice protocol
versa ?
• complexity at network’s “edge”

Application Layer: 2-12


DNS: services, structure
DNS services: Q: Why not centralize DNS?
 hostname-to-IP-address translation  single point of failure
 traffic volume
 host aliasing
 distant centralized database
• canonical, alias names
 maintenance
 mail server aliasing
 load distribution A: doesn‘t scale!
• replicated Web servers: many IP  Comcast DNS servers alone:
addresses correspond to one 600B DNS queries/day
name  Akamai DNS servers alone:
2.2T DNS queries/day

Application Layer: 2-13


Thinking about the DNS
humongous distributed database:
 ~ billion records, each simple
handles many trillions of queries/day:
 many more reads than writes
 performance matters: almost every
Internet transaction interacts with
DNS - msecs count!
organizationally, physically decentralized:
 millions of different organizations
responsible for their records
“bulletproof”: reliability, security
Application Layer: 2-14
DNS: a distributed, hierarchical database
Root DNS Servers Root
… …
.com DNS servers .org DNS servers .edu DNS servers Top Level Domain
… … … …
yahoo.com amazon.com pbs.org nyu.edu umass.edu
DNS servers DNS servers DNS servers DNS servers DNS servers Authoritative

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


 client queries 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
Application Layer: 2-15
DNS: root name servers
 official, contact-of-last-resort by
name servers that can not
resolve name

Application Layer: 2-16


DNS: root name servers
 official, contact-of-last-resort by
name servers that can not 13 logical root name “servers”
worldwide each “server” replicated
resolve name many times (~200 servers in US)
 incredibly important Internet
function
• Internet couldn’t function without it!
• DNSSEC – provides security
(authentication, message integrity)
 ICANN (Internet Corporation for
Assigned Names and Numbers)
manages root DNS domain

Application Layer: 2-17


Top-Level Domain, and authoritative servers
Top-Level Domain (TLD) servers:
 responsible for .com, .org, .net, .edu, .aero, .jobs, .museums, and all top-level
country domains, e.g.: .cn, .uk, .fr, .ca, .jp
 Network Solutions: authoritative registry for .com, .net TLD
 Educause: .edu TLD

authoritative DNS 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

Application Layer: 2-18


Local DNS name servers
 when host makes DNS query, it is sent to its local DNS server
• Local DNS server returns reply, answering:
• from its local cache of recent name-to-address translation pairs (possibly out
of date!)
• forwarding request into DNS hierarchy for resolution
• each ISP has local DNS name server; to find yours:
• MacOS: % scutil --dns
• Windows: >ipconfig /all
 local DNS server doesn’t strictly belong to hierarchy

Application Layer: 2-19


DNS name resolution: iterated query
root DNS server
Example: host at engineering.nyu.edu
wants IP address for gaia.cs.umass.edu 2
3
TLD DNS server
Iterated query: 1 4

 contacted server replies 8 5


with name of server to requesting host at local DNS server
contact engineering.nyu.edu dns.nyu.edu
gaia.cs.umass.edu
 “I don’t know this name, 7 6
but ask this server”
authoritative DNS server
dns.cs.umass.edu

Application Layer: 2-20


DNS name resolution: recursive query
root DNS server
Example: host at engineering.nyu.edu
wants IP address for gaia.cs.umass.edu 2 3

7 6
Recursive query: 1 TLD DNS server
 puts burden of name 8
resolution on requesting host at local DNS server
5 4
engineering.nyu.edu dns.nyu.edu
contacted name gaia.cs.umass.edu

server
 heavy load at upper authoritative DNS server
levels of hierarchy? dns.cs.umass.edu

Application Layer: 2-21


Caching DNS Information
 once (any) name server learns mapping, it caches mapping,
and immediately returns a cached mapping in response to a
query
• caching improves response time
• cache entries timeout (disappear) after some time (TTL)
• TLD servers typically cached in local name servers
 cached entries may be out-of-date
• if named host changes IP address, may not be known Internet-
wide until all TTLs expire!
• best-effort name-to-address translation!

Application Layer: 2-22


DNS records
DNS: distributed database storing resource records (RR)
RR format: (name, value, type, ttl)

type=A type=CNAME
 name is hostname  name is alias name for some “canonical” (the
 value is IP address real) name
 www.ibm.com is really servereast.backup2.ibm.com
type=NS  value is canonical name
 name is domain (e.g., foo.com)
 value is hostname of
type=MX
authoritative name server for  value is name of SMTP mail server
this domain associated with name
Application Layer: 2-23
DNS protocol messages
DNS query and reply messages, both have same format:
2 bytes 2 bytes

message header: identification flags

 identification: 16 bit # for query, # questions # answer RRs

reply to query uses same # # authority RRs # additional RRs


 flags:
questions (variable # of questions)
• query or reply
• recursion desired
answers (variable # of RRs)
• recursion available
• reply is authoritative authority (variable # of RRs)

additional info (variable # of RRs)

Application Layer: 2-24


DNS protocol messages
DNS query and reply messages, both have same format:
2 bytes 2 bytes

identification flags

# questions # answer RRs

# authority RRs # additional RRs

name, type fields for a query questions (variable # of questions)

RRs in response to query answers (variable # of RRs)

records for authoritative servers authority (variable # of RRs)

additional “ helpful” info that may additional info (variable # of RRs)


be used
Application Layer: 2-25
Getting your info into the DNS
example: new startup “Network Utopia”
 register name networkuptopia.com at DNS registrar (e.g., Network
Solutions)
• provide names, IP addresses of authoritative name server (primary and
secondary)
• registrar inserts NS, A RRs into .com TLD server:
(networkutopia.com, dns1.networkutopia.com, NS)
(dns1.networkutopia.com, 212.212.212.1, A)
 create authoritative server locally with IP address 212.212.212.1
• type A record for www.networkuptopia.com
• type MX record for networkutopia.com

Application Layer: 2-26


Application Layer: Overview
 P2P applications
 Principles of network  video streaming and content
applications distribution networks
 Web and HTTP  socket programming with
 E-mail, SMTP, IMAP UDP and TCP
 The Domain Name System
DNS

Application Layer: 2-27


Peer-to-peer (P2P) architecture
 no always-on server mobile network
 arbitrary end systems directly national or global ISP

communicate
 peers request service from other
peers, provide service in return to
other peers local or
regional ISP
• self scalability – new peers bring new
service capacity, and new service demands home network content
provider
 peers are intermittently connected network datacenter
network
and change IP addresses
• complex management
 examples: P2P file sharing (BitTorrent), enterprise
network
streaming (KanKan), VoIP (Skype)
Application Layer: 2-28
File distribution: client-server vs P2P
Q: how much time to distribute file (size F) from one server to N
peers?
• peer upload/download capacity is limited resource
us: server upload
capacity
di: peer i download
file, size F u1 d1 u2 capacity
us d2
server
di
uN network (with abundant
bandwidth) ui
dN
ui: peer i upload
capacity
Introduction: 1-29
File distribution time: client-server
 server transmission: must sequentially
send (upload) N file copies:
F
• time to send one copy: F/us us

• time to send N copies: NF/us di


network
ui
 client: each client must download
file copy
• dmin = min client download rate
• min client download time: F/dmin
time to distribute F
to N clients using
Dc-s > max{NF/us,,F/dmin}
client-server approach

increases linearly in N Introduction: 1-30


File distribution time: P2P
 server transmission: must upload at
least one copy:
F
• time to send one copy: F/us us

 client: each client must download di


network
file copy ui
• min client download time: F/dmin
 clients: as aggregate must download NF bits
• max upload rate (limiting max download rate) is us + Sui

time to distribute F
to N clients using
P2P approach
DP2P > max{F/us,,F/dmin,,NF/(us + Sui)}
increases linearly in N …
… but so does this, as each peer brings service capacity Application Layer: 2-31
Client-server vs. P2P: example
client upload rate = u, F/u = 1 hour, us = 10u, dmin ≥ us
3.5
P2P

Minimum Distribution Time


3
Client-Server
2.5

1.5

0.5

0
0 5 10 15 20 25 30 35

N
Application Layer: 2-32
Application Layer: Overview
 P2P applications
 Principles of network  video streaming and content
applications distribution networks
 Web and HTTP  socket programming with
 E-mail, SMTP, IMAP UDP and TCP
 The Domain Name System
DNS

Application Layer: 2-33


Socket programming
goal: learn how to build client/server applications that
communicate using sockets
socket: door between application process and end-end-transport
protocol
application application
socket controlled by
process process app developer

transport transport
network network controlled
link
by OS
link Internet
physical physical

Application Layer: 2-34


Socket programming
Two socket types for two transport services:
 UDP: unreliable datagram
 TCP: reliable, byte stream-oriented
Application Example:
1. client reads a line of characters (data) from its keyboard and sends
data to server
2. server receives the data and converts characters to uppercase
3. server sends modified data to client
4. client receives modified data and displays line on its screen

Application Layer: 2-35


Socket programming with UDP
UDP: no “connection” between
client and server:
 no handshaking before sending data
 sender explicitly attaches IP destination
address and port # to each packet
 receiver extracts sender IP address and
port# from received packet

UDP: transmitted data may be lost or received out-of-order


Application viewpoint:
 UDP provides unreliable transfer of groups of bytes (“datagrams”)
between client and server processes
Application Layer: 2-36
Client/server socket interaction: UDP
server (running on serverIP) client
create socket:
create socket, port= x: clientSocket =
serverSocket = socket(AF_INET,SOCK_DGRAM)
socket(AF_INET,SOCK_DGRAM)
Create datagram with serverIP address
And port=x; send datagram via
read datagram from clientSocket
serverSocket

write reply to
serverSocket read datagram from
specifying clientSocket
client address,
port number close
clientSocket
Application Layer: 2-37
Socket programming with TCP
Client must contact server  when contacted by client, server
 server process must first be running TCP creates new socket for server
 server must have created socket
process to communicate with that
(door) that welcomes client’s particular client
contact • allows server to talk with multiple
clients
Client contacts server by: • source port numbers used to
 Creating TCP socket, specifying IP distinguish clients (more in Chap 3)
address, port number of server
process Application viewpoint
 when client creates socket: client TCP provides reliable, in-order
TCP establishes connection to byte-stream transfer (“pipe”)
server TCP between client and server
processes
Application Layer: 2-38
Client/server socket interaction: TCP
server (running on hostid) client
create socket,
port=x, for incoming
request:
serverSocket = socket()

wait for incoming create socket,


connection request
TCP connect to hostid, port=x
connectionSocket = connection setup clientSocket = socket()
serverSocket.accept()

send request using


read request from clientSocket
connectionSocket

write reply to
connectionSocket read reply from
clientSocket
close
connectionSocket close
clientSocket
Application Layer: 2-39
Chapter 2: Summary
our study of network application layer is now complete!
 application architectures  specific protocols:
• client-server • HTTP
• P2P • SMTP, IMAP
• DNS
 application service requirements:
• P2P: BitTorrent
• reliability, bandwidth, delay
 video streaming, CDNs
 Internet transport service model  socket programming:
• connection-oriented, reliable: TCP
TCP, UDP sockets
• unreliable, datagrams: UDP

Application Layer: 2-40


Chapter 2: Summary
Most importantly: learned about protocols!
 typical request/reply message important themes:
exchange:  centralized vs. decentralized
• client requests info or service  stateless vs. stateful
• server responds with data, status code  scalability
 message formats:  reliable vs. unreliable
• headers: fields giving info about data message transfer
• data: info(payload) being  “complexity at network
communicated
edge”

Application Layer: 2-41


Thank you

Introduction: 1-42

You might also like