application 1 - networking
TRANSCRIPT
-
8/12/2019 Application 1 - Networking
1/82
2: Application Layer 1
CMPT 371
Data Communicationsand Networking
Chapter 2Application Layer
-
8/12/2019 Application 1 - Networking
2/82
2: Application Layer 2
Chapter 2: Application Layer
Our goals: conceptual,
implementationaspects of network
application protocols transport-layer
service models
client-server
paradigm peer-to-peer
paradigm
learn about protocolsby examining popularapplication-levelprotocols
HTTP FTP
SMTP / POP3 / IMAP
DNS
programming networkapplications socket API
-
8/12/2019 Application 1 - Networking
3/82
2: Application Layer 3
Chapter 2 outline
2.1 Principles of app layer protocols
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
2.6 Content distribution
Network Web caching Content distribution networks
P2P file sharing
-
8/12/2019 Application 1 - Networking
4/82
2: Application Layer 4
Network applications
Applications -> Software
What exactly running in a computer ?
-
8/12/2019 Application 1 - Networking
5/82
2: Application Layer 5
Network applications: some jargon
Process:program runningwithin a host.
implements user
interface &application-levelprotocol Web: browser
E-mail: mail reader streaming audio/video:
media player
within same host, twoprocesses communicateusing interprocesscommunication(defined
by OS). processes running in
different hostscommunicate with an
application-layerprotocol
-
8/12/2019 Application 1 - Networking
6/82
2: Application Layer 6
Applications and application-layer protocols
Application: communicating,distributed processes e.g., e-mail, Web, P2P file
sharing, instant messaging running in end systems
(hosts) exchange messages to
implement application
Application-layer protocols one piece of an app
define messagesexchanged by apps andactions taken
use communication servicesprovided by lower layer
protocols (TCP, UDP)
applicationtransportnetworkdata linkphysical
applicationtransport
networkdata linkphysical
application
transportnetworkdata linkphysical
-
8/12/2019 Application 1 - Networking
7/82
2: Application Layer 7
App-layer protocol defines
Types of messagesexchanged, e.g., request& response messages
Syntax of message
types: what fields inmessages & how fieldsare delineated
Semantics of the fields,i.e., meaning ofinformation in fields
Rules for when and howprocesses send &respond to messages
Public-domain protocols:
defined in RFCs
allows for
interoperability eg, HTTP, SMTP
Proprietary protocols:
eg, Skype
BitTorrent (?)
-
8/12/2019 Application 1 - Networking
8/82
2: Application Layer 8
Client-server paradigm
Typical network app has twopieces: clientand serverapplicationtransportnetworkdata linkphysical
applicationtransport
networkdata linkphysical
Client: initiates contact with server
(speaks first) typically requests service from
server,
Web: client implemented inbrowser; e-mail: in mail reader
request
reply
Server: provides requested service to client
e.g., Web server sends requested Webpage, mail server delivers e-mail
-
8/12/2019 Application 1 - Networking
9/82
2: Application Layer 9
Programming - Socket
process sends/receivesmessages to/from itssocket
socket analogous to door sending process shoves
message out door
sending process assumestransport infrastructureon other side of door whichbrings message to socketat receiving process
process
TCP/UDP
with
buffers,
variables
socket
host orserver
process
TCP/UDP
with
buffers,
variables
socket
host orserver
Internet
controlledby OS
controlled by
app developer
API: Application Programmers Interface
(1) choose transport protocol; (2) set parameters (You might havelearnt it; or you can study it in 471)
-
8/12/2019 Application 1 - Networking
10/82
2: Application Layer 10
Outside of the door Transport Layer Service
Data loss some apps (e.g., audio) can
tolerate some loss
other apps (e.g., file transfer,
telnet) require 100% reliabledata transfer
Timing some apps (e.g.,
Internet telephony,interactive games)require low delay to beeffective
Bandwidth some apps (e.g.,
multimedia) requireminimum amount of
bandwidth to beeffective
other apps (elasticapps) make use of
whatever bandwidththey get
-
8/12/2019 Application 1 - Networking
11/82
2: Application Layer 11
Transport service requirements of common apps
Application
file transfer
e-mail
Web documentsreal-time audio/video
stored audio/video
interactive games
instant messaging
Data loss
no loss
no loss
no lossloss-tolerant
loss-tolerant
loss-tolerant
no loss
Bandwidth
elastic
elastic
elasticaudio: 5kbps-1Mbps
video:10kbps-5Mbps
same as above
few kbps up
elastic
Time Sensitive
no
no
noyes, 100s msec
yes, few secs
yes, 100s msec
yes and no
-
8/12/2019 Application 1 - Networking
12/82
2: Application Layer 12
Internet apps: application, transport protocols
Application
e-mail
remote terminal access
Webfile transfer
streaming multimedia
Internet telephony
Applicationlayer protocol
SMTP [RFC 2821]
Telnet [RFC 854]
HTTP [RFC 2616]FTP [RFC 959]
proprietary
(e.g. RealNetworks)
proprietary
(e.g., Dialpad)
Underlyingtransport protocol
TCP
TCP
TCPTCP
TCP or UDP
typically UDP
-
8/12/2019 Application 1 - Networking
13/82
2: Application Layer 13
Chapter 2 outline
2.1 Principles of app layer protocols
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
2.6 Content distribution
Network Web caching Content distribution networks
P2P file sharing
-
8/12/2019 Application 1 - Networking
14/82
2: Application Layer 14
Web and HTTP
First some jargon
Web pageconsists of objects
Object can be HTML file, JPEG image, Java
applet, audio file, Most Web sites have a base HTML-filewhich
includes several referenced objects
Each object is addressable by a URL
Example URL:http://www.cs.sfu.ca/~jcliu/cmpt371/index.htm
host name path name
-
8/12/2019 Application 1 - Networking
15/82
2: Application Layer 15
HTTP overview
HTTP: hypertexttransfer protocol
Webs application layerprotocol
client/server modelclient:browser that
requests, receives,displays Web objects
server:Web server
sends objects inresponse to requests
HTTP 1.0: RFC 1945
HTTP 1.1: RFC 2068
PC runningExplorer
Serverrunning
Apache Web
server
Mac runningNavigator
-
8/12/2019 Application 1 - Networking
16/82
2: Application Layer 16
Is it difficult to write a Browser ?
MS Internet ExplorerSafari
Opera http://www.opera.com/ (15.3MB)
Mozilla http://www.mozilla.org/ (11.7MB)FireFox http://www.mozilla.com/en-US/firefox/
Chrome
http://www.opera.com/http://www.mozilla.org/http://www.mozilla.com/en-US/firefox/http://www.mozilla.com/en-US/firefox/http://www.mozilla.com/en-US/firefox/http://www.mozilla.com/en-US/firefox/http://www.mozilla.org/http://www.opera.com/ -
8/12/2019 Application 1 - Networking
17/82
2: Application Layer 17
Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server:
Opens TCP connection to port 80(default HTTP server port) at www.cs.sfu.ca
Anything typed in sentto port 80
telnet www.cs.sfu.ca 80
2. Type in a GET HTTP request:GET
or
GET /~jcliu/index.htm
You have sent this minimal (but complete)GET request to HTTP server
And you have received HTML objects !
-
8/12/2019 Application 1 - Networking
18/82
2: Application Layer 18
Is it difficult to write a Browser ?
Implement HTTP - network
Implement a GUI - local
Anymore ?
Internet ExplorerChrome
FireFox
Efficiency, fault-tolerant, compatibility, security, Java-support, multi-language
-
8/12/2019 Application 1 - Networking
19/82
2: Application Layer 19
HTTP overview (continued)
Uses TCP: client initiates TCP
connection (creates socket)to server, port 80
server accepts TCPconnection from client
HTTP messages (application-layer protocol messages)exchanged between browser
(HTTP client) and Webserver (HTTP server)
TCP connection closed
HTTP is stateless server maintains no
information aboutpast client requests
Protocols that maintainstate are complex!
past history (state) mustbe maintained
if server/client crashes,their views of state maybe inconsistent, must bereconciled
aside
-
8/12/2019 Application 1 - Networking
20/82
2: Application Layer 20
HTTP request message
two types of HTTP messages: request, response
HTTP request message: ASCII (human-readable format)
GET /somedir/page.html HTTP/1.1
Host: www.someschool.edu
User-agent: Mozilla/4.0
Connection: close
Accept-language:fr
(extra carriage return, line feed)
request line(GET, POST,
HEAD commands)
header
lines
Carriage return,line feed
indicates end
of message
-
8/12/2019 Application 1 - Networking
21/82
2: Application Layer 21
HTTP request message: general format
-
8/12/2019 Application 1 - Networking
22/82
2: Application Layer 22
Uploading form input
Post method:
Web page oftenincludes form input
Input is uploaded toserver in entity body
URL method:
Uses GET method Input is uploaded in
URL field of requestline:
www.somesite.com/animalsearch?monkeys&banana
-
8/12/2019 Application 1 - Networking
23/82
2: Application Layer 23
Method types
HTTP/1.0
GET
POST
HEAD asks server to leave
requested object out ofresponse
debugging
HTTP/1.1
GET, POST, HEAD
PUT
uploads file in entitybody to path specifiedin URL field
DELETE deletes file specified in
the URL field
-
8/12/2019 Application 1 - Networking
24/82
2: Application Layer 24
HTTP response message
HTTP/1.1 200 OK
Connection close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
Last-Modified: Mon, 22 Jun 1998 ...
Content-Length: 6821
Content-Type: text/html
data data data data data ...
status line(protocol
status codestatus phrase)
headerlines
data, e.g.,
requestedHTML file
-
8/12/2019 Application 1 - Networking
25/82
2: Application Layer 25
HTTP response status codes
200 OK request succeeded, requested object later in this message
301 Moved Permanently requested object moved, new location specified later in
this message (Location:)
400 Bad Request
request message not understood by server404 Not Found
requested document not found on this server
505 HTTP Version Not Supported
In first line in server->client response message.A few sample codes:
-
8/12/2019 Application 1 - Networking
26/82
2: Application Layer 26
HTTP connections
Nonpersistent HTTP
At most one object issent over a TCPconnection.
HTTP/1.0 usesnonpersistent HTTP
Persistent HTTP
Multiple objects canbe sent over singleTCP connectionbetween client andserver.
HTTP/1.1 usespersistent connections
in default mode
-
8/12/2019 Application 1 - Networking
27/82
2: Application Layer 27
Nonpersistent HTTPSuppose user enters URLwww.someSchool.edu/someDepartment/home.index
1a.HTTP client initiates TCPconnection to HTTP server(process) atwww.someSchool.edu on port
80
2.HTTPclient sends HTTPrequest message(containingURL) into TCP connection
socket. Message indicatesthat client wants objectsomeDepartment/home.index
1b.HTTPserver at hostwww.someSchool.edu waiting
for TCP connection at port 80.accepts connection, notifyingclient
3.HTTPserver receives request
message, forms responsemessagecontaining requestedobject, and sends messageinto its socket
time
(contains text,
references to 10
jpeg images)
-
8/12/2019 Application 1 - Networking
28/82
2: Application Layer 28
Nonpersistent HTTP (cont.)
5.HTTP client receives responsemessage containing html file,displays html. Parsing htmlfile, finds 10 referenced jpegobjects
6.Steps 1-5 repeated for eachof 10 jpeg objects
4.HTTPserver closes TCPconnection.
time
-
8/12/2019 Application 1 - Networking
29/82
2: Application Layer 29
Response time modeling
Definition of RTT:time tosend a small packet totravel from client toserver and back.
time to
transmit
file
initiate TCP
connection
RTT
request
file
RTT
file
received
time time
Response time: one RTT to initiate TCP
connection
one RTT for HTTP
request and first fewbytes of HTTP responseto return
file transmission time
total = 2RTT+transmit time
-
8/12/2019 Application 1 - Networking
30/82
2: Application Layer 30
Nonpersistent HTTP issues
requires at least 2 RTTs per object so browsers often open parallel TCP connections
to fetch referenced objects
but OS must work and allocate host resources
for each TCP connection
-
8/12/2019 Application 1 - Networking
31/82
2: Application Layer 31
Persistent HTTP
server leaves connection open after sending
response subsequent HTTP messages between same
client/server are sent over connection
Persistent without pipelining:
client issues new request only when previous responsehas been received
one RTT for each referenced object
Persistent with pipelining:
default in HTTP/1.1 client sends requests as soon as it encounters a
referenced object
as little as one RTT for all the referenced objects
-
8/12/2019 Application 1 - Networking
32/82
2: Application Layer 32
User-server interaction: authorization
Authorization :control access toserver content
authorization credentials:typically name, password
stateless:client must present
authorization in eachrequest authorization:header line in
each request
if no authorization:header,server refuses access,
sendsWWW authenticate:
header line in response
client serverusual http request msg
401: authorization req.WWW authenticate:
usual http request msg+ Authorization:
usual http response msg
usual http request msg+ Authorization:
usual http response msg time
-
8/12/2019 Application 1 - Networking
33/82
2: Application Layer 33
Cookies: keeping state
Many Web sites usecookies
Example: You access Internet
always from same PC
You visit a specific e-
commerce site for firsttime
When initial HTTPrequests arrives at site,site creates a unique ID
and creates an entry inbackend database forID
-
8/12/2019 Application 1 - Networking
34/82
2: Application Layer 34
Cookies: keeping state
Many major Web sitesuse cookies
Four components:1) cookie header line in
the HTTP responsemessage
2) cookie header line inHTTP request message
3) cookie file kept onusers host and managedby users browser
4) back-end database atWeb site
-
8/12/2019 Application 1 - Networking
35/82
2: Application Layer 35
Cookies: keeping state (cont.)
client serverusual http request msg
usual http response +Set-cookie: 1678
usual http request msgcookie: 1678
usual http response msg
usual http request msgcookie: 1678
usual http response msg
cookie-specificaction
cookie-spectific
action
servercreates ID
1678 for user
Cookie file
amazon: 1678
ebay: 8734
Cookie file
ebay: 8734
Cookie file
amazon: 1678
ebay: 8734
one week later:
-
8/12/2019 Application 1 - Networking
36/82
2: Application Layer 36
Cookies (continued)
What cookies can bring: authorization
shopping carts
recommendations
user session state(Web e-mail)
Cookies and privacy: cookies permit sites to
learn a lot about you
you may supply name
and e-mail to sites search engines use
redirection & cookiesto learn yet more
advertising companiesobtain info acrosssites
aside
-
8/12/2019 Application 1 - Networking
37/82
2: Application Layer 37
Cookies: Enable/Disable
-
8/12/2019 Application 1 - Networking
38/82
2: Application Layer 38
Cookies: Delelte
-
8/12/2019 Application 1 - Networking
39/82
2: Application Layer 39
Chapter 2 outline
2.1 Principles of app layer protocols
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
2.6 Content distribution
Network Web caching Content distribution networks
P2P file sharing
-
8/12/2019 Application 1 - Networking
40/82
2: Application Layer 40
FTP: the file transfer protocol
transfer file to/from remote host
client/server model
client:side that initiates transfer (either to/from
remote)server:remote host
ftp: RFC 959
ftp server: port 21
file transferFTP
server
FTPuser
interface
FTPclient
local file
system
remote file
system
userat host
-
8/12/2019 Application 1 - Networking
41/82
-
8/12/2019 Application 1 - Networking
42/82
2: Application Layer 42
FTP commands, responses
Sample commands: sent as ASCII text over
control channel
USER username
PASS password LISTreturn list of file in
current directory
RETR filenameretrieves
(gets) file STOR filenamestores
(puts) file onto remotehost
Sample return codes status code and phrase (as
in HTTP) 331 Username OK,
password required 125 data connection
already open;
transfer starting
425 Cant open data
connection 452 Error writing
file
-
8/12/2019 Application 1 - Networking
43/82
2: Application Layer 43
FTP Client Software
-
8/12/2019 Application 1 - Networking
44/82
2: Application Layer 44
Port 21 ?
-
8/12/2019 Application 1 - Networking
45/82
2: Application Layer 45
Secure FTP (http://www.ssh.com/)
ssh never trusts the net; somebodyhostile who has taken over the networkcan only force ssh to disconnect, butcannot decrypted or play back thetraffic, or hijack the connection.
-
8/12/2019 Application 1 - Networking
46/82
-
8/12/2019 Application 1 - Networking
47/82
2: Application Layer 47
Key differences between HTTP & FTP
Stateless vs. stateful
Inband control vs. outband control
Why ?
-
8/12/2019 Application 1 - Networking
48/82
2: Application Layer 48
Chapter 2 outline
2.1 Principles of app layer protocols
2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
2.6 Content distribution
Network Web caching Content distribution networks
P2P file sharing
-
8/12/2019 Application 1 - Networking
49/82
2: Application Layer 49
Electronic Mail
Three major components: user agents
mail servers
mail transfer protocol
User Agent
a.k.a. mail reader
composing, editing, readingmail messages
e.g., Eudora, Outlook, elm,Netscape Messenger
outgoing, incoming messagesstored on server
user mailbox
outgoingmessage queue
mail
server
useragent
useragent
useragent
mailserver
useragent
useragent
mailserver
useragent
-
8/12/2019 Application 1 - Networking
50/82
2: Application Layer 50
Electronic Mail: mail servers
Mail Servers mailboxcontains incoming
messages for user
messagequeueof outgoing
(to be sent) mail messages SMTP protocolbetween mail
servers to send emailmessages
client: sending mail
server server: receiving mail
server
mailserver
useragent
useragent
useragent
mail
server
useragent
useragent
mailserver
user
agent
SMTP
SMTP
SMTP
?
-
8/12/2019 Application 1 - Networking
51/82
2: Application Layer 51
Electronic Mail: SMTP [RFC 2821]
uses TCP to reliably transfer email message from clientto 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
S i Ali d t B b
-
8/12/2019 Application 1 - Networking
52/82
2: Application Layer 52
Scenario: Alice sends message to Bob
1) Alice uses UA to compose
message and [email protected]
2) Alices UA sends messageto her mail server; messageplaced in message queue
3) Client side of SMTP opensTCP connection with Bobsmail server
4) SMTP client sends Alices
message over the TCPconnection
5) Bobs mail server places themessage in Bobs mailbox
6) Bob invokes his user agent
to read message
useragent
mailserver
mailserver user
agent
1
2 3 4 56
-
8/12/2019 Application 1 - Networking
53/82
2: Application Layer 53
Sample SMTP interactionS: 220 hamburger.edu
C: HELO crepes.frS: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM:
S: 250 [email protected]... Sender ok
C: RCPT TO:
S: 250 [email protected] ... Recipient okC: 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/12/2019 Application 1 - Networking
54/82
2: Application Layer 54
Try SMTP interaction for yourself:
telnet servername 25
-
8/12/2019 Application 1 - Networking
55/82
2: Application Layer 55
Try SMTP interaction for yourself:
telnet smtp.sfu.ca25
(mailgate.sfu.ca 465 SSLv2http://www.sfu.ca/itservices/sfuconnect/getstarted/accessmethods/ssl_background_
info.html)
see 220 reply from server enter HELO, MAIL FROM, RCPT TO, DATA, QUIT
commandsabove lets you send email without using email client
(reader)
-- note: SFU IT service has upgraded their systemand now supports only SSL connections
-
8/12/2019 Application 1 - Networking
56/82
2: Application Layer 56
Message format: multimedia extensions
ASCII: http://www.asciitable.com/ MIME: multimedia mail extension, RFC 2045, 2056
additional lines in msg header declare MIME contenttype
From: [email protected]
To: [email protected]: Picture of yummy crepe.
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data ..............................
......base64 encoded data
multimedia data
type, subtype,parameter declaration
method usedto encode data
MIME version
encoded data
MIME
-
8/12/2019 Application 1 - Networking
57/82
2: Application Layer 57
MIME typesContent-Type: type/subtype; parameters
Text example subtypes:plain,
html
Image example subtypes: jpeg,gif
Audio
example subtypes:basic(8-bit mu-law encoded),32kadpcm (32 kbpscoding)
Video example subtypes:mpeg,
quicktime
Application other data that must be
processed by readerbefore viewable
example subtypes:msword, octet-stream
-
8/12/2019 Application 1 - Networking
58/82
2: Application Layer 58
Multipart Type
From: [email protected]
To: [email protected]: Picture of yummy crepe.
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary=StartOfNextPart
--StartOfNextPart
Dear Bob, Please find a picture of a crepe.
--StartOfNextPartContent-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data .....
.........................
......base64 encoded data
--StartOfNextPartDo you want the recipe?
MIME t
-
8/12/2019 Application 1 - Networking
59/82
2: Application Layer 59
MIME typesContent-Type: type/subtype; parameters
An Example: MailEncodingExample.txt------=_NextPart_000_0010_8CEC7DC6.92E25D8CContent-Type: application/octet-stream;
name="readme.scr"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="readme.scr"
TVqQAAMAAAAEAAAA//8AALgAAAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAqAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAUEUA
AEwBAwAAAAAAAAAAAAAAAADgAA8BCwEHAABQAAAAEAAAAGAAAGC+AAAAcAAAAMAAAAAASgAAEAAA
AAIAAAQAAAAAAAAABAAAAAAAAAAA0AAAABAAAAAAAAACAAAAAAAQAAAQAAAAABAAABAAAAAAAAAQ
AAAAAAAAAAAAAADowQAAMAEAAADAAADoAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAABVUFgwAAAAAABgAAAAEAAAAAAAAAAEAAAAAAAAAAAAAAAAAACAAADg
VVBYMQAAAAAAUAAAAHAAAABQAAAABAAAAAAAAAAAAAAAAAAAQAAA4C5yc3JjAAAAABAAAADAAAAA
BAAAAFQAAAAAAAAAAAAAAAAAAEAAAMAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
-
8/12/2019 Application 1 - Networking
60/82
2: Application Layer 60
Coding for MIME
Key issue: Binary data (bit string) to plain text (SMTPmessage)
Simple solution: 8 bit -> one plain text symbol (?)
-
8/12/2019 Application 1 - Networking
61/82
2: Application Layer 61
ASCII Table
Beyond 7 bit? Extended ASCII
Never well defined
-
8/12/2019 Application 1 - Networking
62/82
2: Application Layer 62
Base 64 coding more info (RFC1521)
A 65-character subset of US-ASCII is used, enabling 6bits to be represented per printable character. (Theextra 65th character, "=", is used to signify a specialprocessing function.)
NOTE: This subset has the important property that it is representedidentically in all versions of ISO 646, including US ASCII, and allcharacters in the subset are also represented identically in all versionsof EBCDIC. Other popular encodings, such as the encoding used by theuuencode utility and the base85 encoding specified as part of Level 2PostScript, do not share these properties, and thus do not fulfill theportability requirements a binary transport encoding for mail mustmeet.
-
8/12/2019 Application 1 - Networking
63/82
2: Application Layer 63
Base 64 coding more info (RFC1521)
The 64 characters
A-Z a-z 0-9 + / =
-
8/12/2019 Application 1 - Networking
64/82
2: Application Layer 64
Mail access protocols
useragent
senders mailserver
useragent
? SMTP ?
receivers mailserver
-
8/12/2019 Application 1 - Networking
65/82
2: Application Layer 65
Mail access protocols
SMTP: delivery/storage to receivers 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: Hotmail , Yahoo! Mail, etc.
useragent
senders mailserver
useragent
SMTP SMTP accessprotocol
receivers mailserver
-
8/12/2019 Application 1 - Networking
66/82
2: Application Layer 66
WebMail Hotmail/Gmail SFU Webmail:
webmail.sfu.ca (old)/connect.sfu.ca
-
8/12/2019 Application 1 - Networking
67/82
2: Application Layer 67
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 bynumber
dele:delete
quit
C: list
S: 1 498
S: 2 912
S: .C: retr 1
S:
S: .
C: dele 1
C: retr 2
S:
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: +OKuser successfully logged on
-
8/12/2019 Application 1 - Networking
68/82
2: Application Layer 68
POP3 (more) and IMAP
More about POP3 Previous example uses
download and deletemode.
Bob cannot re-read e-mail if he changesclient
Download-and-keep:copies of messages ondifferent clients
POP3 is statelessacross sessions
newpop.sfu.ca 995SSLv2
IMAP IMAP keeps user state
across sessions: names of folders and
mappings betweenmessage IDs and foldername
Allows user toorganize messages in
folders Partial retrieving -
header
-
8/12/2019 Application 1 - Networking
69/82
2: Application Layer 69
Chapter 2 outline
2.1 Principles of app layer protocols 2.2 Web and HTTP
2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
2.6 Content distribution Network Web caching
Content distribution networks
P2P file sharing
-
8/12/2019 Application 1 - Networking
70/82
2: Application Layer 70
Name vs. ID
People:many identifiers: name, passport #, driving license ID, SIN
Example:
I want to talk to J.C. Liu. -- from Friend
Please tell me you driving license ID. -- fromVisa card service
-
8/12/2019 Application 1 - Networking
71/82
2: Application Layer 71
DNS: Domain Name System
People:many identifiers: SIN, name, passport #
Internet hosts, routers: IP address (32 bit) -
used for addressingdatagrams
name, e.g.,gaia.cs.umass.edu - usedby humans
Q:map between IPaddresses and name ?
Domain Name System: distributed database
implemented in hierarchy ofmany name servers
application-layer protocolhost, routers, name servers tocommunicate to resolvenames(address/name translation)
note: core Internetfunction, implemented asapplication-layer protocol
complexity at networksedge
-
8/12/2019 Application 1 - Networking
72/82
2: Application Layer 72
DNS name servers
no server has all name-to-IP address mappings
local name servers: each ISP, company has
local (default) name server host DNS query first goes
to local name server
authoritative name server: for a host: stores that
hosts IP address, name can perform name/address
translation for that hostsname
Centralize DNS? No single point of failure
traffic volume
distant centralized
database maintenance
doesnt scale!
DNS Cli t S tti
-
8/12/2019 Application 1 - Networking
73/82
2: Application Layer 73
DNS: Client Settings
DN
-
8/12/2019 Application 1 - Networking
74/82
2: Application Layer 74
DNS name servers
local name servers: each ISP, company has local (default) name server
host DNS query first goes to local name server
authoritative name server: for a host: stores that hosts IP address, name can perform name/address translation for that
hosts name
no server has all name-to-IP address mappings
-
8/12/2019 Application 1 - Networking
75/82
Si l DNS l
-
8/12/2019 Application 1 - Networking
76/82
2: Application Layer 76
Simple DNS example
host surf.eurecom.frwants IP address ofgaia.cs.umass.edu
1.contacts its local DNS
server, dns.eurecom.fr2.dns.eurecom.frcontacts
root name server, ifnecessary
3.root name server contacts
authoritative name server,dns.umass.edu,ifnecessary requesting host
surf.eurecom.frgaia.cs.umass.edu
root name server
authorititive name serverdns.umass.edu
local name serverdns.eurecom.fr
1
23
4
5
6
DNS l
-
8/12/2019 Application 1 - Networking
77/82
2: Application Layer 77
DNS example
Root name server: may not know
authoritative nameserver
may know
intermediate nameserver:who tocontact to findauthoritative nameserver
requesting hostsurf.eurecom.fr
gaia.cs.umass.edu
root name server
local name serverdns.eurecom.fr
1
23
4 5
6
authoritative name serverdns.cs.umass.edu
intermediate name serverdns.umass.edu
7
8
DNS it t d i
-
8/12/2019 Application 1 - Networking
78/82
2: Application Layer 78
DNS: iterated queries
recursive query: puts burden of name
resolution oncontacted nameserver
heavy load?
iterated query: contacted server
replies with name of
server to contact I dont know this
name, but ask thisserver
requesting hostsurf.eurecom.fr
gaia.cs.umass.edu
root name server
local name serverdns.eurecom.fr
1
23
4
5 6
authoritative name serverdns.cs.umass.edu
intermediate name serverdns.umass.edu
7
8
iterated query
DNS hi d d ti d
-
8/12/2019 Application 1 - Networking
79/82
2: Application Layer 79
DNS: caching and updating records
once (any) name server learns mapping, it cachesmapping
cache entries timeout (disappear) after sometime
update/notify mechanisms under design by IETF RFC 2136 http://www.ietf.org/html.charters/dnsind-charter.html
DNS d
-
8/12/2019 Application 1 - Networking
80/82
2: Application Layer 80
DNS records
DNS:distributed db storing resource records (RR)
Type=NS nameis domain (e.g.
foo.com) valueis IP address of
authoritative nameserver for this domain
RR format: (name, value, type,ttl)
Type=A
nameis hostname valueis IP address
Type=CNAME
nameis alias name for somecanonical (the real) name
www.ibm.com is reallyservereast.backup2.ibm.com
valueis canonical name
Type=MX valueis name of mailserver
associated with name
DNS t l
-
8/12/2019 Application 1 - Networking
81/82
2: Application Layer 81
DNS protocol, messages
DNS protocol :queryand replymessages, both withsame message format
msg header identification:16 bit #
for query, reply to queryuses same #
flags:
query or reply
recursion desired
recursion available reply is authoritative
DNS t l
-
8/12/2019 Application 1 - Networking
82/82
DNS protocol, messages
Name, type fieldsfor a query
RRs in response
to query
records forauthoritative servers
additional helpfulinfo that may be used