Академический Документы
Профессиональный Документы
Культура Документы
Applications
EECS 489 Computer Networks
http://www.eecs.umich.edu/courses/eecs489/w07
Z. Morley Mao
Wednesday Jan 17, 2007
Acknowledgement: Some slides taken from Kurose&Ross and Katz&Stoica Mao W07 1
Adminstrivia
Mao W07 2
Principles of network applications
Our goals: learn about protocols
conceptual, by examining popular
implementation application-level
aspects of network protocols
application protocols - HTTP
- transport-layer - FTP
service models - SMTP / POP3 / IMAP
- client-server - DNS
paradigm programming network
- peer-to-peer paradigm applications
- socket API
Mao W07 3
Some network apps
- communicate over a
network.
- e.g., Web: Web server
software communicates
with browser software
No software written for
devices in network core
- Network core devices do application
application
not function at app layer transport
transport
network
- This design allows for network
data link
data link
physical
rapid app development physical
Mao W07 5
Application architectures
Client-server
Peer-to-peer (P2P)
Hybrid of client-server and P2P
no always on server
arbitrary end systems
directly communicate
peers are intermittently
connected and change
IP addresses
example: Gnutella
Highly scalable
Why?
But difficult to manage
Mao W07 8
Hybrid of client-server and P2P
Napster
- File transfer P2P
- File search centralized:
• Peers register content at central server
• Peers query same central server to locate content
Instant messaging
- Chatting between two users is P2P
- Presence detection/location centralized:
• User registers its IP address with central server
when it comes online
• User contacts central server to find IP addresses
of buddies
Mao W07 9
Processes communicating
Mao W07 10
Sockets
host or host or
process sends/receives server server
messages to/from its
socket controlled by
app developer
socket analogous to door process process
- sending process shoves socket socket
message out of door TCP with
TCP with
- sending process relies on buffers, Internet buffers,
transport infrastructure on variables variables
other side of door which
brings message to socket at controlled
receiving process by OS
API: (1) choice of transport protocol; (2) ability to fix a few parameters
Mao W07 11
Addressing processes
For a process to
Identifier includes receive messages, it
both the IP address must have an
and port numbers identifier
associated with the
process on the host. A host has a unique
32-bit IP address
Example port
numbers: Q: does the IP
address of the host on
- HTTP server: 80
which the process
- Mail server: 25
runs suffice for
identifying the
process?
Mao W07 15
Internet transport protocol services
Mao W07 17
Web and HTTP
First some jargon
Web page consists of objects
Object can be HTML file, JPEG image, Java applet, audio
file,…
Web page consists of base HTML-file which includes
several referenced objects
Each object is addressable by a URL
Example URL:
www.someschool.edu/someDept/pic.gif
host name path name
HTTP: hypertext
transfer protocol HT
TP
Web’s application layer r
equ
PC running HT est
protocol TP
Explorer res
pon
client/server model se
- client: browser that
requests, receives, e st
u
“displays” Web objects
P r eq se Server
T o n
- server: Web server HT r es
p running
sends objects in T P Apache Web
HT
response to requests server
HTTP 1.0: RFC 1945
HTTP 1.1: RFC 2068 Mac running
Navigator
Mao W07 19
HTTP overview (continued)
Mao W07 21
Nonpersistent HTTP
Suppose user enters URL www.someSchool.edu/someDepartment/home.index
(contains text,
references to 10
jpeg images)
1a. HTTP client initiates a TCP
connection to HTTP server 1b. HTTP server at host
(process) at www.someSchool.edu www.someSchool.edu waiting
on port 80 for TCP connection at port 80.
“accepts” connection, notifying
client
time
Mao W07 22
Nonpersistent HTTP (cont.)
Mao W07 23
Response time modeling
Definition of RTT: time to
send a small packet to
travel from client to server
initiate TCP
and back. connection
Response time: RTT
request
one RTT to initiate TCP
file
connection RTT
time to
transmit
one RTT for HTTP request file
file
and first few bytes of received
HTTP response to return
file transmission time time time
Mao W07 24
Persistent HTTP
Nonpersistent HTTP issues: Persistent without pipelining:
requires 2 RTTs per object client issues new request
request line
(GET, POST, GET /somedir/page.html HTTP/1.1
HEAD commands) Host: www.someschool.edu
User-agent: Mozilla/4.0
header Connection: close
lines Accept-language:fr
Carriage return,
line feed (extra carriage return, line feed)
indicates end
of message
Mao W07 26
HTTP request message:
general format
Mao W07 27
Uploading form input
Post method:
Web page often
includes form input URL method:
Input is uploaded to Uses GET method
server in entity body Input is uploaded in
URL field of request
line:
www.somesite.com/animalsearch?monkeys&banana
Mao W07 28
Method types
HTTP/1.0 HTTP/1.1
GET GET, POST, HEAD
POST PUT
HEAD - uploads file in entity body
to path specified in URL
- asks server to leave
field
requested object out of
response DELETE
- deletes file specified in
the URL field
Mao W07 29
HTTP response message
status line
(protocol
status code HTTP/1.1 200 OK
status phrase) Connection close
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
Mao W07 30
HTTP response status codes
In first line in server->client response message.
A few sample codes:
200 OK
- request succeeded, requested object later in this message
301 Moved Permanently
- requested object moved, new location specified later in this message
(Location:)
400 Bad Request
- request message not understood by server
404 Not Found
- requested document not found on this server
505 HTTP Version Not Supported
Mao W07 31
User-server state: cookies
Mao W07 32
Cookies: keeping “state” (cont.)
client server
Cookie file usual http request msg server ne
da try i
tab n b
usual http response + creates ID as ac
e ke
ebay: 8734 Set-cookie: 1678 1678 for user nd
Cookie file
usual http request msg
amazon: 1678 cookie: 1678 cookie- ss
ebay: 8734 specific acce
usual http response msg action
ss
one week later:
ce
ac
usual http request msg
Cookie file cookie-
cookie: 1678
amazon: 1678 spectific
ebay: 8734 usual http response msg action
Mao W07 33
Cookies (continued)
aside
What cookies can bring: Cookies and privacy:
authorization cookies permit sites to
shopping carts
learn a lot about you
you may supply name
recommendations
and e-mail to sites
user session state (Web
search engines use
e-mail) redirection & cookies to
learn yet more
advertising companies
obtain info across sites
Mao W07 35
More about Web caching
Mao W07 36
Caching example
Assumptions origin
average object size = 100,000 bits servers
avg. request rate from institution’s
public
browsers to origin servers = 15/sec Internet
delay from institutional router to any
origin server and back to router = 2
sec
1.5 Mbps
Consequences access link
utilization on LAN = 15%
institutional
utilization on access link = 100% network
10 Mbps LAN
total delay = Internet delay + access
delay + LAN delay
= 2 sec + minutes + milliseconds
institutional
cache
Mao W07 37
Caching example (cont)
origin
Possible solution servers
increase bandwidth of
public
access link to, say, 10 Internet
Mbps
Consequences
utilization on LAN = 15% 10 Mbps
access link
utilization on access link = 15%
institutional
Total delay = Internet delay +
network
access delay + LAN delay 10 Mbps LAN
Mao W07 38
Caching example (cont)
origin
Install cache servers
suppose hit rate is 0.4 public
Consequence Internet
40% requests will be satisfied
almost immediately
60% requests satisfied by origin 1.5 Mbps
server access link
utilization of access link reduced
institutional
to 60%, resulting in negligible
network
delays (say 10 msec) 10 Mbps LAN
total avg delay = Internet delay +
access delay + LAN delay = .
6*(2.01) secs + milliseconds <
1.4 secs institutional
cache
Mao W07 39
Conditional GET
Goal: don’t send object if cache server
cache has up-to-date cached
HTTP request msg
version If-modified-since:
cache: specify date of cached <date>
object
copy in HTTP request not
If-modified-since: HTTP response modified
<date> HTTP/1.0
304 Not Modified
server: response contains no
object if cached copy is up-to-
date: HTTP request msg
HTTP/1.0 304 Not If-modified-since:
Modified <date> object
modified
HTTP response
HTTP/1.0 200 OK
<data>
Mao W07 40
FTP: the file transfer protocol
Mao W07 41
FTP: separate control, data
connections
TCP control connection
FTP client contacts FTP port 21
server at port 21, specifying
TCP as transport protocol
Client obtains authorization TCP data connection
FTP port 20 FTP
over control connection
client server
Client browses remote
directory by sending Server opens a second TCP data
commands over control connection to transfer another file.
connection.
Control connection: “out of band”
When server receives a
command for a file transfer, FTP server maintains “state”:
the server opens a TCP current directory, earlier
data connection to client authentication
After transferring one file,
server closes connection.
Mao W07 43
outgoing
Electronic Mail message queue
user mailbox
user
Three major components: agent
user agents mail
user
mail servers server
agent
simple mail transfer protocol:
SMTP
SMTP mail
server user
User Agent SMTP agent
a.k.a. “mail reader”
composing, editing, reading SMTP
mail user
mail messages agent
server
e.g., Eudora, Outlook, elm,
Netscape Messenger
user
outgoing, incoming messages agent
stored on server user
agent
Mao W07 44
Electronic Mail: mail servers
user
Mail Servers agent
mailbox contains incoming mail
user
messages for user server
agent
message queue of
SMTP
outgoing (to be sent) mail mail
messages server user
SMTP protocol between SMTP agent
Where can we find out the mail servers for a domain? Mao W07 45
Electronic Mail: SMTP [RFC 2821]
Mao W07 46
Scenario: Alice sends message to Bob
4) SMTP client sends Alice’s
1) Alice uses UA to compose message over the TCP
message and “to” connection
bob@someschool.edu
5) Bob’s mail server places the
2) Alice’s UA sends message to message in Bob’s mailbox
her mail server; message
6) Bob invokes his user agent to
placed in message queue
read message
3) Client side of SMTP opens
TCP connection with Bob’s
mail server
1 mail
mail
server user
user server
2 agent
agent 3 6
4 5
Mao W07 47
Sample SMTP interaction
S: 220 hamburger.edu
C: HELO crepes.fr
S: 250 Hello crepes.fr, pleased to meet you
C: MAIL FROM: <alice@crepes.fr>
S: 250 alice@crepes.fr... Sender ok
C: RCPT TO: <bob@hamburger.edu>
S: 250 bob@hamburger.edu ... Recipient ok
C: DATA
S: 354 Enter mail, end with "." on a line by itself
C: Do you like ketchup?
C: How about pickles?
C: .
S: 250 Message accepted for delivery
C: QUIT
S: 221 hamburger.edu closing connection
Mao W07 48
Try SMTP interaction for yourself:
telnet servername 25
see 220 reply from server
enter HELO, MAIL FROM, RCPT TO, DATA,
QUIT commands
above lets you send email without using email
client (reader)
Mao W07 49
SMTP: final words
Mao W07 50
Mail message format
Mao W07 51
Message format: multimedia extensions
MIME: multimedia mail extension, RFC 2045, 2056
additional lines in msg header declare MIME content
type
From: alice@crepes.fr
MIME version To: bob@hamburger.edu
Subject: Picture of yummy crepe.
method used MIME-Version: 1.0
to encode data Content-Transfer-Encoding: base64
Content-Type: image/jpeg
multimedia data
type, subtype, base64 encoded data .....
parameter declaration .........................
......base64 encoded data
encoded data
Mao W07 52
Mail access protocols
SMTP SMTP access user
user
agent protocol agent
Mao W07 53
POP3 protocol
S: +OK POP3 server ready
authorization phase C: user bob
client commands: S: +OK
- user: declare username C: pass hungry
- pass: password S: +OK user successfully logged on
Mao W07 55
DNS: Domain Name System
Mao W07 56
DNS
Mao W07 57
Distributed, Hierarchical Database
Root DNS Servers
m WIDE Tokyo
e NASA Mt View, CA
f Internet Software C. Palo Alto,
CA (and 17 other locations) 13 root name servers
worldwide
Mao W07 59
TLD and Authoritative Servers
Mao W07 60
Local Name Server
Mao W07 61
root DNS server
Example
2
Host at cis.poly.edu wants 3
IP address for TLD DNS server
gaia.cs.umass.edu 4
gaia.cs.umass.edu
Mao W07 62
Recursive queries
root DNS server
recursive query:
puts burden of name
resolution on contacted 2 3
name server
7 6
heavy load?
TLD DNS server
iterated query:
contacted server replies
with name of server to local DNS server
5 4
contact dns.poly.edu
“I don’t know this name, 1 8
but ask this server”
gaia.cs.umass.edu
Mao W07 63
DNS: caching and updating
records
once (any) name server learns mapping, it caches
mapping
- cache entries timeout (disappear) after some time
- TLD servers typically cached in local name servers
• Thus root name servers not often visited
update/notify mechanisms under design by IETF
- RFC 2136
- http://www.ietf.org/html.charters/dnsind-charter.html
Mao W07 64
DNS records
DNS: distributed db storing resource records (RR)
RR format: (name, value, type, ttl)
Type=A Type=CNAME
- name is hostname - name is alias name for some
- value is IP address “cannonical” (the real) name
www.ibm.com is really
Type=NS servereast.backup2.ibm.com
- name is domain (e.g. - value is cannonical name
foo.com)
- value is IP address of
authoritative name server
for this domain
Type=MX
- value is name of mailserver
associated with name
Mao W07 65
DNS protocol, messages
DNS protocol : query and reply messages, both with same message format
msg header
identification: 16 bit # for
query, reply to query uses
same #
flags:
- query or reply
- recursion desired
- recursion available
- reply is authoritative
Mao W07 66
DNS protocol, messages
RRs in reponse
to query
records for
authoritative servers
additional “helpful”
info that may be used
Mao W07 67
Inserting records into DNS
Example: just created startup “Network Utopia”
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)
- Registrar inserts two RRs into the com TLD server:
Mao W07 68