cs 372 – introduction to computer networks* wednesday june 30
Post on 03-Jan-2016
15 Views
Preview:
DESCRIPTION
TRANSCRIPT
Chapter 2, slide: 1
CS 372 – introduction to computer networks*Wednesday June 30
Announcements: Assignment 2 is posted.
Acknowledgement: slides drawn heavily from Kurose & Ross
* Based in part on slides by Bechir Hamdaoui and Paul D. Paulson.
Chapter 2, slide: 2
Chapter 2: Application layer
Principles of network applications app architectures app requirements
Web and HTTP File transfer: FTP
P2P file sharing Socket programming
with TCP
Chapter 2, slide: 3
Web and HTTPFirst some terminologies:
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 (Uniform Resource Locator):
www.someschool.edu/someDept/pic.gif
host name path name
Chapter 2, slide: 4
HTTP overview: app architecture
HTTP: hypertext transfer protocol
Web’s appl-layer protocol client/server model
client: browser that requests, receives, “displays” Web objects
server: Web server sends objects in response to requests
HTTP 1.0: RFC 1945 HTTP 1.1: RFC 2068
PC runningExplorer
Server running
Apache Webserver
Mac runningNavigator
HTTP request
HTTP request
HTTP response
HTTP response
Chapter 2, slide: 5
HTTP overview (continued)
Uses TCP: client initiates TCP
connection (creates socket) to server, port 80
server accepts TCP connection from client
HTTP messages exchanged between browser (HTTP client) and Web server (HTTP server)
TCP connection closed
HTTP is “stateless” server maintains no
information about past client requests
Protocols that maintain “state” are complex!
past history (state) must be maintained
if server/client crashes, their views of “state” may be inconsistent, must be reconciled
aside
Chapter 2, slide: 6
HTTP connections
Nonpersistent HTTP At most one object is
sent over a TCP connection.
HTTP/1.0 uses nonpersistent HTTP
Persistent HTTP Multiple objects can
be sent over single TCP connection between client and server.
HTTP/1.1 uses persistent connections in default mode
Chapter 2, slide: 7
Nonpersistent HTTPSuppose user enters URL www.someSchool.edu/someDepartment/home.index
1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80
2. HTTP client sends HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants object someDepartment/home.index
1b. HTTP server at host www.someSchool.edu waiting for TCP connection at port 80. “accepts” connection, notifying client
3. HTTP server receives request message, forms response message containing requested object, and sends message into its socket
time
(contains text, references to 10
jpeg images)
Chapter 2, slide: 8
Nonpersistent HTTP (cont.)
5. HTTP client receives response message containing html file, displays html. Parsing html file, finds 10 referenced jpeg objects
6. Steps 1-5 repeated for each of 10 jpeg objects
4. HTTP server closes TCP connection.
time
Chapter 2, slide: 9
Non-Persistent HTTP: Response timeDefinition of RTT (round trip
time): time to send a small packet to travel from client to server and back.
Response time: one RTT to initiate TCP
connection one RTT for HTTP request
and first few bytes of HTTP response to return
file transmission time = 2RTT + transmit time
time to transmit file
initiate TCPconnection
RTT
requestfile
RTT
filereceived
time time
Chapter 2, slide: 10
Non-Persistent HTTP: issues
time to transmit file
initiate TCPconnection
RTT
requestfile
RTT
filereceived
time time
Nonpersistent HTTP: Name some issues?? requires 2 RTTs per
object
E.g., a 10 object-page needs ~ 20 RTTs
Open/close TCP connection for each object => OS overhead
Any ideas for improvement?
Chapter 2, slide: 11
Persistent HTTP
Persistent HTTP server leaves
connection open after sending response
subsequent HTTP messages between same client/server sent over open connection
reduces response time
Persistent without pipelining:
client issues new request only when previous response has been received
one RTT for each referenced object
Persistent with pipelining: default in HTTP/1.1 client sends requests as
soon as it encounters a referenced object
as little as one RTT for all the referenced objects
Chapter 2, slide: 12
HTTP request message
two types of HTTP messages: request, response
HTTP request message: ASCII (human-readable format)
GET /somedir/page.html HTTP/1.1Host: www.someschool.edu User-agent: Mozilla/4.0Connection: close Accept-language:fr
(extra carriage return, line feed)
request line(GET, POST,
HEAD commands)
header lines
Carriage return, line feed
indicates end of message
Chapter 2, slide: 13
HTTP response message
HTTP/1.1 200 OK Connection closeDate: Thu, 06 Aug 1998 12:00:15 GMT Server: Apache/1.3.0 (Unix) Last-Modified: Mon, 22 Jun 1998 …... Content-Length: 6821 Content-Type: text/html data data data data data ...
status line(protocol
status codestatus phrase)
header lines
Entity body:data, e.g., requestedHTML file
Chapter 2, slide: 14
HTTP response status codes
200 OK request succeeded, requested object later in this
message
301 Moved Permanently requested object moved, new location specified later
in this message (Location:)
400 Bad Request request message not understood by server
404 Not Found requested document not found on this server
505 HTTP Version Not Supported
In first line in server -> client response message.
A few sample codes:
Chapter 2, slide: 15
Trying out HTTP (client side) for yourself
1. Telnet to your favorite Web server:
Opens TCP connection:• to port 80 (default HTTP port)• at cis.poly.edu (~ IP address)• anything typed is sent there
telnet cis.poly.edu 80
2. Type in a GET HTTP request:
GET /~ross/ HTTP/1.1Host: cis.poly.edu
By typing this in (hit carriagereturn twice), you sendthis minimal (but complete) GET request to HTTP server
3. Look at response message sent by HTTP server!Try it at home or lab!
Chapter 2, slide: 16
time to transmit file
initiate TCPconnection
RTT
requestfile
RTT
filereceived
time time
A HTTP request consists of: 1 basic html object 2 referenced JPEG objects All objects of size = 106bits
RTT = 1 second Transmission rate = 1Mbps Consider transmission delay of
objects only
Question: how long it takes to receive the entire page:a) Non-persistent connectionb) Persistent without pipeliningc) Persistent with pipelining
Web and HTTP: Review Question
Chapter 2, slide: 17
time to transmit file
initiate TCPconnection
RTT
requestfile
RTT
filereceived
time time
A HTTP request consists of: 1 basic html object 2 referenced JPEG objects All objects of size = 106bits
RTT = 1 second Transmission rate = 1Mbps Consider transmission delay of
objects only
Answer: (transmit time = 1 sec)a) 3+3+3=9 sec
initiate + request + transmit for each of all 3
b) 1+2+2+2=7 sec initiate + (request + transmit for each of all 3)
c) 1+2+3=6 sec initiate + (request + transmit for basic) + (one request for 2 + two transmits, one for each of the 2 objects)
Web and HTTP: Review Question
User-server state: cookies
Many major Web sites use cookies
Four components:1) cookie header line of
HTTP response message
2) cookie header line in HTTP request message
3) cookie file kept on user’s host, managed by user’s browser
4) back-end database at Web site
Example: Susan always access
Internet always from PC visits specific e-
commerce site for first time
when initial HTTP requests arrives at site, site creates: unique ID entry in backend
database for ID
Cookies: keeping “state” (cont.)client server
usual http response msg
usual http response msg
cookie file
one week later:
usual http request msg
cookie: 1678cookie-specificaction
access
ebay 8734usual http request
msgAmazon server
creates ID1678 for user
create entry
usual http response Set-cookie: 1678
ebay 8734amazon 1678
usual http request msg
cookie: 1678cookie-spectificaction
accessebay 8734amazon 1678
backenddatabase
Cookies (continued)
What cookies can bring: authorization shopping carts recommendations user session state
(Web e-mail)
Cookies and privacy:• cookies permit sites
to learn a lot about you
• you may supply name and e-mail to sites
aside
How to keep “state”:• protocol endpoints: maintain
state at sender/receiver over multiple transactions
• cookies: http messages carry state
Chapter 2, slide: 21
Web caches (or proxy server)
If page is needed, browser requests it from the Web cache
Q: what if object not in cache??
cache requests object from origin server, then returns object to client
Goal: satisfy client request without involving origin server
client
Proxyserver
client
HTTP request
HTTP response
HTTP request HTTP request
origin server
origin server
HTTP response HTTP response
Chapter 2, slide: 22
More about Web caching
cache acts as both client and server
typically cache is installed by ISP (university, company, residential ISP)
Why Web caching? reduce response time
for client request
reduce traffic on an institution’s access link.
Chapter 2, slide: 23
Caching example
Assumptions avg. object size =
0.1x106bits avg. request rate from
institution to origin servers = 10/sec
Internet delay = 2 sec
Consequences utilization on LAN = 10%
(LAN: local area network) utilization on access link =
100% total delay = Internet delay +
access delay + LAN delay = 2 sec + minutes +
milliseconds
originservers
public Internet
institutionalnetwork 10 Mbps LAN
1 Mbps access link
institutionalcache
Chapter 2, slide: 24
Caching example (cont)
possible solution increase bandwidth of
access link to, say, 10 Mbps
consequence utilization on LAN = 10% utilization on access link =
10% Total delay = Internet delay +
access delay + LAN delay = 2 sec + msecs + msecs often a costly upgrade
originservers
public Internet
institutionalnetwork 10 Mbps LAN
10 Mbps access link
institutionalcache
Chapter 2, slide: 25
Caching example (cont)
possible solution: web cache
suppose hit rate is 0.4
consequence 40% requests will be satisfied
almost immediately
60% requests satisfied by origin server
utilization of access link reduced to 60%
total avg delay will also be reduced
originservers
public Internet
institutionalnetwork 10 Mbps LAN
1 Mbps access link
institutionalcache
Chapter 2, slide: 26
Web cache (cont)
Advantages are obvious: Reduce response time Reduce internet traffic
Any problems with caches??
Local cache copies of web pages may not be up-to-date??
What do we do then?
Solution Upon receiving a web
request, a cache must consult origin server to check whether the requested page is up-to-date
Conditional GET method What: Sent by cache to origin
server: check page status
When:For each new request: client checks with cache
Chapter 2, slide: 27
Conditional GET
Goal: don’t send object if cache has up-to-date version
How: cache specifies date of cached copy in HTTP requestIf-modified-since: <date>
Server: response contains no object if cached copy is up-to-date: HTTP/1.0 304 Not Modified
cache server
HTTP request msgIf-modified-since: <date>
HTTP responseHTTP/1.0
304 Not Modified
object not
modified
HTTP request msgIf-modified-since: <date>
HTTP responseHTTP/1.0 200 OK
<data>
object modified
Chapter 2, slide: 28
Chapter 2: Application layer
Principles of network applications
Web and HTTP FTP
P2P file sharing Socket programming
with TCP
Chapter 2, slide: 29
FTP: the file transfer protocol
transfer file to/from remote host client/server model
client: that initiates transfer (to or from remote) server: remote host
ftp: RFC 959
file transfer FTPserver
FTPuser
interface
FTPclient
local filesystem
remote filesystem
user at host
Chapter 2, slide: 30
FTP: separate control, data connections
FTP client contacts FTP server to open TCP control connection
client browses remote directory by sending commands over the TCP control connection.
FTPclient
FTPserver
TCP control connection
port 21
TCP data connectionport 20
when server receives file transfer command, server opens 2nd TCP data connection (for file) to client
after transferring one file, server closes TCP data connection.
Chapter 2, slide: 31
FTP: separate control, data connections
FTPclient
FTPserver
TCP control connection
port 21
TCP data connectionport 20
More on FTP server opens a
separate TCP data connection for each file to transfer
TCP control stays on
control connection: called: “out of band”
FTP server maintains “state”: current directory, earlier authent. => limit on concurrent connections
Chapter 2, slide: 32
Chapter 2: Application layer
Principles of network applications
Web and HTTP FTP
P2P file sharing Socket programming
with TCP
Chapter 2, slide: 33
File sharing approaches
There are 2 approaches
Centralized: Client-server architecture
Distributed: P2P architecture (e.g., BitTorrent)
obtain listof peers
trading chunks
peer
server
server
peers
Alice
Bob
Chapter 2, slide: 34
File sharing: P2P vs. client-server architectures
Robustness to failure
Scalability
Security
Performance
Client-Server
Single point of failure
Not scalable
More secure
Bottleneck
P2P
Fault-tolerant
Scalable
Less secure
Better
Chapter 2, slide: 35
Comparing Client-Server, P2P architecturesQuestion : What is the file distribution time:
from one server to N hosts?
us
u2d1 d2u1
uN
dN
Server
Network (with abundant bandwidth)
File, size F
us: server upload bandwidth
ui: client/peer i upload bandwidth
di: client/peer i download bandwidth
Chapter 2, slide: 36
Client-server: file distribution time
us
u2d1 d2u1
uN
dN
Server
Network (with abundant bandwidth)
F server
sequentially sends N copies: NF/us time
client i takes F/di
time to download
lower bound is alsoachievable
= dcs > max { NF/us, F/min(di) }i
Time to distribute F to N clients using
client/server approach
increases linearly in N(for large N)
uN NF bits must be downloaded- NF bits must be uploaded- Fastest possible upload rate (assuming all nodes sending file chunks to same peer) is:
us + ui
Chapter 2, slide: 37
P2P: file distribution time
us
u2d1 d2u1
dN
Server
Network (with abundant bandwidth)
F
server must send one copy: F/us time
client i takes F/di time to download
i=1,N
dP2P > max { F/us, F/min(di) , NF/(us + ui) }i=1,N
Chapter 2, slide: 38
0
0.5
1
1.5
2
2.5
3
3.5
0 5 10 15 20 25 30 35
N
Min
imum
Dis
trib
utio
n T
ime P2P
Client-Server
Comparing Client-server, P2P architectures
Chapter 2, slide: 39
Chapter 2: Application layer
Principles of network applications app architectures app requirements
Web and HTTP FTP
P2P file sharing Socket programming
with TCP (assignment 2)
Chapter 2, slide: 40
Assignment 2- programming partBuilding a Multi-Threaded Web Server
Read Chapter 2, Section 7 first• Good examples on how to write socket-programs
in Java using TCP
Then do your assignment• Socket/Java programming: relatively
simple and easy to do
Chapter 2, slide: 41
Chapter 2: Summary
application architectures client-server P2P
application service requirements: reliability, bandwidth, delay
Internet transport service model connection-oriented, reliable:
TCP unreliable, datagrams: UDP
our study of network apps now complete!
specific protocols: HTTP FTP P2P
socket programming (assignment 2)
top related