Understanding Application Layer Networking
Understanding Application Layer Networking
Application Layer
Client-Server Model
• UDP
DHCP – 67 & 68
POP – 110
• TCP connection
• data and control over the same connection.
• Network Virtual Terminal
• negotiated options
McGraw-Hill TELNET 15
©The McGraw-Hill Companies, Inc., 2001
telnet hostname port
> telnet [Link] 7
Trying [Link]...
Connected to [Link]
([Link]).
Escape character is '^]'.
Hi mehmet
Hi mehmet
stop it
stop it
^]
telnet> quit
Connection closed.
McGraw-Hill TELNET 16
©The McGraw-Hill Companies, Inc., 2001
The Domain Name System
17
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
A primary server loads all information
from the disk file; the secondary server
loads all information from the primary
server.
18
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS In The Internet
Generic Domain
Country Domain
Inverse Domain
19
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS in the Internet
20
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Generic domains
21
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Generic domain labels
Label Description
22
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Table 25.2 New generic domain labels
Label Description
23
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Country domains
24
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Inverse domain
25
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Hostnames
26
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
The Domain Name System
27
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Hierarchy
rpi albany
28
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Host name structure
• Each host name is made up of a sequence of
labels separated by periods.
– Each label can be up to 63 characters
– The total name can be at most 255 characters.
• Examples:
– [Link]
– [Link]
– [Link]
29
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Domain Name
30
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Top level domains
• edu, gov, com, net, org, mil, …
• Countries each have a top level domain (2
letter domain name).
• New top level domains include:
.aero .biz .coop .info .name .pro
31
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Organization
• Distributed Database
– The organization that owns a domain name is
responsible for running a DNS server that can
provide the mapping between hostnames within
the domain to IP addresses.
– So - some machine run by RPI is responsible
for everything within the [Link] domain.
32
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Distributed Database
• There is one primary server for a domain,
and typically a number of secondary servers
containing replicated databases.
[Link] DNS server
[Link] [Link]
[Link]
[Link]
DB
DNS DB DNS
DNSDBDB
Authoritative Replicas
33
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Clients
• A DNS client is called a resolver.
domain [Link]
[Link]
[Link]
35
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
nslookup
36
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Servers
37
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Server - Server Communication
• If a server is asked to provide the mapping
for a host outside it’s domain (and the
mapping is not in the server cache):
– The server finds a nameserver for the target
domain.
– The server asks the nameserver to provide the
host name to IP translation.
• To find the right nameserver, use DNS!
38
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Data
39
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
The Root DNS Server
rpi albany
40
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Server Operation
41
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Message Format
HEADER
HEADER
QUERIES
QUERIES
Response
Response RESOURCE
RESOURCE RECORDS
RECORDS
Response
Response AUTHORITY
AUTHORITY RECORDS
RECORDS
Response
Response ADDITIONAL
ADDITIONAL INFORMATION
INFORMATION
42
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Message Header
• query identifier
16 bit fields
• flags
• # of questions
}
• # of RRs
• # of authority RRs Response
• # of additional RRs
43
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Message Flags
44
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Recursion
45
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Question Format
46
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Response Resource Record
• Domain Name
• Response type
• Class (IP)
• Time to live (in seconds)
• Length of resource data
• Resource data
47
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Resource Records
• Each name server maintains a collection of resource records
(Name, Value, Type, Class, TTL)
– Each record is a translation based on type
– Name/Value: not necessarily host names to IP addresses
• Type (some examples)
– A: Name = full domain name, Value = IP address
– NS: Value gives domain name for host running name server that
knows how to resolve names within specified domain.
– CNAME: Value gives canonical name for particle host; used to
define aliases.
– MX: Value gives domain name for host running mail server that
accepts messages for specified domain.
• Class: allow other entities (other than NIC) to define types
– IN is what is used by the Internet
• TTL: how long the resource record is valid
48
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
DNS Resource Record
The resource record will be in this format
Domain_name time_to_live class type value
Domain_name - it tells the domain name
time_to_live - the existance of record for 1day/hr/min
Class – it is generally IN(internet information)
Type – it denotes a Host/name server/mail server etc..
Value – it can be a number/domain name/Ascii string
Eg:
[Link] 86400 IN NS [Link]
[Link] 86400 IN MX [Link]
50
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Name to Address Conversion
51
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
FTP - File Transfer Protocol
TFTP – Trivial FTP
User Server
Protocol Control Protocol
Interpreter Connection Interpreter
User Server
Protocol Control Protocol
Interpreter Connection Interpreter
Passive open on
Port 5001
User Data Server
Data Transfer Data Transfer
Function Connection Function
McGraw-Hill
Establish Data ©The McGraw-Hill Companies, Inc., 2001
FTP’s 2
Connections – Connection Closing
bye
client
User
Interface
221 Service Closing
QUIT
server
User Server
Protocol Control Protocol
Interpreter Connection Interpreter
Client Server
PORT 192,168,0,173,19,137
SYN
SYN-
AACK
CK
150 Data
ACK Connection will be
NAME LIST
open shortly
FIN
Control connection FIN-ACK
Data Connection ACK
226 Closing Data
ACK
Connection
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
FTP Client Commands (issued by user interface)
Command Description
get filename Retrieve file from server
TCP/IP Protocol 66
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Trivial FTP (TFTP)
• Used only to read and write files
from/to a remote server
– Cannot list directories
• Useful for bootstrapping diskless
systems
– Workstations
– X terminals
• Simple and small:
– 5 message formats
– Runs on UDP
– Designed to fit in ROM
– Uses a “stop and wait” protocol
– NO BUILT IN SECURITY FEATURES (login)
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
FTP vs. TFTP
• FTP provides (minimal) security through
login procedure
• TFTP has NO login procedure
• FTP Provides a reliable service through
its use of TCP
• TFTP must handle its own
retransmissions since it uses UDP
• FTP uses two connections
• TFTP uses one connection (stop and wait)
• FTP provides many commands
• TFTP can only read and write files
McGraw-Hill
Slide from William Boyer ©The McGraw-Hill Companies, Inc., 2001
Hyper Text Transfer Protocol
69
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
HTTP uses the services of
TCP on well-known port 80.
HTTP transaction
URL
McGraw-Hill
73
©The McGraw-Hill Companies, Inc., 2001
Web History
• Before the 1970s-1980s
– Internet used mainly by researchers and academics
– Log in remote machines, transfer files, exchange e-mail
• Late 1980s and early 1990s
– Initial proposal for the Web by Berners-Lee in 1989
– Competing systems for searching/accessing documents
• Gopher, Archie, WAIS (Wide Area Information Servers), …
• All eventually subsumed by the World Wide Web
• Growth of the Web in the 1990s
– 1991: first Web browser and server
– 1993: first version of Mosaic browser
McGraw-Hill
74
©The McGraw-Hill Companies, Inc., 2001
Enablers for Success of the Web
• Internet growth and commercialization
– 1988: ARPANET gradually replaced by the NSFNET
– Early 1990s: NSFNET begins to allow commercial traffic
• Personal computer
– 1980s: Home computers with graphical user interfaces
– 1990s: Power of PCs increases, and cost decreases
• Hypertext
– 1945: Vannevar Bush’s “As We May Think”
– 1960s: Hypertext proposed, and the mouse invented
– 1980s: Proposals for global hypertext publishing systems
McGraw-Hill
75
©The McGraw-Hill Companies, Inc., 2001
Main Components: URL
• Uniform Resource Identifier (URI)
– Denotes a resource independent of its location or value
– A pointer to a “black box” that accepts request methods
• Formatted string
– Protocol for communicating with server (e.g., http)
– Name of the server (e.g., [Link])
– Name of the resource (e.g., [Link])
• Name (URN), Locator (URL), and Identifier (URI)
– URN: globally unique name, like an ISBN # for a book
– URI: identifier representing the contents of the book
– URL: location of the book
McGraw-Hill
76
©The McGraw-Hill Companies, Inc., 2001
Main Components: HTML
• HyperText Markup Language (HTML)
– Representation of hyptertext documents in ASCII format
– Format text, reference images, embed hyperlinks
– Interpreted by Web browsers when rendering a page
• Straight-forward and easy to learn
– Simplest HTML document is a plain text file
• Easy to add formatting, references, bullets, etc.
– Automatically generated by authoring programs
• Tools to aid users in creating HTML files
• Web page
– Base HTML file referenced objects (e.g., images)
– Each object has its own URL
McGraw-Hill
77
©The McGraw-Hill Companies, Inc., 2001
Main Components: HTTP
GET /courses/archive/spring06/cos461/
HTTP/1.1
Host: [Link] Request
User-Agent: Mozilla/4.03
<CRLF>
HTTP/1.1 200 OK
Date: Mon, 6 Feb 2006 13:09:03 GMT
Server: Netscape-Enterprise/3.5.1
Last-Modified: Mon, 6 Feb 2006 11:12:23 GMT
Response
Content-Length: 21
<CRLF>
Site under construction
McGraw-Hill
79
©The McGraw-Hill Companies, Inc., 2001
HTTP: Request-Response Protocol
• Client program • Server program
– Running on end host – Running on end host
– Requests service – Provides service
– E.g., Web browser – E.g., Web server
GET /[Link]
McGraw-Hill
“Site under construction” 80
©The McGraw-Hill Companies, Inc., 2001
HTTP Request Message
• Request message sent by a client
– Request line: method, resource, and protocol version
– Request headers: provide information or modify request
– Body: optional data (e.g., to “POST” data to the server)
request line
(GET, POST, GET /somedir/[Link] HTTP/1.1
HEAD commands) Host: [Link]
headerUser-agent: Mozilla/4.0
Connection: close
lines
Accept-language:fr
Carriage return,
line feed (extra carriage return, line feed)
indicates end
of message
McGraw-Hill
81
©The McGraw-Hill Companies, Inc., 2001
Example: Conditional GET
Request
• Fetch resource only if it has changed at the server
GET /courses/archive/spring06/cos461/ HTTP/1.1
Host: [Link]
User-Agent: Mozilla/4.03
If-Modified-Since: Mon, 6 Feb 2006 11:12:23 GMT
<CRLF>
• Server avoids wasting resources to send again
– Server inspects the “last modified” time of the resource
– … and compares to the “if-modified-since” time
– Returns “304 Not Modified” if resource has not changed
– …. or a “200 OK” with the latest version otherwise
McGraw-Hill
82
©The McGraw-Hill Companies, Inc., 2001
HTTP Response Message
• Response message sent by a server
– Status line: protocol version, status code, status phrase
– Response headers: provide information
– Body: optional data
status line
(protocol
HTTP/1.1 200 OK
status code Connection close
status phrase) Date: Thu, 06 Aug 1998 12:00:15 GMT
header
Server: Apache/1.3.0 (Unix)
lines Last-Modified: Mon, 22 Jun 1998 …...
Content-Length: 6821
Content-Type: text/html
data, e.g.,
requested data data data data data ...
83
HTML file
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Request Methods and Response Codes
• Request methods include
– GET: return current value of resource, run program, …
– HEAD: return the meta-data associated with a resource
– POST: update a resource, provide input to a program, …
• Response code classes
– 1xx: informational (e.g., “100 Continue”)
– 2xx: success (e.g., “200 OK”)
– 3xx: redirection (e.g., “304 Not Modified”)
– 4xx: client error (e.g., “404 Not Found”)
– 5xx: server error (e.g., “503 Service Unavailable”)
• Note similarities to File Transfer Protocol (FTP)
McGraw-Hill
84
©The McGraw-Hill Companies, Inc., 2001
HTTP Resource Meta-Data
• Meta-data
– Information relating to a resource
– … but not part of the resource itself
• Example meta-data
– Size of a resource
– Type of the content
– Last modification time
• Concept borrowed from e-mail protocols
– Multipurpose Internet Mail Extensions (MIME)
– Data format classification (e.g., Content-Type: text/html)
– Enables browsers to automatically launch a viewer
McGraw-Hill
85
©The McGraw-Hill Companies, Inc., 2001
Stateless Protocol
• Stateless protocol
– Each request-response exchange treated independently
– Clients and servers not required to retain state
• Statelessness to improve scalability
– Avoid need for the server to retain info across requests
– Enable the server to handle a higher rate of requests
• However, some applications need state
– To uniquely identify the user or store temporary info
– E.g., personalize a Web page, compute profiles or access statistics by
user, keep a shopping cart, etc.
– Lead to the introduction of “cookies” in the mid 1990s
McGraw-Hill
86
©The McGraw-Hill Companies, Inc., 2001
Cookies
• Cookie
– Small state stored by client on behalf of server
– Included in future requests to the server
Request
Response
Set-Cookie: XYZ
Request
Cookie: XYZ
McGraw-Hill
87
©The McGraw-Hill Companies, Inc., 2001
Cookies Examples
client server en
usual http request da try i
Cookie file
server tab n b
msg as ac
usual http response creates ID e ke
ebay: 8734 + nd
Set-cookie: 1678 for user
Cookie file 1678http request
usual
amazon: 1678 msg cookie- e s s
ebay: 8734 ac c
cookie:
usual 1678
http response
specific
action
ss
one week later: msg
ce
ac
Cookie file usual http request
msg cookie-
amazon: 1678
ebay: 8734 cookie:
usual 1678
http response
spectific
msg action
McGraw-Hill
88
©The McGraw-Hill Companies, Inc., 2001
Web Components
• Clients
– Send requests and receive responses
– Browsers, spiders, and agents
• Servers
– Receive requests and send responses
– Store or generate the responses
• Proxies
– Act as a server for the client, and a client to the server
– Perform extra functions such as anonymization, logging,
transcoding, blocking of access, caching, etc.
McGraw-Hill
89
©The McGraw-Hill Companies, Inc., 2001
Web Browser
• Generating HTTP requests
– User types URL, clicks a hyperlink, or selects bookmark
– User clicks “reload”, or “submit” on a Web page
– Automatic downloading of embedded images
• Layout of response
– Parsing HTML and rendering the Web page
– Invoking helper applications (e.g., Acrobat, PowerPoint)
• Maintaining a cache
– Storing recently-viewed objects
– Checking that cached objects are fresh
McGraw-Hill
90
©The McGraw-Hill Companies, Inc., 2001
Typical Web Transaction
• User clicks on a hyperlink
– [Link]
• Browser learns the IP address of the server
– Invokes gethostbyname([Link])
– And gets a return value of [Link]
• Browser establishes a TCP connection
– Selects an ephemeral port for its end of the connection
– Contacts [Link] on port 80
• Browser sends the HTTP request
– “GET /[Link] HTTP/1.1
Host: [Link]”
McGraw-Hill
91
©The McGraw-Hill Companies, Inc., 2001
Typical Web Transaction (Continued)
McGraw-Hill
92
©The McGraw-Hill Companies, Inc., 2001
Web Server
• Web site vs. Web server
– Web site: collections of Web pages associated with a
particular host name
– Web server: program that satisfies client requests for Web
resources
• Handling a client request
– Accept the TCP connection
– Read and parse the HTTP request message
– Translate the URL to a filename
– Determine whether the request is authorized
– Generate and transmit the response
McGraw-Hill
93
©The McGraw-Hill Companies, Inc., 2001
Web Server: Generating a Response
• Returning a file
– URL corresponds to a file (e.g., /www/[Link])
– … and the server returns the file as the response
– … along with the HTTP response header
• Returning meta-data with no body
– Example: client requests object “if-modified-since”
– Server checks if the object has been modified
– … and simply returns a “HTTP/1.1 304 Not Modified”
• Dynamically-generated responses
– URL corresponds to a program the server needs to run
– Server runs the program and sends the output to client
McGraw-Hill
94
©The McGraw-Hill Companies, Inc., 2001
Hosting: Multiple Sites Per
Machine
• Multiple Web sites on a single machine
– Hosting company runs the Web server on behalf of multiple sites
(e.g., [Link] and [Link])
• Problem: returning the correct content
– [Link]/[Link] vs. [Link]/[Link]
– How to differentiate when both are on same machine?
• Solution #1: multiple servers on the same machine
– Run multiple Web servers on the machine
– Have a separate IP address for each server
• Solution #2: include site name in the HTTP request
– Run a single Web server with a single IP address
– … and include “Host” header (e.g., “Host: [Link]”)
McGraw-Hill
95
©The McGraw-Hill Companies, Inc., 2001
Hosting: Multiple Machines Per
Site
• Replicating a popular Web site
– Running on multiple machines to handle the load
– … and to place content closer to the clients
• Problem: directing client to a particular replica
– To balance load across the server replicas
– To pair clients with nearby servers
• Solution #1: manual selection by clients
– Each replica has its own site name
– A Web page lists the replicas (e.g., by name, location)
– … and asks clients to click on a hyperlink to pick
McGraw-Hill
96
©The McGraw-Hill Companies, Inc., 2001
Hosting: Multiple Machines Per
Site
• Solution #2: single IP address, multiple machines
– Same name and IP address for all of the replicas
– Run multiple machines behind a single IP address
Load Balancer
[Link]
McGraw-Hill
97
©The McGraw-Hill Companies, Inc., 2001
Hosting: Multiple Machines Per Site
• Solution #3: multiple addresses, multiple machines
– Same name but different addresses for all of the replicas
– Configure DNS server to return different addresses
[Link] [Link]
Internet
[Link]
McGraw-Hill
98
©The McGraw-Hill Companies, Inc., 2001
Caching vs. Replication
• Motivations for moving content close to users
– Reduce latency for the user
– Reduce load on the network and the server
– Reduce cost for transferring data on the network
• Caching
– Replicating the content “on demand” after a request
– Storing the response message locally for future use
– May need to verify if the response has changed
– … and some responses are not cacheable
• Replication
– Planned replication of the content in multiple locations
– Updating of resources is handled outside of HTTP
– Can replicate scripts that create dynamic responses
McGraw-Hill
99
©The McGraw-Hill Companies, Inc., 2001
Caching vs. Replication
(Continued)
• Caching initially viewed as very important in HTTP
– Many additions to HTTP to support caching
– … and, in particular, cache validation
• Deployment of caching proxies in the 1990s
– Service providers and enterprises deployed proxies
– … to cache content across a community of users
– Though, sometimes the gains weren’t very dramatic
• Then, content distribution networks emerged
– Companies (like Akamai) that replicate Web sites
– Host all (or part) of a Web site for a content provider
– Place replicas all over the world on many machines
McGraw-Hill
100
©The McGraw-Hill Companies, Inc., 2001
TCP Interaction: Multiple
Transfers
• Most Web pages have multiple objects
– E.g., HTML file and multiple embedded images
• Serializing the transfers is not efficient
– Sending the images one at a time introduces delay
– Cannot start retrieving second images until first arrives
• Parallel connections
– Browser opens multiple TCP connections (e.g., 4)
– … and retrieves a single image on each connection
• Performance trade-offs
– Multiple downloads sharing the same network links
– Unfairness to other traffic traversing the links
McGraw-Hill
101
©The McGraw-Hill Companies, Inc., 2001
TCP Interaction: Short Transfers
• Most HTTP transfers are
short
– Very small request message
(e.g., a few hundred bytes)
initiate TCP
connection
– Small response message RTT
request
(e.g., a few kilobytes) file
time to
• TCP overhead may be big RTT
transmit
file
– Three-way handshake to file
received
establish connection
time
– Four-way handshake to tear time
McGraw-Hill
103
©The McGraw-Hill Companies, Inc., 2001
TCP Interaction: Persistent Connections
• Handle multiple transfers per connection
– Maintain the TCP connection across multiple requests
– Either the client or server can tear down the connection
– Added to HTTP after the Web became very popular
• Performance advantages
– Avoid overhead of connection set-up and tear-down
– Allow TCP to learn a more accurate RTT estimate
– Allow the TCP congestion window to increase
• Further enhancement: pipelining
– Send multiple requests one after the other
– … before receiving the first response
McGraw-Hill
104
©The McGraw-Hill Companies, Inc., 2001
Conclusions
• Key ideas underlying the Web
– Uniform Resource Identifier (URI)
– HyperText Markup Language (HTML)
– HyperText Transfer Protocol (HTTP)
– Browser helper applications based on content type
• Main Web components
– Clients, proxies, and servers
• Dependence on underlying Internet protocols
– DNS and TCP
• Next week: other application-layer protocols
– E-mail, peer-to-peer file sharing, Voice-over-IP
McGraw-Hill
105
©The McGraw-Hill Companies, Inc., 2001
POP3
Server
Primary Primary
Thread Socket (101) Thread
Server Client
Server Client
USER bob
Primary Primary
Thread Socket (101) Thread
Server Client
+OK
Primary Primary
Thread Socket (101) Thread
Server Client
PASS ITSD4304
Primary Primary
Thread Socket (101) Thread
Server Client
+OK
Primary Primary
Thread Socket (101) Thread
Server Client
STAT
Primary Primary
Thread Socket (101) Thread
Server Client
+OK 2 320
Primary Primary
Thread Socket (101) Thread
Server Client
LIST
Primary Primary
Thread Socket (101) Thread
Server Client
Server Client
1 120
Primary Primary
Thread Socket (101) Thread
Server Client
2 200
Primary Primary
Thread Socket (101) Thread
Server Client
.
Primary Primary
Thread Socket (101) Thread
Server Client
RETR 1
Primary Primary
Thread Socket (101) Thread
Server Client
Server Client
Server Client
.
Primary Primary
Thread Socket (101) Thread
Server Client
DELE 1
Primary Primary
Thread Socket (101) Thread
Server Client
Server Client
QUIT
Primary Primary
Thread Socket (101) Thread
Server Client
Primary Primary
Thread Socket (101) Thread
Server Client
Primary Primary
Thread Thread
Server Client
133
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Content
• about imap
• procedure of the imap protocol
• interaction between client and server
• flags message attributes
• different states of an imap session
– state diagram
• commands
• example of an imap session
134
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
About IMAP
• Internet message access protocol
• Stands for accessing electronic mail that are kept on a
server
• access messages from more than one computer
• More than one user
• Imap protocol based on a TCP connection (port 143)
• No functionality to send messages (realized with
SMTP)
135
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Procedure of the imap protocol
136
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Procedure of the imap protocol [2]
• communication procedure:
– Connection initialization
– Welcome of the server
– Interaction between client and server
– Connection closed
137
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Interaction between client and server
138
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Different states of an imap session
139
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
State diagram
Initialization
Connect Reject con.
Logou
Non-Authenticated
t
Close
Logout,
Preauth
Login
Logou
Authenticated
t
Select Close
Logou
Selected
t
140
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Flags message attributes
• List of token associated with the message that is sent
by the server
• A flag can be permanent or session-only
• types:
– System flag:
• flag name that is pre-defined in the imap specification
• All system flags begin with ‘\’
– Keywords:
• A keyword is defined by the server implementation
• Keywords do not begin with ‘\’
141
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Flags Message Attributes [2]
• \Seen (Message has been read)
• \Answered (Message has been answered)
• \Flagged (Message is "flagged" for urgent/special
attention)
• \Deleted (Message is "deleted" for removal by later
EXPUNGE)
• \Draft (Message has not completed composition
(marked as a draft))
• \Recent (Message is "recently" arrived in this mailbox.
This session is the first session to have been notified about
this message)
142
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
commands
• LOGIN username password
• SELECT mailbox-name
• CREATE new-mailbox-name
• DELETE mailbox-name
• RENAME old-name new-name
• AUTHENTICATE
• CLOSE
• SEARCH
• COPY
143
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
imap session
S: * OK IMAP4rev1 Service Ready
C: a001 login TIM timmy
S: a001 OK LOGIN completed
C: a002 select inbox
S: * 18 EXISTS
S: * FLAGS(\Answered\Flagged\Deleted\Seen\Draft)
S: * 2 RECENT
S: * OK [UNSEEN 17] Message 17 is the first unseen
message
S: * OK [UIDVALIDITY 3857529045] UIDs valid
S: a002 OK [READ-WRITE] SELECT completed
C: a003 fetch 12 body[header]
S: * 12 FETCH (BODY[HEADER] {350}
S: Date: Wed, 19 May 2003 02:23:25 -0700 (PDT)
S: From: christiane <christiane@[Link]>
S: Subject: weekend planning
144
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
imap session [2]
S: To: steffen <steffen@[Link]>
S: cc: steffen <steffen@[Link]>
S: Message-Id: <B27397-0100000@[Link]>
S: MIME-Version: 1.0
S: Content-Type: TEXT/PLAIN; CHARSET=US-ASCII
S:
S: )
S: a003 OK FETCH completed
C: a004 store 12 +flags \deleted
S: * 12 FETCH (FLAGS (\Seen \Deleted))
S: a004 OK +FLAGS completed
C: a005 logout
S: * BYE IMAP4rev1 server terminating connection
S: a005 OK LOGOUT completed
145
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
Simple Mail Transfer Protocol
• Introduction
• Message Breakdown
• Sending Messages
• Extensions
• Retrieving mail (Mailbox Protocols)
• Examples
[Link]
route
for <kissel@[Link]>; Tue, 25 Oct 2005 20:27:19 -0400 (EDT)
Date: Tue, 25 Oct 2005 20:27:19 -0400 (EDT)
Keyword Arguments
HELO Sender’s Host Domain
Name
MAIL Email Address of sender
FROM:
RCPT TO: Email of Intended
recipient
DATA Body of the message
McGraw-Hill
QUIT ©The McGraw-Hill Companies, Inc., 2001
How SMTP works (A-PDU’s)
• The Extras
Keyword Arguments
RSET
VRFY Name to be verified
NOOP
TURN
EXPN Mailing list to expand
HELP Command Name
TCP Connection
Establishment
• No authentication mechanisms
• Messages are sent un-encrypted
• Susceptible to misuse (Spamming,
faking sender address)
• Email Basics
• What Makes Up An Email
• How Email Works
• What Are TCP/IP Ports
• The Header
– Who sent the email.
– To whom the mail is sent.
– When the email was sent.
– The email subject.
– The size of the email.
• The Body
– Contains the message.
– May also contain an attachment.
• Attachments
– If not embedded within the body, attachments are
sent along with the email.
Peer Peer
Required Interface Required Interface
Provided Interface
Peer
Required Interface
Filter
McGraw-Hill
Required Interface
Provided Interface
Filter
Required Interface
Provided Interface
Filter
Required Interface
How Email Works
Pipe and Filter Model
Provided Interface
Filter
Required Interface
©The McGraw-Hill Companies, Inc., 2001
How Email Works
Implicit Invocation “Bus” Model
Provided Interface
Bus
Required Interface
Provided Interface
Server
Required Interface
– MIME-Version: 1.1
– Content-Type: type/subtype
– Content-Transfer-Encoding: encoding type
– Content-Id: message id
– Content-Description: textual explanation of non-
textual contents
--MIMEStream=_0+92061_793033260215529_597673089
Content-Type: TEXT/PLAIN; charset="US-ASCII"; format=flowed
/9j/4AAQSkZJRgABAgEASABIAAD/4QNxRXhpZgAATU0AKgAAAAgABwESAAMA
AAABAAEAAAEaAAUAAAABAAAAYgEbAAUAAAABAAAAagEoAAMAAAABAAIAAAEx
…
osv/0I5nPvr7sVdirsVf/9GO5z76+6hxQ1il2Kv/0o5nPvr7eKtYq7FX/9k=
--MIMEStream=_0+92061_793033260215529_597673089--
McGraw-Hill ©The McGraw-Hill Companies, Inc., 2001
MTA MTA
SMTP AUTH Client TCP Connection
Establishment
Server
IMAP:
[Link]
Friends
…. rs
heade
Internet
• Simple
• Allows the user to obtain a list of their Emails
• Users can retrieve their emails
• Users can either delete or keep the email on
their system
• Minimizes server resources
• Important RFCs
– RFC-822 Standard for the format for ARPA Internet test messages
– RFC-2045 MIME Part 1: Format of Internet Message Bodies
– RFC-2046 MIME Part 2: Media Types
– RFC-2047 MIME Part 3: Message Header Extensions
– RFC-2048 MIME Part 4: Registration Procedure
– RFC-2049 MIME Part 5: Conformance Criteria
Man is distinguished, not only by his reason, but by this singular passion from
other animals, which is a lust of the mind, that by a perseverance of delight in the
continued and indefatigable generation of knowledge, exceeds the short
vehemence of any carnal pleasure.
base64 encoded:
TWFuIGlzIGRpc3Rpbmd1aXNoZWQsIG5vdCBvbmx5IGJ5IGhpcyByZWFzb24sIGJ1dCBieSB0
aGlzIHNpbmd1bGFyIHBhc3Npb24gZnJvbSBvdGhlciBhbmltYWxzLCB3aGljaCBpcyBhIGx1
c3Qgb2YgdGhlIG1pbmQsIHRoYXQgYnkgYSBwZXJzZXZlcmFuY2Ugb2YgZGVsaWdodCBpbiB0
aGUgY29udGludWVkIGFuZCBpbmRlZmF0aWdhYmxlIGdlbmVyYXRpb24gb2Yga25vd2xlZGdl
LCBleGNlZWRzIHRoZSBzaG9ydCB2ZWhlbWVuY2Ugb2YgYW55IGNhcm5hbCBwbGVhc3VyZS4=
SNMP agent
SNMP
protocol
messages
SNMP agent
• Interactions in SNMP
Management Station Managed System
Replies
Access
objects
Traps
Traps
Data
SNMP SNMP messages SNMP
UDP UDP
IP IP
IP Network
([Link]
directory (1) mgmt (2) experimental (3) private (4)
b-2) is at the top of the
hierarchy for all managed
objects of the MIB-II. mib-2 (1)
• Manufacturers of networking
system (1)
equipment can add product at (3) icmp (5) udp (7) snmp (11)
specific objects to the interface (2) ip (4) tcp (6) egp (8) transmiss
hierarchy.
ipForwDatagrams (6)
ipForwDatagrams OBJECT-TYPE
SYNTAX Counter
ACCESS read-only
STATUS mandatory
DESCRIPTION
"The number of input datagrams for which this
entity was not their final IP destination, as a
result of which an attempt was made to find a
route to forward them to that final destination.
In entities which do not act as IP Gateways, this
counter will include only those packets which were
Source-Routed via this entity, and the Source-
Route option processing was successful."
::= { ip 6 }
SNMP manager
get-next-request
SNMP agent
get-response Port 161
set-request
get-response Port 161
– SNMPv3 (2002)
• SNMPv3 started from SNMPv1 (and not SNMPv2c)
• Addresses security