Upload
rengabilla
View
237
Download
0
Embed Size (px)
Citation preview
8/9/2019 Cn Chp2 [Compatibility Mode]
1/300
.
Computer NetworksComputer Networks
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--11June 23, 2010
Application Layer
8/9/2019 Cn Chp2 [Compatibility Mode]
2/300
2.1 Principles of
app layer protocols clients and servers
app requirements
2.6 Socket
programming with TCP 2.7 Socket
programming with UDP
Chapter 2 OutlineChapter 2 Outline
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--22June 23, 2010
. e an 2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
.server
2.9 Contentdistribution Network Web caching Content distribution
networks
P2P file sharing
8/9/2019 Cn Chp2 [Compatibility Mode]
3/300
within same host, twoprocesses communicate
using inter-processcommunication (definedby OS).
implements userinterface &
application-levelprotocol Web: browser
- :
Network ApplicationsNetwork Applications
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--33June 23, 2010
different hostscommunicate with anapplication-layer
protocol
streaming audio/video:media player
Process: program runningwithin a host.
user agent: interfaceswith user above andnetwork below.
8/9/2019 Cn Chp2 [Compatibility Mode]
4/300
8/9/2019 Cn Chp2 [Compatibility Mode]
5/300
Application
processApplication Program Interface (API) Application Program Interface (API)
Communication Software & HardwareCommunication Software & Hardware
Application Process(Client Side)
Application Process(Server Side)
Client/Server ApplicationsClient/Server Applications
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--55June 23, 2010
CommunicationCommunicationNetworkNetwork
Server Agents Examples: Internet Information
Sever + http, Appachi +http
SQL query engines + http
Communication SoftwareExamples: TCP, UDP; IP
8/9/2019 Cn Chp2 [Compatibility Mode]
6/300
applicationtransportnetwork
data linkphysical
modem
modem
Application: communicating,distributed processes e.g., e-mail, Web, P2P file
sharing, instant messaging
running in end systems(hosts)
Applications and ApplicationApplications and Application--Layer ProtocolsLayer Protocols
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--66June 23, 2010
applicationtransportnetworkdata linkphysical
applicationtransportnetworkdata linkphysical
implement applicationApplication-layer protocols
one piece of an app
define messages
exchanged by apps andactions taken
use communicationservices provided by lowerlayer protocols (TCP, UDP)
8/9/2019 Cn Chp2 [Compatibility Mode]
7/300
Types of messagesexchanged: request &
response messages Syntax of messagetypes: what fields inmessages & how fields
Public-domain protocols:
defined in RFCs
allows forinteroperability
eg, HTTP, SMTP
ApplicationApplication--Layer ProtocolsLayer Protocols
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--77June 23, 2010
re e ineate Semantics of the
fields: meaning ofinformation in fields
Rules for when andhow processes send &respond to messages
Proprietary protocols:
eg, Napster, KaZaA,
8/9/2019 Cn Chp2 [Compatibility Mode]
8/300
modem
modem
Typical network app has twopieces: clientand server
Client: initiates contact with server
(speaks first)
typically requests service from
applicationtransportnetwork
data linkphysical
ClientClient--Server ParadigmServer Paradigm
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--88June 23, 2010
,
Web: client implemented inbrowser; e-mail: in mail reader
replyServer: provides requested service to client e.g., Web server sends requested Web
page, mail server delivers e-mail
applicationtransportnetworkdata linkphysical
request
8/9/2019 Cn Chp2 [Compatibility Mode]
9/300
Pure P2P architecturePure P2P architecture
no always on server
arbitrary end systems directly communicate peers are intermittently
modem
modem
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--99June 23, 2010
connecte an c ange addresses example: Gnutella
Highly scalable But difficult to manage
8/9/2019 Cn Chp2 [Compatibility Mode]
10/300
Hybrid of clientHybrid of client--server and P2Pserver and P2P
Napster File transfer P2P File search centralized:
Peers register content at central server Peers query same central server to locate content
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1010June 23, 2010
Instant messaging Chatting between two users is P2P Presence detection/location centralized:
User registers its IP address with central server when itcomes online User contacts central server to find IP addresses of
buddies
8/9/2019 Cn Chp2 [Compatibility Mode]
11/300
process sends/receivesmessages to/from itssocket
socket analogous to door sending process pushes
message out door
process
socket
host or
server
process
socket
host or
server
controlled by
app developer
Processes Communicating Across NetworkProcesses Communicating Across Network
Sockets: doors between process and host
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1111June 23, 2010
sending process assumestransport infrastructureon other side of door whichbrings message to socket
at receiving process
TCP withbuffers,
variables
TCP withbuffers,
variablesInternet
controlled
by OS
API: (1) choice of transport protocol; (2) ability to fixa few parameters (lots more on this later)
8/9/2019 Cn Chp2 [Compatibility Mode]
12/300
For a process toreceive messages, itmust have an identifier
Every host has a unique32-bit IP address
Q: does the IP address
Identifier includesboth the IP addressand port numbers
associated with theprocess on the host. Example port numbers:
HTTP ser er: 80
Process IdentifierProcess Identifier
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1212June 23, 2010
the process runssuffice for identifyingthe process?
Answer: No, manyprocesses can berunning on same host
Mail server: 25 Example IP address:
113.45.12.201
Example Identifier: (80; 113.45.12.201)
8/9/2019 Cn Chp2 [Compatibility Mode]
13/300
Data loss some apps (e.g., audio) can
tolerate some loss
other apps (e.g., filetransfer, telnet) require100% reliable data
Bandwidth
some apps (e.g.,multimedia) requireminimum amount ofbandwidth to beeffective
What transport service does an app need?What transport service does an app need?
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1313June 23, 2010
Timing some apps (e.g.,
Internet telephony,
interactive games)require low delay to beeffective
other apps (elasticapps) make use ofwhatever bandwidththey get
8/9/2019 Cn Chp2 [Compatibility Mode]
14/300
Application Data loss Bandwidth TimeSensitive
file transfer no loss elastic no
e-mail no loss elastic no
web documents no loss elastic (few kbps) no
real-time loss- audio: few kbps-1Mbps yes, 100s of
Requirements of Selected Network ApplicationsRequirements of Selected Network Applications
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1414June 23, 2010
audio/video to erantvideo:10kbps-5Mbps
msec
storedaudio/video
loss-tolerant
same as above yes, few sec
interactivegames
loss-tolerant
few kbps-10kbps yes, 100s ofmsec
instantmessaging
no loss elastic yes and no
8/9/2019 Cn Chp2 [Compatibility Mode]
15/300
TCP service: connection-oriented:setup
required between client and
server processes reliable transportbetween
sending and receiving process
low control:sender wont
UDP service: unreliable data transfer
between sending and
receiving process does not provide:
connection setup,reliability, flow control,
Internet Transport Protocols ServicesInternet Transport Protocols Services
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1515June 23, 2010
overwhelm receiver congestion control:throttle
sender when networkoverloaded
no guarantee on:timing,minimum bandwidth
congestion control, timing,or bandwidth guarantee
Q: Why is there a UDP?
8/9/2019 Cn Chp2 [Compatibility Mode]
16/300
Internet apps: application, transport protocolsInternet apps: application, transport protocols
applications application-layerprotocol
underlying transportprotocol
e-mail SMTP [RFC 2821] TCP
remote terminal access Telnet [RFC 854] TCP
web HTTP [RFC 2616] TCP
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1616June 23, 2010
remote file server NFS [McKusik] UDP or TCP
streaming multimedia proprietary
(e.g., Dialpad)
UDP or TCP
internet telephony proprietary(e.g., Dialpad) Typically UDP
8/9/2019 Cn Chp2 [Compatibility Mode]
17/300
2.1 Principles of app
layer protocols clients and servers
app requirements
2.6 Socket programming
with TCP 2.7 Socket programming
with UDP
Chapter 2 OutlineChapter 2 Outline
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1717June 23, 2010
. 2.3 FTP
2.4 Electronic Mail SMTP, POP3, IMAP
2.5 DNS
.server
2.9 Content distribution Network Web caching
Content distributionnetworks
P2P file sharing
8/9/2019 Cn Chp2 [Compatibility Mode]
18/300
Web page consists of objects
Object can be HTML file, JPEG image, Javaapplet, audio file,
Web page consists of base HTML-file whichincludes several referenced objects
Each object is addressable by a URL
Web and HTTPWeb and HTTP
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1818June 23, 2010
Example URL:
www.iust.ac.ir/computer/home.html
host name path name
8/9/2019 Cn Chp2 [Compatibility Mode]
19/300
HTTP: hypertexttransfer protocol
Webs app layer protocol
client/server model client:browser that
requests, receives,
PC runningExplorer
Serverrunning
Apache Web
server
HTTP OverviewHTTP Overview
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--1919June 23, 2010
server:Web serversends objects inresponse to requests
HTTP 1.0: RFC 1945
HTTP 1.1: RFC 2068Mac runningNavigator
Storage
contents:
base files,
objects
8/9/2019 Cn Chp2 [Compatibility Mode]
20/300
Uses TCP: client initiates TCP
connection (creates socket)
to server, port 80 server accepts TCP
connection from client
HTTP is stateless server maintains no
information about
past client requests
Protocols that maintainstate are com lex!
aside
HTTP Overview (cont.)HTTP Overview (cont.)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2020June 23, 2010
messages app ca on-layer protocol messages)exchanged between browser(HTTP client) and Webserver (HTTP server)
TCP connection closed
past history (state) mustbe maintained
if server/client crashes,their views of state may
be inconsistent, must bereconciled
8/9/2019 Cn Chp2 [Compatibility Mode]
21/300
Nonpersistent HTTP
At most one object issent over a TCPconnection.
Persistent HTTP
Multiple objects canbe sent over singleTCP connection
HTTP ConnectionsHTTP Connections
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2121June 23, 2010
.nonpersistent HTTP
server. HTTP/1.1 uses
persistent connections
in default mode
8/9/2019 Cn Chp2 [Compatibility Mode]
22/300
Suppose user enters URLwww.iust.ac.ir/computer/home.html
1. HTTP client initiates TCPconnection to HTTP server(process) at www.iust.ac.iron port 80
2. HTTP server at hostwww.iust.ac.ir waiting forTCP connection at port 80.
(contains text,references to 10
jpeg images)
NonNon--persistent HTTPpersistent HTTP
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2222June 23, 2010
3. HTTP client sends HTTPrequest message(containingURL) into TCP connection
socket. Message indicatesthat client wants objectComputer//home.html
accepts connection, notifyingclient
4. HTTP server receives request
message, forms responsemessagecontaining requestedobject, and sends messageinto its socket
time
8/9/2019 Cn Chp2 [Compatibility Mode]
23/300
5. HTTP client receives responsemessage containing html file,displays html. Parsing html
file, finds 10 referenced jpegobjects
6. HTTP server closesTCP connection.
4.
NonNon--persistent HTTP (cont.)persistent HTTP (cont.)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2323June 23, 2010
7. Steps 1-6 repeated for eachof 10 jpeg objects
time
8/9/2019 Cn Chp2 [Compatibility Mode]
24/300
Definition of RRT: time tosend a small packet totravel from client toserver and back.
Response time: one RTT to initiate TCP
connection
initiate TCP
connection
RTT
Response Time ModelingResponse Time Modeling
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2424June 23, 2010
one RTT for HTTPrequest and first fewbytes of HTTP responseto return
file transmission timetotal = 2RTT+transmit time
time to
transmit
file
request
file
RTT
file
received
time time
8/9/2019 Cn Chp2 [Compatibility Mode]
25/300
Nonpersistent HTTP issues: requires 2 RTTs per object
OS must work and allocatehost resources for each TCPconnection
but browsers often open
Persistent without pipelining:
client issues new request
only when previousresponse has been received
one RTT for eachreferenced object
Persistent HTTPPersistent HTTP
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2525June 23, 2010
fetch referenced objectsPersistent HTTP server leaves connection
open after sending response
subsequent HTTP messagesbetween same client/serverare sent over connection
Persistent with pipelining: default in HTTP/1.1
client sends requests assoon as it encounters a
referenced object as little as one RTT for all
the referenced objects
8/9/2019 Cn Chp2 [Compatibility Mode]
26/300
method SP URL SP version CR LF
header field name : value CR LF
--- - --- --- ---
request line
header lines
HTTPHTTP RequestRequestMessage: General FormatMessage: General Format
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2626June 23, 2010
CR LF
Entity Body
8/9/2019 Cn Chp2 [Compatibility Mode]
27/300
version SP status code SP phrase CR LF
header field name : value CR LF
--- - --- --- ---
status line
header lines
HTTPHTTP ResponseResponseMessage: General FormatMessage: General Format
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2727June 23, 2010
CR LF
Entity Body
8/9/2019 Cn Chp2 [Compatibility Mode]
28/300
HTTP request message: ASCII (human-readable format)
GET /somedir/page.html HTTP/1.1
request line(GET, POST,
HEAD commands)
HTTPHTTP RequestRequest MessageMessage
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2828June 23, 2010
. .
User-agent: Mozilla/4.0Connection: close
Accept-language:fr
If-modified-since:Sat, 2 Nov 2002 13:45:12
(carriage return, line feed)
headerlines
Carriage return,line feedindicates end
of message
8/9/2019 Cn Chp2 [Compatibility Mode]
29/300
HTTP/1.1 200 OK
Connection: close
Date: Thu, 06 Aug 1998 12:00:15 GMT
Server: Apache/1.3.0 (Unix)
-
status line(protocol
status codestatus phrase)
header
HTTPHTTP ResponseResponse MessageMessage
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--2929June 23, 2010
, ...
Content-Length: 6821Content-Type: text/html
data data data data data ...
ines
data, e.g.,requestedHTML file
MIME lines
8/9/2019 Cn Chp2 [Compatibility Mode]
30/300
GETGETThe GET method means retrieve whatever information (in the formof an entity) is identified by the Request-URI.
The semantics of the GET method changes to a "conditional GET" ifthe request message includes an If-Modified-Since header field.
GET and HEAD CommandsGET and HEAD Commands
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3030June 23, 2010
The HEAD method is identical to GET except that the server mustnot return any Entity-Body in the response.
There is no"conditional HEAD"request analogous to the conditional
GET.
8/9/2019 Cn Chp2 [Compatibility Mode]
31/300
Goal: dont send object ifclient has up-to-date
cached version
client: specify date ofcached copy in HTTPrequest
client server
HTTP request msgIf-modified-since:
HTTP responseHTTP/1.0
objectnot
modified
Conditional GET: ClientConditional GET: Client--Side CachingSide Caching
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3131June 23, 2010
-mo e -s nce:
server: response containsno object if cached copyis up-to-date:
HTTP/1.0 304 NotModified
HTTP request msgIf-modified-since:
HTTP responseHTTP/1.0 200 OK
object
modified
POST C dPOST C d
8/9/2019 Cn Chp2 [Compatibility Mode]
32/300
POSTPOST
The POST method is used to request that the destination serveraccept the entity enclosed in the request as a new subordinate of
the resource identified by the Request-URL in the Request-Line.POST is designed to allow a uniform method to cover the followingfunctions:
Annotation of existin resources;
POST CommandPOST Command
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3232June 23, 2010
Posting a message to a bulletin board, newsgroup, mailinglist,or similar group of articles;
Providing a block of data, such as the result of submitting aform, to a data-handling process;
Extending a database through an append operation.
U l di F I tU l di F I t
8/9/2019 Cn Chp2 [Compatibility Mode]
33/300
Get method: Web page often
includes form input
Input is uploaded toserver in URL field ofrequest line:www.somesite.com/cgi.bin/form.cgi
URL encoding
A-Z A-Z
a-z a-z
0-9 0-9
*-_ *-_
Space +
Others %HEX
Uploading Form InputUploading Form Input
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3333June 23, 2010
Post method: Web page often
includes form input Input is uploaded to
server in entity body
URL Encoded data
M th d TM th d T
8/9/2019 Cn Chp2 [Compatibility Mode]
34/300
HTTP/1.0
GET
POST HEAD
asks server to leave
HTTP/1.1
GET, POST, HEAD
PUT uploads file in entity
body to path specifiedin URL field
Method TypesMethod Types
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3434June 23, 2010
response
DELETE deletes file specified in
the URL field
Other MethodsOPTIONS, PATCH, COPY, MOVE, DELETE, LINK, UNLINK, TRACE,WRAPPED, extension method.
H d Fi ldH d Fi ld
8/9/2019 Cn Chp2 [Compatibility Mode]
35/300
1. General Header Fields
2. Request Header Fields
3. Res onse Header Fields
Header FieldsHeader Fields
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3535June 23, 2010
4. Entity Body Hearer Fields
H d Fi ldH d Fi ld
8/9/2019 Cn Chp2 [Compatibility Mode]
36/300
1. General Header Fields
Keep-Alive
Upgrade
Connection
MIME-Version
Data Pragma Type Subtypes
Multipurpose Internet Mail Extensions(rfcs822obs, 2045, 2046, 2077)
Header FieldsHeader Fields
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3636June 23, 2010
orwar e
Cache-Control TextImage
Audio
Multipart
Video
, ,
Msexel,/ Html, plain(ASCII),
/ Jpeg, gif, ief,
/
Basic, x-pn-realaudio,/ mixed
/ mpeg,quicktime
Header FieldsHeader Fields
8/9/2019 Cn Chp2 [Compatibility Mode]
37/300
2. Request Header Fields
Accept:
Accept-Language:
Authorization:
Range:
Refer:
Unless:
Header FieldsHeader Fields
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3737June 23, 2010
rom:
Host:
If-Modified-Since:
Proxy-Authorization:
ser- gen :
Accept-Encoding:
Cookie:
Header FieldsHeader Fields
8/9/2019 Cn Chp2 [Compatibility Mode]
38/300
3. Response Header Fields
Location:
Proxy-Authentication:
Public:
Header FieldsHeader Fields
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3838June 23, 2010
Retry-After:
Server:
WWW-Authenticate: Set-Cookie:
Header Fields (cont )Header Fields (cont )
8/9/2019 Cn Chp2 [Compatibility Mode]
39/300
4. Entity Body Header Fields
Allow
Content-Encoding
Content-Language
Derived-From
Expires
Last-Modified
Header Fields (cont.)Header Fields (cont.)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--3939June 23, 2010
on en - eng
Content-Range
Content-Type
Content-Version
Content-MD5
n
Title
Transfer-Encoding
URL-Header
extension-header
HTTP Response Status CodesHTTP Response Status Codes
8/9/2019 Cn Chp2 [Compatibility Mode]
40/300
200 OK request succeeded, requested object later in this message
301 Moved Permanently
In first line in server -> client response message.
A few sample codes:
HTTP Response Status CodesHTTP Response Status Codes
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4040June 23, 2010
requeste o ject move , new ocat on spec e ater n
this message (Location:)
400 Bad Request
request message not understood by server
404 Not Found requested document not found on this server
Status Codes CategoriesStatus Codes Categories
8/9/2019 Cn Chp2 [Compatibility Mode]
41/300
Status Codes CategoriesStatus Codes Categories
Response Categories Informational :100
Successful :200
Redirection :300
Client Error :400 e . 404 Not found
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4141June 23, 2010
Server Error :500
Status CodesStatus Codes
8/9/2019 Cn Chp2 [Compatibility Mode]
42/300
Status-Codes "201" ; Created "202" ; Accepted "204" ; No Content "301" ; Moved Permanently "200" ; OK "302" ; Moved Temporarily "304" ; Not Modified
Status CodesStatus Codes
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4242June 23, 2010
; a eques "401" ; Unauthorized "403" ; Forbidden "404" ; Not Found "500" ; Internal Server Error
"501" ; Not Implemented "502" ; Bad Gateway "503" ; Service Unavailable 505 ; HTTP Version Not Supported
8/9/2019 Cn Chp2 [Compatibility Mode]
43/300
UserUser--Server Interaction: AuthorizationServer Interaction: Authorization
8/9/2019 Cn Chp2 [Compatibility Mode]
44/300
Authorization : control access toserver content
authorization credentials:typically name, password
stateless: client must presentauthorization in eachrequest authorization: header line in
client server
usual http request msg
401: authorization req.WWW authenticate:
usual htt re uest ms
UserUser Server Interaction: AuthorizationServer Interaction: Authorization
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4444June 23, 2010
if no authorization: header,server refuses access,sendsWWW authenticate:
header line in response
+ Authorization:
usual http response msg
usual http request msg
+ Authorization:
usual http response msgtime
Cookies: Keeping StateCookies: Keeping State--RFC2109RFC2109
8/9/2019 Cn Chp2 [Compatibility Mode]
45/300
Cookies: Keeping StateCookies: Keeping State RFC2109RFC2109
Some Web sites store information in a small text file onyour computer. This file is called a cookie.
There are several types of cookies,
ou can choose whether to allow some none or all of
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4545June 23, 2010
them to be saved on your computer.
If you do not allow cookies at all, you may not be able to
view some Web sites or
take advantage of customization features (such as localnews and weather, or stock quotes).
How cookies are usedHow cookies are used
8/9/2019 Cn Chp2 [Compatibility Mode]
46/300
How cookies are usedHow cookies are used
Created by an Internet site to store information on yourcomputer. Example, you visit a Web site, it saves a record of the pages
you looked at, to help the site customize the view for you the
next time you visit.
Cookies can also store personally identifiable information,that can be used to identif or contact ou, such as
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4646June 23, 2010
your name, e-mail address, or telephone number. A Web site only has access to the information you provide.
Once a cookie is saved on your computer, only the Web sitethat created the cookie can read it.
Persistent/Temporary CookiesPersistent/Temporary Cookies
8/9/2019 Cn Chp2 [Compatibility Mode]
47/300
Persistent/Temporary CookiesPersistent/Temporary Cookies
A persistent cookie is one stored as a file on yourcomputer, and it remains there when you closeInternet browser.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4747June 23, 2010
your current browsing session, and is deleted fromyour computer when you close Internet browser.
FirstFirst--Party vs. ThirdParty vs. Third--Party cookiesParty cookies
8/9/2019 Cn Chp2 [Compatibility Mode]
48/300
FirstFirst Party vs. ThirdParty vs. Third Party cookiesParty cookies
A first-party cookie either originates on or is sent to theWeb site you are currently viewing.
A third-party cookie either originates on or is sent to a Website different from the one you are currently viewing.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4848June 23, 2010
-
Web site you are viewing. For example, many sites useadvertising from third-party Web sites and those third-party Web sites may use cookies.
A common use for this type of cookie is to track your Web
page use for advertising or other marketing purposes.
Third-party cookies can either be persistent or temporary.
Unsatisfactory CookiesUnsatisfactory Cookies
8/9/2019 Cn Chp2 [Compatibility Mode]
49/300
yy
Unsatisfactory cookies are cookies that might
allow access to personally identifiable information that
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--4949June 23, 2010
cou e use or a secon ary purpose w ou
your consent.
Cookies and PrivacyCookies and Privacy
8/9/2019 Cn Chp2 [Compatibility Mode]
50/300
What cookies can bring:
authorization
shopping carts
recommendations
user session state
Cookies and privacy:
cookies permit sites tolearn a lot about you
you may supply nameand e-mail to sites
search en ines use
aside
yy
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5050June 23, 2010
redirection & cookiesto learn yet more
advertising companiesobtain info acrosssites
HTTP and CookiesHTTP and Cookies
8/9/2019 Cn Chp2 [Compatibility Mode]
51/300
There are four components:
1) cookie header line in theHTTP response message
2) cookie header line in HTTP
Example: Ali access Internet
always from same PC
He visits a specific e-
Many major Web sites use cookies
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5151June 23, 2010
reques message
3) cookie file kept on usershost and managed by usersbrowser
4) back-end database at Web
site
commerce s e or rs
time When initial HTTP
requests arrives at site,site creates a unique ID
and creates an entry inbackend database forID
ExampleExample
8/9/2019 Cn Chp2 [Compatibility Mode]
52/300
client serverusual http request msg
usual http response +
Set-cookie: 1678
usual http request msg cookie-
servercreates ID
1678 for user
Cookie file
amazon: 1678
Cookie file
ebay: 8734
pp
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5252June 23, 2010
usual http response msg
usual http request msgcookie: 1678
usual http response msg
specificaction
cookie-
specificaction
ebay: 8734
Cookie file
amazon: 1678ebay: 8734
one week later:
Cookie File Samples
HTTP over TCPHTTP over TCP
8/9/2019 Cn Chp2 [Compatibility Mode]
53/300
HTTPFiles
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5353June 23, 2010
TCP
IP
Routers packetspacketspacketspacketspacketspacketsRouters
Chapter 2 OutlineChapter 2 Outline
8/9/2019 Cn Chp2 [Compatibility Mode]
54/300
2.1 Principles of applayer protocols clients and servers
app requirements 2.2 Web and HTTP
2.6 Socket programmingwith TCP
2.7 Socket programming
with UDP 2.8 Building a Web
server
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5454June 23, 2010
2.4 Electronic Mail
SMTP, POP3, IMAP
2.5 DNS
2.9 Content distribution Network Web caching
Content distributionnetworks
P2P file sharing
FTP: the File Transfer ProtocolFTP: the File Transfer Protocol
8/9/2019 Cn Chp2 [Compatibility Mode]
55/300
file transferFTP
server
FTPuser
interface
FTPclient
local filesystem
remote filesystem
userat host
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5555June 23, 2010
transfer file to/from remote host
client/server model
client:side that initiates transfer (either to/fromremote)
server:remote host ftp: RFC 959
ftp server: port 21
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs1
8/9/2019 Cn Chp2 [Compatibility Mode]
56/300
(FTP, TFTP, SFTP, NFS) RFCs1
2640 Internationalization of the File Transfer
Protocol
2624 NFS Version 4 Design Considerations 2623 NFS Version 2 and Version 3 Security
Issues and the NFS Protocols Use of
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5656June 23, 2010
RPCSEC_GSS and Kerberos V5 2577 FTP Security Considerations
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs1
8/9/2019 Cn Chp2 [Compatibility Mode]
57/300
(FTP, TFTP, SFTP, NFS) RFCs1
2428 FTP Extensions for IPv6 and NATs
2389 Feature negotiation mechanism for the File
Transfer Protocol 2349, 1784 - TFTP Timeout Interval and Transfer
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5757June 23, 2010
2348, 1783 - TFTP Blocksize Option
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs2
8/9/2019 Cn Chp2 [Compatibility Mode]
58/300
( , , , )
2347, 1782 - TFTP Option Extension
2228 FTP Security Extensions
2224 NFS URL Scheme 2204 ODETTE File Transfer Protocol
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5858June 23, 2010
2090 TFTP Mu ticast Option
2055 WebNFS Server Specification
2054 WebNFS Client Specification
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs3
8/9/2019 Cn Chp2 [Compatibility Mode]
59/300
( , , , )
1986 Experiments with a Simple File Transfer
Protocol for Radio Links using
Enhanced Trivial File Transfer Protocol (ETFTP)
1813 NFS Version 3 Protocol Specification
1785 TFTP Option Negotiation Analysis
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--5959June 23, 2010
1639, 1545 - FTP Operation Over Big AddressRecords (FOOBAR)
1635 How to Use Anonymous FTP
1579 Firewall-Friendly FTP
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs4
8/9/2019 Cn Chp2 [Compatibility Mode]
60/300
( , , , )
1440 SIFT/UFT: Sender-Initiated/UnsolicitedFile Transfer
1415 FTP-FTAM Gateway Specification
1350, 783 - The TFTP Protocol (Revision 2) 1282, 1258 - BSD Rlogin
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6060June 23, 2010
1094 NFS: Network File System Protocolspecification
1068 Background File Transfer Program (BFTP)
1037 NFILE - a file access protocol
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs5
8/9/2019 Cn Chp2 [Compatibility Mode]
61/300
( )
959, 765, 542, 354, 265, 172, 114 - File TransferProtocol.
949 FTP unique-named store command.
913 Simple File Transfer Protocol. 906 Bootstrap loading using TFTP.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6161June 23, 2010
.
743 FTP extension: XRSQ/XRCP. 737 FTP extension: XSEN.
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs6
8/9/2019 Cn Chp2 [Compatibility Mode]
62/300
697 CWD command of FTP 691 One more try on the FTP
686 Leaving well enough alone
683 FTPSRV - Tenex extension for paged files 662 Performance improvement in ARPANET file
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6262June 23, 2010
640 Revised FTP reply codes 630 FTP error code usage for more reliable mail
service
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs7
8/9/2019 Cn Chp2 [Compatibility Mode]
63/300
624 Comments on the File Transfer Protocol
614 Response to RFC 607: "Comments on the FileTransfer Protocol"
607 Comments on the File Transfer Protocol 571 Tenex FTP problem
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6363June 23, 2010
532 UCSD-CC Server-FTP facility 520 Memo to FTP group: Proposal for File Access
Protocol
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs8
8/9/2019 Cn Chp2 [Compatibility Mode]
64/300
506 FTP command naming problem
505 Two solutions to a file transfer accessproblem
501 Un-muddling "free file transfer" 487 Freefile transfer
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6464June 23, 2010
480 Host-dependent FTP parameters 479 Use of FTP by the NIC Journal
478 FTP server-server interaction - II
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs9
8/9/2019 Cn Chp2 [Compatibility Mode]
65/300
468 FTP data compression
463 FTP comments and response to RFC 430
448 Print files in FTP
438 FTP server-server interaction
430 Comments on File Transfer Protocol
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6565June 23, 2010
418 Server file transfer under TSS/360 atNASA Ames
414 File Transfer Protocol (FTP) status andfurther comments
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs10
8/9/2019 Cn Chp2 [Compatibility Mode]
66/300
412 User FTP Documentation 385 Comments on the File Transfer Protocol
310 Another Look at Data and File Transfer
Protocols 294 The Use of "Set Data Type" Transaction in
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6666June 23, 2010
281 Suggested addition to File Transfer Protocol 269 Some Experience with File Transfer
264, 171 - The Data Transfer Protocol
File Transfer and Access Protocols
(FTP, TFTP, SFTP, NFS) RFCs11
8/9/2019 Cn Chp2 [Compatibility Mode]
67/300
250 Some thoughts on file transfer
242 Data Descriptive Language for Shared Data
238 Comments on DTP and FTP proposals
163 Data transfer protocols
141 Comments on RFC 114: A File Transfer
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6767June 23, 2010
ro oco
133 File Transfer and Recovery
FTP: Separate Control, Data Connections1FTP: Separate Control, Data Connections1
8/9/2019 Cn Chp2 [Compatibility Mode]
68/300
FTP client FTP server
TCP control connectionport 21 (persistent)
TCP data connectionport 20(nonpersistent)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6868June 23, 2010
c en con ac erver a por , pec y ng
TCP as transport protocol. Client obtains authorization over control connection.
Client browses remote directoryremote directory by sending
commands over control connection. When server receives a command for a file transfer,
server opens a TCP data conn. to client at port 20.
FTP MODEL1FTP MODEL1
8/9/2019 Cn Chp2 [Compatibility Mode]
69/300
USERUSERUSERINTERFACE
USERPI
SERVERPI FTP REPLIESFTP REPLIES
FTP COMMANDSFTP COMMANDS
PI: Protocol InterpreterDTP: Data Transfer Process
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--6969June 23, 2010
FILESYSTEM
USERDTP
SERVERDTP
FILESYSTEM
DATACONNECTION
Control Connection InitiationControl Connection Initiation
8/9/2019 Cn Chp2 [Compatibility Mode]
70/300
In the model, the user-protocol interpreter (PI)initiates the control connection.
The control connection follows the Telnet
protocol.
FTP commands are enerated b the user-PI and
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7070June 23, 2010
transmitted to the server process via the controlconnection.
Standard replies are sent from the server-PI to
the user-PI over the control connection inresponse to the commands.
Data Connection InitiationData Connection Initiation
8/9/2019 Cn Chp2 [Compatibility Mode]
71/300
The FTP commands specify the parameters forthe data connection (data port, transfer mode, representation type, and
structure) and
the nature of file system operation (store, retrieve,append, delete, etc.).
- " "
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7171June 23, 2010
port, and the server initiate the data connectionand data transfer in accordance with the specifiedparameters.
Note that the data connection may be used for
simultaneous sending and receiving.
Relationship between FTP and TelnetRelationship between FTP and Telnet
8/9/2019 Cn Chp2 [Compatibility Mode]
72/300
The FTP uses the Telnet protocol on thecontrol connection.
This can be achieved in two ways: First, the user-PI or the server-PI may
implement the rules of the Telnet Protocol
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7272June 23, 2010
rec y n e r own proce ures; or,
Second, the user-PI or the server-PI may makeuse of the existing Telnet module in thesystem.
FTP: Separate Control, Data ConnectionsFTP: Separate Control, Data Connections
8/9/2019 Cn Chp2 [Compatibility Mode]
73/300
After transferring a file, server closes port20.
Server opens a second TCP data connection to
transfer the next file. Control connection: out of band
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7373June 23, 2010
.
stateless, in-band and a push/pull protocol.FTP is also a push/pull one)
FTP server maintains state: currentdirectory, earlier authentication
FTP Commands, ResponsesFTP Commands, Responses
8/9/2019 Cn Chp2 [Compatibility Mode]
74/300
Sample commands: sent as ASCII text over
control channel(4 uppercase ASCII
characters) USERusername
PASS password
Sample return codes status code and phrase (as
in HTTP) 331 Username OK,
password required
125 data connection
already open;
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7474June 23, 2010
LIST re urn s o e n
current directory RETR filename retrieves
(gets) file
STOR filename stores
(puts) file onto remotehost
transfer starting
425 Cant open dataconnection
452 Error writing
file
ftp://ftpserver.iust.ac.ir/dir1/filename.extension
Chapter 2 OutlineChapter 2 Outline
8/9/2019 Cn Chp2 [Compatibility Mode]
75/300
2.1 Principles of applayer protocols clients and servers
app requirements 2.2 Web and HTTP
2.3 FTP
2.6 Socket programmingwith TCP
2.7 Socket programming
with UDP 2.8 Building a Web
server
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7575June 23, 2010
2.4 Electronic Mail SMTP, POP3, IMAP,
HTTP
2.5 DNS
2.9 Content distribution Network Web caching
Content distributionnetworks
P2P file sharing
outgoing
Electronic MailElectronic Mail
8/9/2019 Cn Chp2 [Compatibility Mode]
76/300
Three major components: user agents mail servers simple mail transfer
protocol: SMTPUser Agent
:
user mailbox
g g
message queue
mailserver
user
agent
server
useragent
P
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7676June 23, 2010
mail reader
composing, editing, readingmail messages
e.g., Eudora, Outlook, elm,Netscape Messenger
outgoing, incoming messagesstored on server
agent
useragent
mailserver
useragent
useragent
SMT
Electronic Mail: Mail ServersElectronic Mail: Mail Servers
8/9/2019 Cn Chp2 [Compatibility Mode]
77/300
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
mailserver
useragent
usera ent
mailserver
useragent
TP
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7777June 23, 2010
messages
client: sending mailserver (sending agent)
server: receiving mailserver (receiving agent)
useragent
mailserver
user
agentuseragent
S
Electronic Mail: SMTP [RFC 2821]Electronic Mail: SMTP [RFC 2821]
8/9/2019 Cn Chp2 [Compatibility Mode]
78/300
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
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7878June 23, 2010
closure
command/response interaction commands: ASCII text
response: status code and phrase
messages must be in 7-bit ASCII
1) User1 (sender) uses UA to 4) SMTP client sends User1s
Scenario: User1 sends message to User2Scenario: User1 sends message to User2
8/9/2019 Cn Chp2 [Compatibility Mode]
79/300
) User (sender) uses UA tocompose message [email protected] .
2) User1s UA sends messageto his mail server; message
placed in message queue.3) Client side of SMTP opens
TCP connection with
)message over the TCPconnection.
5) User2s mail server placesthe message in User2s
mailbox.6) User2 invokes his/her user
agent to read message.
U
A:UserAgent
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--7979June 23, 2010
User2s mail server.
useragent
server
mailserver user
agent
1
23 4 5
6User1
User2
webmail.iust.ac.ir
yahoo.com
Try SMTP Interaction for Yourself:Try SMTP Interaction for Yourself:
8/9/2019 Cn Chp2 [Compatibility Mode]
80/300
telnet servername 25
see 220 reply from server
enter HELO, MAIL FROM, RCPT TO, DATA, QUITcommands above lets you send email without using
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8080June 23, 2010
ema c en rea er
SMTP: Final WordsSMTP: Final Words
8/9/2019 Cn Chp2 [Compatibility Mode]
81/300
SMTP uses persistentconnections.
SMTP requiresmessage (header &
-
Comparison with HTTP:
HTTP: pull
SMTP: push
both have ASCII
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8181June 23, 2010
ASCII SMTP server usesCRLF.CRLF todetermine end of
message
comman response
interaction, status codes. HTTP: each object
encapsulated in its ownresponse message.
SMTP: multiple objectssent in multipart message.
Mail Message FormatMail Message Format
8/9/2019 Cn Chp2 [Compatibility Mode]
82/300
SMTP: protocol forexchanging email msgs
RFC 822: standard for textmessage format:
header lines, e.g.,
headerblank
line
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8282June 23, 2010
o:
From: Subject:
differentfrom SMTPcommands!
body the message, ASCII
characters only
bodybody
..
SMTP Message Transfer Between Mail ServersSMTP Message Transfer Between Mail Servers
sms = sending mail server
8/9/2019 Cn Chp2 [Compatibility Mode]
83/300
sms rms: TCP connection establishment on port 25
sms rms: SMTP handshake (HELO, MAIL, FROM, RCPT TO, DATA,commands, and 220, 250, 354, 221 status codes)
sms header
g
rms = receiving mail server
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8383June 23, 2010
Massage
body.
sms QUIT
rms 221 yahoo.com closing connection
ExampleExample
8/9/2019 Cn Chp2 [Compatibility Mode]
84/300
mailserver
mailserver user
agent13 4 6
User1
User2webmail.iust.ac.ir
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8484June 23, 2010
yahoo.com
sms: TCP connection request on port 25
Example: SMTP InteractionExample: SMTP Interaction
8/9/2019 Cn Chp2 [Compatibility Mode]
85/300
rms: 220 yahoo.com accepts connectionsms: HELO webmail.iust.ac.ir is readyrms: 250 Hello webmail.iust.ac.irsms: MAIL FROM:
rms: 250 [email protected]... Sender oksms: RCPT TO: rms: 250 user2@ ahoo.com ... Reci ient ok
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8585June 23, 2010
Massage
from
user1user1 to
user2user2
sms: DATA
rms: 354 Enter mail, end with "." on a line by itselfsms: From: [email protected]: To: [email protected].
sms: .rms: 250 Message accepted for deliverysms: QUITrms: 221 yahoo.com closing connection
Message Format: Multimedia ExtensionsMessage Format: Multimedia Extensions
8/9/2019 Cn Chp2 [Compatibility Mode]
86/300
MIME: multimedia mail extension, RFC 2045, 2056 additional lines in message header declare MIME content
type
From: [email protected]
To: [email protected]: Picture of iust
-
MIME version
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8686June 23, 2010
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data .....
.........................
......base64 encoded data
.
to encode data
multimedia datatype, subtype,
parameter declaration
encoded data
MIMEMIME (RFCs(RFCs20452045,, 20462046,, 20772077))TypesTypesContentContent--Type: type/subtype; parametersType: type/subtype; parameters
8/9/2019 Cn Chp2 [Compatibility Mode]
87/300
Text example subtypes:plain,
html
Image example subtypes: jpeg,
Video example subtypes:mpeg,
quicktime
Application
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8787June 23, 2010
Audio example subtypes:basic
(8-bit mu-law encoded),32kadpcm(32 kbpscoding)
processed by readerbefore viewable
example subtypes:msword, octet-stream
From: [email protected]
T 2@ h
Multipart TypeMultipart Type
8/9/2019 Cn Chp2 [Compatibility Mode]
88/300
To: [email protected]: photo of iust.
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary=StartOfNextPart
--StartOfNextPart
Dear User1, Hear is a photo of iust in 1383 winter.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8888June 23, 2010
-- ar ex ar
Content-Transfer-Encoding: base64
Content-Type: image/jpeg
base64 encoded data .....
.........................
......base64 encoded data
--StartOfNextPart
Do you like to receive more pictures?
.
SMTP SMTP
Mail Access ProtocolsMail Access Protocols
8/9/2019 Cn Chp2 [Compatibility Mode]
89/300
useragent
senders mailserver
useragent
SMTP SMTP accessprotocol
receivers mailserver
Sender Receiver
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--8989June 23, 2010
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 messages on server
HTTP: Hotmail , Yahoo! Mail, IUST, etc.
POP3POP3--Post Office ProtocolPost Office Protocol -- Version 3Version 3
8/9/2019 Cn Chp2 [Compatibility Mode]
90/300
RFC 1939 / Std 53
To retrieve emails from server (POP3 server) Server port number: 110
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9090June 23, 2010
Three states Authorization State Transaction State
Update State
8/9/2019 Cn Chp2 [Compatibility Mode]
91/300
S: +OK POP3 server ready
C: user USER1
POP3 ProtocolPOP3 Protocol
8/9/2019 Cn Chp2 [Compatibility Mode]
92/300
authorization phase client commands:
user: declare usernamepass: password
server responses +OK
C: listS: 1 498
S: 2 912
C: user USER1S: +OK
C: pass zxcdvf
S: +OK user successfully logged on
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9292June 23, 2010
-ERR
transaction phase, client: list: list message numbers retr: retrieve message by
number dele: delete quit
.
C: retr 1
S: S: .
C: dele 1
C: retr 2
S:
S: .C: dele 2
C: quit
S: +OK POP3 server signing off
More about POP3 IMAP
POP3 (more) and IMAPPOP3 (more) and IMAP
8/9/2019 Cn Chp2 [Compatibility Mode]
93/300
More about POP3 Previous example uses
download and delete mode. Download brings the mail
into client computer. Delete removes the mail
from the mail server. User1cannot re-read e-mail if
IMAP Keep all messages in
one place: the server
Allows user toorganize messages infolders
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9393June 23, 2010
computer.
Download-and-keep: leavesthe message on the mailserver.
POP3 is stateless acrosssessions.
IMAP keeps user stateacross sessions: names of folders and
mappings between
message IDs and foldername
2 1 Principles of app 2 6 Socket programming
Chapter 2 OutlineChapter 2 Outline
8/9/2019 Cn Chp2 [Compatibility Mode]
94/300
2.1 Principles of applayer protocols clients and servers
app requirements 2.2 Web and HTTP
2.6 Socket programmingwith TCP
2.7 Socket programming
with UDP 2.8 Building a Web
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9494June 23, 2010
.
2.4 Electronic Mail SMTP, POP3, IMAP,
HTTP
2.5 DNS
2.9 Content distribution Network Web caching
Content distributionnetworks
P2P file sharing
DNS RFCs1DNS RFCs1
2673 Binary Labels in the Domain Name System
8/9/2019 Cn Chp2 [Compatibility Mode]
95/300
2673 Binary Labels in the Domain Name System. 2672 Non-Terminal DNS Name Redirection.
2671 Extension Mechanisms for DNS (EDNS0).
2606 Reserved Top Level DNS Names.
2541 DNS Securit O erational Considerations.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9595June 23, 2010
2540 Detached Domain Name System (DNS)Information.
2539 Storage of Diffie-Hellman Keys in the
Domain Name System (DNS).
DNS RFCs2DNS RFCs2
2535 Domain Name System Security Extensions
8/9/2019 Cn Chp2 [Compatibility Mode]
96/300
2535 Domain Name System Security Extensions. 2517 Building Directories from DNS: Experiences from
WWWSeeker.
2352, 2240 - A Convention For Using Legal Names as Domain
Names.
2317 Classless IN-ADDR.ARPA delegation.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9696June 23, 2010
2308 Negative Caching of DNS Queries (DNS. NCACHE)
2230 Key Exchange Delegation Record for the DNS. 2219 Use of DNS Aliases for Network Services.
2182 Selection and Operation of Secondary DNS Servers.
DNS RFCs3DNS RFCs3
2181 Clarifications to the DNS Specification
8/9/2019 Cn Chp2 [Compatibility Mode]
97/300
2181 Clarifications to the DNS Specification. 2137 Secure Domain Name System Dynamic Update.
2136 Dynamic Updates in the Domain Name System (DNS
UPDATE).
2065 Domain Name System Security Extensions.
2052 A DNS RR for specifying the location of services
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9797June 23, 2010
(DNS SRV).
2010 Operational Criteria for Root Name Servers.
1996 A Mechanism for Prompt Notification of Zone
Changes (DNS NOTIFY).
1995 Incremental Zone Transfer in DNS.
DNS RFCs4DNS RFCs4
1982 Serial Number Arithmetic
8/9/2019 Cn Chp2 [Compatibility Mode]
98/300
1982 Serial Number Arithmetic.
1912, 1537 - Common DNS Operational andConfiguration Errors.
1876 A Means for Expressing LocationInformation in the Domain Name System.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9898June 23, 2010
uppor or oa a anc ng.
1713 Tools for DNS debugging. 1712 DNS Encoding of Geographical Location.
1706, 1637, 1348 - DNS NSAP Resource Records.
1591 Domain Name System Structure andDelegation.
DNS RFCs5DNS RFCs5
1536 Common DNS Implementation Errors andS d Fi
8/9/2019 Cn Chp2 [Compatibility Mode]
99/300
1536 Common DNS Implementation Errors andSuggested Fixes. 1535 A Security Problem and Proposed Correction
With Widely Deployed DNS Software 1480, 1386 - The US Domain. 1464 Using the Domain Name System To Store
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--9999June 23, 2010
r rary r ng r u e .
1394 Relationship of Telex Answerback Codes toInternet Domains. 1183 New DNS RR Definitions. 1101 DNS encoding of network names and other
types. 1035 Domain names - implementation and
specification.
DNS RFCs6DNS RFCs6
8/9/2019 Cn Chp2 [Compatibility Mode]
100/300
1034 Domain names - concepts and facilities
1033 Domain administrators operations guide
1032 Domain administrators guide 1031 MILNET name domain transition
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--100100June 23, 2010
973 Domain system changes and observations
953, 811 - Hostname Server 921, 897 - Domain name system implementation
schedule - revised
920 Domain requirements
DNS RFCs7DNS RFCs7
883 Domain names: Implementation specification
8/9/2019 Cn Chp2 [Compatibility Mode]
101/300
883 Domain names Implementation specification 882 Domain names: Concepts and facilities
881 Domain names plan and schedule
830 Distributed system for Internet nameservice
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--101101June 23, 2010
applications
799 Internet name domains
756 NIC name server - a datagram-basedinformation utility
752 Universal host table
People: many identifiers: Domain Name System:
DNS: Domain Name SystemDNS: Domain Name SystemRFC1034RFC1034
8/9/2019 Cn Chp2 [Compatibility Mode]
102/300
People many dent f ers SSN, name, passport #
Internet hosts, routers:
IP address (32 bit) -used for addressingdatagrams
Doma n Name System distributed database
implemented in hierarchy ofmany name servers
application-layer protocolhost, routers, name servers to
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--102102June 23, 2010
name, e.g.,
www.iust.ac.ir - used byhumans
Q: map between IPaddresses and name ?
(address/name translation)
note: core Internetfunction, implemented asapplication-layer protocol
complexity at networks
edge
Why DNSWhy DNS
Although DNS is most commonly associated withth I t t i t t k l DNS
8/9/2019 Cn Chp2 [Compatibility Mode]
103/300
g ythe Internet, private networks also use DNSbecause of the following benefits:
Convenience: User-friendly names are easier for peopleto remember than numerical IP addresses.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--103103June 23, 2010
Consistency: IP a resses may c ange, ut t e server
names can remain constant. Simplicity: Users need to learn only one naming
convention to find resources on either the Internet or onan intranet.
DNS: Domain Name SystemDNS: Domain Name System
The Domain Name System is a distributed
8/9/2019 Cn Chp2 [Compatibility Mode]
104/300
ydatabase system that can serve as the foundationfor name resolution in a TCP/IP network.
DNS is used by most internetworking software,
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--104104June 23, 2010
programs, to locate servers and to resolve, or map,a user-friendly name of a computer to its IPaddress.
DNS ComponentsDNS Components
To understand how DNS maps names to IPaddresses you will need to understand the
8/9/2019 Cn Chp2 [Compatibility Mode]
105/300
paddresses, you will need to understand thefollowing five components:
1. Domain Name Space Name Structure,
2. Zone
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--105105June 23, 2010
Zone data base file,
3. Name Server (DNS Server) DNS Root Servers,
4. DNS Resolver,
5. Protocol Forward Lookup Query
Caching.
1. Domain Name Space1. Domain Name Space
The domain name space has a hierarchicalstructure
8/9/2019 Cn Chp2 [Compatibility Mode]
106/300
pstructure. The root domain is at the top, and it is
represented by a period. Below the root domain, the top-level, or 1st-level
domains can be an organizational type, such as com
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--106106June 23, 2010
., , .IRAN.
Second-level domains are registered to individualsor organizations, such as microsoft.com, theMicrosoft Corporation domain.
Second-level domains can have many sub domains.and any domain can have hosts.
1. Domain Name Space1. Domain Name Space
.
Root Domain
8/9/2019 Cn Chp2 [Compatibility Mode]
107/300
Top Level or First Level Domain
org. edu. com. ir.
Second Level Domain (Registered to Individuals or Organizations)ac.ir.
me,orF
QDN
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--107107June 23, 2010
iust.ac.ir.
ce.iust.ac.ir.
Any domain can have hosts.
A host is a specific computer within a domain.
Iran University of Science & Technology s Domain: iust.ac.ir.
host
subdomain 2nd-leveldomain
top-leveldomain
webmail . iust . ac . ir .
root
fully
qualifieddom
ainn
1. Domain Name Space: Name Structure1. Domain Name Space: Name Structure
d
Max: 63 Characters Root
8/9/2019 Cn Chp2 [Compatibility Mode]
108/300
Host name . . Subdomain-name . 2nd-level name. 1st-level-name .
Max: 255 Characters
ICANN: Internet Corporation For Assigned Names
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--108108June 23, 2010
.
Levelm-name authority appoints levelm-1-names.
Example: ir. is controlled by ) ( iust.ir. is appointed by ) ( and controlled by Iran
University of science and Technology.
Names are ValuableNames are Valuable
8/9/2019 Cn Chp2 [Compatibility Mode]
109/300
new
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--109109June 23, 2010
1. Domain Name Space: Top Levels1. Domain Name Space: Top Levels
com: commercial edu: educational institute
ir: Iran nl: Netherlands
8/9/2019 Cn Chp2 [Compatibility Mode]
110/300
u ucat ona nst tut ac: Academic, research institute int: international organization gov: US federal goverment org: US armed forces
nl: Netherlands
jp: Japan
uk: England
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--110110June 23, 2010
net: network providers
biz: business name: peoples name pro: professions
tv: TV stations and networks
For the most upFor the most up--toto--datedate
information about new top levelinformation about new top leveldomains, consult:domains, consult:http://www.icann.org/tldshttp://www.icann.org/tlds
For administrative purposes,domains can be organized
2. Zones2. Zonesir.
Name
NameServer
Zone Database File
8/9/2019 Cn Chp2 [Compatibility Mode]
111/300
domains can be organized
into zones.
As you can see in this example,
a zone is a discrete and
contiguous area of the
ac.ir.NameServer
Name
ZoneDatabase File
ZoneDatabase File
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--111111June 23, 2010
oma n name space.
One reason to divide a name space into zones is todelegate authority for different portions of it.
One very large domain could be difficult to administer.
The name-to-IP address data for computers located in a
zone, is stored in a zone database file on a DNS nameserver.
A zone database storing resource records (RR) of the zonefor which a server is authoritative.
2. Zone Database File2. Zone Database File
8/9/2019 Cn Chp2 [Compatibility Mode]
112/300
Type=A name is hostname
Type=CNAME name is alias name for some
RR format: (Name, TTL, Class, Type, Value)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--112112June 23, 2010
Type=NS name is domain (e.g. iust.ac.ir) value is IP address of authoritative
name server for this domain
value is IP address
canonical (the real) name
www.ibm.com is reallyservereast.backup2.ibm.com
value is canonical name
Type=MX value is name of mail-server
associated with name
2. Zone Database File: Type Description2. Zone Database File: Type Description
Example ResourceRecord FormatDescriptionTypeNumber
1D N 10 1 1 1N k dd1
8/9/2019 Cn Chp2 [Compatibility Mode]
113/300
www 1D IN A 10.1.1.1Network addressA1
@ 1D IN NS na.av.comAuthoritative nameserver
NS2
Mail destination; now replaced by MXMD3
Mail forwarder; now replaced by MXMF4
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--113113June 23, 2010
anon ca a as name
Start of zone authoritySOA6Mailbox domain nameMB7
Mailbox memberMG8
Mail rename domainMR9
Null resource recordNULL10Well-Known serviceWKS11
RR format: (Name, TTL, Class, Type, Value)
2. Zone Database File: Type Description2. Zone Database File: Type Description
Example Record FormatDescriptionTypeNumberPointer to a domain namePTR12
8/9/2019 Cn Chp2 [Compatibility Mode]
114/300
www 1D IN HINFO SolarisHost informationHINFO13
Mailbox informationMINFO14
Mail exchangeMX15
System 1 IN TXT This is a
Text stringsTXT16
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--114114June 23, 2010
new sys em
Responsible personRP17
AFS-type servicesAFSDB18
X.25 addressX.2519
ISDN addressISDN20
Route throughRT21
RR format: (Name, TTL, Class, Type, Value)
8/9/2019 Cn Chp2 [Compatibility Mode]
115/300
A DNS server is aWhy not centralize DNS? single point of failure
3. DNS Name Servers3. DNS Name Servers
8/9/2019 Cn Chp2 [Compatibility Mode]
116/300
A DNS server is acomputer that runs aDNS server program,such as BerkeleyInternet NAME Domain
single point of failure traffic volume
distant centralizeddatabase
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--116116June 23, 2010
.
DNS Servers containDNS database files. They resolve name
resolution queries issued
by DNS clients.
doesnt scale!
no server has all name-to-IP address mappings.
does scale!
Distributed, Hierarchical DatabaseDistributed, Hierarchical Database
Root DNS Servers
8/9/2019 Cn Chp2 [Compatibility Mode]
117/300
org DNS Servers edu DNS Servers com DNS Servers ir DNS Servers
ac.ir DNS
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--117117June 23, 2010
Servers
iust.ac.ir
DNS Servers
3. DNS Name Servers3. DNS Name Servers
One name server holds the
primary zone database file
ir.NameServer
NameServer
Primary ZoneDatabase File
8/9/2019 Cn Chp2 [Compatibility Mode]
118/300
primary zone database file
for a zone.
That name server is said to"have authority" for making
chan es to the zone file.
ac.ir.Secondary ZoneDatabase File
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--118118June 23, 2010
A copy of the zone file may
be stored on other servers to balance network load. These copies are referred to as secondary zone database
files.
The secondary zone database files are updated regularly
from the primary zone database file by a process called zonetransfer.
Zone Owners ResponsibilitiesZone Owners Responsibilities
Authoritatively maintain the zones data
8/9/2019 Cn Chp2 [Compatibility Mode]
119/300
Authoritatively maintain the zone s data.
Arrange for replicated name servers for the zone
Typically, zone data is maintained in a primary file andloaded into a primary server
Re licated servers use TCP-based zone trans ers
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--119119June 23, 2010
specified in DNS protocol to refresh their data.
Therefore, either servers can answer name resolutionqueries for that zone.
A name server authoritative for a zone does nothave to be in that zone.
A name server can handle any number of zones,which dont have to be contiguous.
contacted by local name server that can not resolve name root name server:
Either, contacts authoritative name server gets mapping
3. DNS Root Name Servers3. DNS Root Name Servers
8/9/2019 Cn Chp2 [Compatibility Mode]
120/300
(i)(i) NORDUnet Stockholm, Sweden
(k)(k) RIPE London, UK
(a)(a) NSI Herndon, VA(c)(c) PSInet Herndon, VA
(d)(d) U Maryland College Park, MD
g pp g returns mapping to local name server
Or, introduces authoritative name server to local name server.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--120120June 23, 2010
(b)(b) USC-ISI Marina del Rey, CA(l)(l) ICANN Marina del Rey, CA
(e)(e) NASA Mt View, CA(f)(f) Internet Software C. Palo Alto, CA
(m)(m) WIDE Tokyo, Japan
gg enna,(h)(h) ARL Aberdeen, MD
(j)(j) NSI (TBD) Herndon, VA
13 root name serversworldwide
13 Root Name Servers13 Root Name Servers
F gets 270,000,000+ hits per day.
8/9/2019 Cn Chp2 [Compatibility Mode]
121/300
p y Other root servers are comparable.
Top Level Domain servers answer 5,000,000,000 per day.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--121121June 23, 2010
3. DNS Root Name Servers3. DNS Root Name Servers
Root ServersServer Operator Locations IP Addr HomeASN
8/9/2019 Cn Chp2 [Compatibility Mode]
122/300
A VeriSign Global RegistryServices Dulles VA 198.41.0.4 19836
B
Information Sciences
InstituteMarina Del Rey CA
IPv4: 192.228.79.201IPv6:2001:478:65::53
tba
C Cogent Communications Herndon VA; Los Angeles;New York City; Chicago 192.33.4.12 2149
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--122122June 23, 2010
n vers y o ary an o ege ar . . .
E NASA Ames Research Center Mountain View CA 192.203.230.10 297
F Internet Systems Consortium,Inc.
Ottawa; Palo Alto; San Jose CA;New York City; San Francisco;Madrid; Hong Kong; Los Angeles;Rome; Auckland; Sao Paulo;Beijing; Seoul; Moscow; Taipei;Dubai; Paris; Singapore; Brisbane;Toronto; Monterrey; Lisbon;Johannesburg;Tel Aviv;Jakarta;
Munich;
IPv4: 192.5.5.241IPv6:2001:500::1035
3557
G U.S. DOD NetworkInformation Center Vienna VA 192.112.36.4 568
3. DNS Root Name Servers3. DNS Root Name Servers
Root ServersServer Operator Locations IP Addr
HomeASN
8/9/2019 Cn Chp2 [Compatibility Mode]
123/300
H U.S. Army Research Lab Aberdeen MD IPv4: 128.63.2.53IPv6:2001:500:1::803f:235 13
I Autonomica/NORDUnet
Stockholm; Helsinki; Milan;London; Geneva; Amsterdam;Oslo; Bangkok; Hong Kong;Brussels; Frankfurt;Bucharest; Ankara;Chicago; Washington DC;Tok o Kuala Lum ur
192.36.148.17 29216
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--123123June 23, 2010
J VeriSign Global RegistryServices
Dulles VA (2 locations); MountainView CA;Seattle WA; Amsterdam;Atlanta GA; Los Angeles CA;Miami; Stockholm; London;Tokyo; Seoul; Singapore;Sterling VA (2 locations,standby)
192.58.128.30 26415
KReseaux IP Europeens -
Network CoordinationCentre
London (UK); Amsterdam (NL);Frankfurt (DE); Athens (GR);Doha (QA); Milan (IT)
IPv4: 193.0.14.129IPv6: 2001:7fd::1
25152
LInternet Corporation for
Assigned Names andNumbers
Los Angeles 198.32.64.12 20144
M WIDE Project Tokyo; Seoul (KR); Paris (FR) 202.12.27.33IPv6: 2001:dc3::35 7500
8/9/2019 Cn Chp2 [Compatibility Mode]
124/300
4. Resolver4. Resolver
A DNS resolver is a service that uses the DNS
8/9/2019 Cn Chp2 [Compatibility Mode]
125/300
protocol to query for information from DNS
servers.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--125125June 23, 2010
DNS client service.
DNS service uses UDP in transport layer.
Root name server: t k
root name server
23
6
7
5. DNS Protocol: Forward Lookup Query5. DNS Protocol: Forward Lookup Query
a:answer
r:referral
q:query
qa
8/9/2019 Cn Chp2 [Compatibility Mode]
126/300
may not knowauthoritative name
server may know
3
7q:query q
q a
a
a
a
q
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--126126June 23, 2010
server:who to
contact to findauthoritative nameserver
requesting host
www.icann.org
oca name serverdns.iust.ac.ir
1 4 5
authoritative name serverdns.icann.org
n erme a e name server(Top level) dns.org
8
recursive query: puts burden of name
root name server
2iterated query
5. DNS Protocol: Forward Lookup Query5. DNS Protocol: Forward Lookup Query
a:answerr:referral q
8/9/2019 Cn Chp2 [Compatibility Mode]
127/300
puts burden of nameresolution on
contacted nameserver
hea load
23
4
7
q yq:query
qa
r
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--127127June 23, 2010
iterated query: contacted serverreplies with name ofserver to contact
I dont know thisname, but ask thisserver
requesting host
www.icann.org
local name server
dns.iust.ac.ir
15 6
authoritative name server
dns.icann.org
intermediate name server(Top Level) dns.org
8
5. DNS Protocol: Forward Lookup Query5. DNS Protocol: Forward Lookup Query
root name server
2 iterated query
a:answer
r:referral
q:query
q
8/9/2019 Cn Chp2 [Compatibility Mode]
128/300
3
4
5
intermediate name server
7
q:query
a
rq
qr
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--128128June 23, 2010
requesting host
www.icann.org
local name serverdns.iust.ac.ir
1 6
authoritative name serverdns.icann.org
op eve dns.org
8
5. DNS Protocol: Forward Lookup Query5. DNS Protocol: Forward Lookup Query
.
RootName ServerAuthorized nameserver for org. zone
IP Address of www.icann.org is
142.12.01.23
8/9/2019 Cn Chp2 [Compatibility Mode]
129/300
org. edu. com. ir.
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--129129June 23, 2010
The query contains the FQDN of the requested computer. A forward lookup query is a request
to map a name to an IP address.
ac.ir.
iust.ac.ir.LocalName Server
Client
www.icann.org.
Forward Lookup Query:
What is IP Address of www.icann.org
DNS Resolver and Local DNS ServerDNS Resolver and Local DNS Server
Root server
3
8/9/2019 Cn Chp2 [Compatibility Mode]
130/300
Application DNS cache
4
Top-level
5
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--130130June 23, 2010
DNS resolver
Local DNS
server
1 10
2
DNS response 9
domain server6
Second-level
domain server
7
8
Caching based on a time-to-live (TTL) assigned by the DNS serverresponsible for the host name to reduce latency in DNS translation.
5. DNS Protocol: Caching and Updating Records5. DNS Protocol: Caching and Updating Records
8/9/2019 Cn Chp2 [Compatibility Mode]
131/300
once (any) name server learns mapping, it cachesmapping
cache entries timeout (disappear) after some time Top Level Domain servers typically cached in local name
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--131131June 23, 2010
erver . u roo name erver no o en v e .
update/notify mechanisms under design by IETF
RFC 2136
http://www.ietf.org/html.charters/dnsind-charter.html
DNS protocol : queryand replymessages, both with samemessage format
5. DNS Protocol Messages5. DNS Protocol Messages
identification flags
8/9/2019 Cn Chp2 [Compatibility Mode]
132/300
msg header identification: 16 bit #for uer , re l to uer
g
number of questions number of answer RRs
number of authority RRs number of additional RRs
questions
12byte
s
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--132132June 23, 2010
uses same #
flags: query or reply
recursion desired
recursion available
reply is authoritative
var a e num er o ques ons
answers
(variable number of resource records)
authority
(variable number of resource records)
additional information
(variable number of resource records)
identification flags
number of questions number of answer RRsName, Type fields
5. DNS Protocol Messages5. DNS Protocol Messages
12byt
8/9/2019 Cn Chp2 [Compatibility Mode]
133/300
number of authority RRs number of additional RRs
questions(variable number of questions)
, ypfor a query
RRs in responseto uer
tes
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--133133June 23, 2010
(variable number of resource records)
authority(variable number of resource records)
additional information
(variable number of resource records)
records forauthoritative servers
additional helpfulinfo that may be used
Inserting records into DNSInserting records into DNS
Example: just created startup Network Utopia
Register name networkuptopia com at a registrar
8/9/2019 Cn Chp2 [Compatibility Mode]
134/300
Register name networkuptopia.com at a registrar
(e.g., Network Solutions) Need to provide registrar with names and IP addresses of your
authoritative name server (primary and secondary)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--134134June 23, 2010
eg s rar nser s wo s n o e com server:
(networkutopia.com, dns1.networkutopia.com, NS)
(dns1.networkutopia.com, 212.212.212.1, A)
Put in authoritative server Type A record forwww.networkuptopia.com and Type MX record fornetworkutopia.com
How do people get the IP address of your Web site?
Example: Set Debug CommandExample: Set Debug Command
> set debug
> www.goole.comServer: jupitr.iust.ac.irAddress: 194.225.228.4-------------------------------
Got answer:
AUTHORITY RECORDS:
-> 1.google.comnameserver = b.1.google.comttl = 37098
8/9/2019 Cn Chp2 [Compatibility Mode]
135/300
Got answer:HEADER:
opcode = QUERY, id = 11, rcode =NOERROR
header flags: response, want recursion,recursion avail.questions = 1, answers = 4, authorityrecords = 6, additional = 0
ttl = 37098 -> 1.google.com
nameserver = c.1.google.com
ttl = 37098 -> 1.google.com
nameserver = d.1.google.comttl = 37098
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--135135June 23, 2010
QUESTIONS:www.google.com, type = A, class = IN
ANSEWRS:
-> www.google.comcannonical name = www.1.google.comttl = 900
-> www.1.google.cominternet address = 66.102.9.147ttl = 176
-> www.1.google.com
internet address = 66.102.9.99ttl = 176 -> www.1.google.com
internet address = 66.102.9.104ttl = 176
-> .goog e.comnameserver = e.1.google.comttl = 37098
-> 1.google.comnameserver = g.1.google.comttl = 37098
-> 1.google.comnameserver = a.1.google.comttl = 37098
--------------------Non-authoritative answer:
Name: www.1.google.comAddresses: 66.102.9.147, 66.102.9.99, 66.102.9.104Aliases: www.google.com
8/9/2019 Cn Chp2 [Compatibility Mode]
136/300
Using Ports to Identify ServicesUsing Ports to Identify Services
Web server(port 80)
Client hostServer host 128.2.194.242Service request for
128.2.194.242:80(i th W b s )
8/9/2019 Cn Chp2 [Compatibility Mode]
137/300
(port 80)
Echo server(port 7)
(i.e., the Web server)OSClient
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--137137June 23, 2010
Web server(port 80)
Echo server(port 7)
Service request for128.2.194.242:7
(i.e., the echo server)OS
Client
Client host
Network ApplicationNetwork Application--CommunicationCommunication
Network Applications communicates through a network. API is a programming means, either a library or part ofOS.
API provides the communication functionality for the
8/9/2019 Cn Chp2 [Compatibility Mode]
138/300
API provides the communication functionality for theNetwork Applications (Processes).
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--138138June 23, 2010
Application Program Interface (API)
Communication Software & HardwarePlatform (OS + Hardware)
pp ca on o ware(Network Application)
OSOS
API comes as a library
API TechnologiesAPI Technologies--SocketsSockets
Sockets (earliest technology) Low level functions for the communication
S k t
8/9/2019 Cn Chp2 [Compatibility Mode]
139/300
Socket,
ServerSocket, ConnectionSocket,
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--139139June 23, 2010
,
DatagramSocket,
Send, Read,
Write,
Close, Accept
8/9/2019 Cn Chp2 [Compatibility Mode]
140/300
API TechnologiesAPI Technologies--ComponentsComponents
Components: Components Look and act likebj t
8/9/2019 Cn Chp2 [Compatibility Mode]
141/300
objects, CORBA (common object request Broker
Architecture)
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--141141June 23, 2010
COM,
COM+ , DCOM (Distributed Component Object Model)
k P
Goal:Goal: learn how to build client/server application thatlearn how to build client/server application thatcommunicate using socketscommunicate using sockets
Socket ProgrammingSocket Programming
8/9/2019 Cn Chp2 [Compatibility Mode]
142/300
Socket API introduced in BSD4.1UNIX, 1981 ex licitl created used
Socket a host-local, application-
created, OS-controlled
jamali@ iust.ac.irjamali@ iust.ac.ir Application Layer Application Layer 22--142142June 23, 2010
released by apps
client/server paradigm two types of transport
service via socket API: unreliable datagram reliable, byte stream-
oriented
n er ace
a door into which
application process can both send and
receive
messages to/from another
application process
8/9/2019 Cn Chp2 [Compatibility Mode]
143/300
Client must contact server server process must first
be runningh d
When contacted by client,server TCP creates newsocket for server process to
Socket ProgrammingSocket Programming with TCPwith TCP
8/9/2019 Cn Chp2 [Compatibility Mode]
144/300
server must have created
socket (door) thatwelcomes clients contact
communicate with client
allows server to talk withmultiple clients
jamali@ iust.ac.irjamali@ iust.ac.ir App