Chapter 1 Web Server
Chapter 1 Web Server
Client/Server
Networking Model
Components
Clients
Servers
Communication Networks
Clients
Applications that run on computers
Rely on servers for
Files
Devices
Processing power
Servers
Computers or processes that manage
network resources
Disk
Servers Manage
Resources
Communication Networks
Networks Connect
Clients and Servers
The Internet
Technical origin: ARPANET (late 1960s)
The Internet
Open-access networks
NSFNET (1985-1995)
The Internet
The Internet
Original NSFNET backbone speed: 56 kbit/s
Upgraded to 1.5 Mbit/s (T1) in 1988
Upgraded to 45 Mbit/s (T3) in 1991
In 1988, networks in Canada and France
connected to NSFNET
In 1990, ARPANET is decommissioned, NSFNET
the center of the internet
10
The Internet
Internet: the network of networks
connected via the public backbone and
communicating using TCP/IP
communication protocol
11
Internet Protocols
Communication protocol: how computers
talk
IP
IP function: transfer data from source device to
destination device
IP source software creates a packet representing
the data
IP
Source
Network 1
Gateway
Destination
Gateway
Network 2
Network 3
15
IP
Source
LAN 1
Gateway
Destination
Gateway
Internet Backbone
LAN 2
16
TCP
Establish
connection.
{
{
Send packet
with
acknowledgment.
Resend packet if
no (or delayed)
acknowledgment.
Heres a packet.
Source
Got it.
Destination
Heres a packet.
Heres a resent packet.
Got it.
18
TCP
TCP also adds concept of a port
TCP
20
Builds on IP
Provides port concept
No connection concept
No transmission guarantee
Host names
DNS
Domains are divided into second-level
domains, which can be further divided into
subdomains, etc.
23
DNS
nslookup program provides commandline access to DNS (on most systems)
looking up a host name given an IP address
is known as a reverse lookup
DNS
ipconfig (on windows) can be used to
find the IP address (addresses) of your
machine
ipconfig /displaydns displays the
contents of the DNS Resolver Cache
(ipconfig /flushdns to flush it)
25
26
Higher-level Protocols
Many protocols build on TCP
Some examples:
27
HTTP
Normally implemented over a TCP connection (80
is standard port number for HTTP)
Typical browser-server interaction:
HTTP
The information transmitted using HTTP is
often entirely text
Can use the Internets Telnet protocol to
simulate browser request and view server
response
32
HTTP
Connect
Send
Request
{
{
Receive
Response
$ telnet www.example.org 80
Trying 192.0.34.166...
Connected to www.example.com
(192.0.34.166).
Escape character is ^].
GET / HTTP/1.1
Host: www.example.org
HTTP/1.1 200 OK
Date: Thu, 09 Oct 2003 20:30:49 GMT
33
HTTP Request
Structure of the request:
start line
header field(s)
blank line
optional body
34
HTTP Request
Structure of the request:
start line
header field(s)
blank line
optional body
35
HTTP Request
Start line
36
HTTP Request
Start line
HTTP Request
Start line
38
HTTP Request
Uniform Resource Identifier (URI)
Ex:
Ex:
39
URI
URIs are of two types:
HTTP Request
Start line
41
HTTP Request
Common request methods:
GET
Used
POST
Used
HEAD
Requests
HTTP Request
Structure of the request:
start line
header field(s)
blank line
optional body
43
HTTP Request
Header field structure:
Syntax
HTTP Request
Common header fields:
HTTP Response
Structure of the response:
status line
header field(s)
blank line
optional body
48
HTTP Response
Structure of the response:
status line
header field(s)
blank line
optional body
49
HTTP Response
Status line
HTTP version
status code
reason phrase (intended for human use)
50
HTTP Response
Status code
Three-digit number
First digit is class of the status code:
1=Informational
2=Success
3=Redirection (alternate URL is supplied)
4=Client Error
5=Server Error
See http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html
51
HTTP Response
Structure of the response:
status line
header field(s)
blank line
optional body
52
HTTP Response
Common header fields:
Client Caching
A cache is a local copy of information
obtained from some other source
Most web browsers use cache to store
requested resources so that subsequent
requests to the same resource will not
necessarily require an HTTP
request/response
Client
Client Caching
Server
Web
Server
3. Store image
Cache
55
Client
Browser
I need that
image
again
Client Caching
Server
Web
Server
Cache
56
Client
Client Caching
Server
This
Browser
I need that
image
again
Web
Server
Cache
57
Client
Client Caching
Web
Server
Browser
I need that
image
again
Get
image
Server
or this
Cache
58
Client Caching
Cache advantages
Cache disadvantage
Client Caching
Validating cached resource:
Send HTTP HEAD request and check LastModified or ETag header in response
Compare current date/time with Expires header
sent in response containing resource
If no Expires header was sent, use heuristic
algorithm to estimate value for Expires
Ex:
Character Sets
Every document is represented by a string of
integer values (code points)
The mapping from code points to characters is
defined by a character set
Some header fields have character set values:
Character Sets
Technically, many character sets are
actually character encodings
Character Sets
Typical US PC produces ASCII documents
US-ASCII character set can be used for such
documents, but is not recommended
UTF-8 and ISO-8859-1 are supersets of USASCII and provide international compatibility
Web Clients
Many possible web clients:
Web Browsers
First graphical browser running on generalpurpose platforms: Mosaic (1993)
65
Web Browsers
66
Web Browsers
Primary tasks:
67
HTTP URLs
http://www.example.org:56789/a/b/c.txt?t=win&s=chess#para5
host (FQDN)
authority
port
path
query
fragment
Request-URI
Web Browsers
Standard features
Web Browsers
Additional functionality:
Web Servers
Basic functionality:
Web Servers
httpd: UIUC, primary Web server c. 1995
Apache: A patchy version of httpd, now the
most popular server (esp. on Linux platforms)
IIS: Microsoft Internet Information Server
Tomcat:
Java-based
Provides container (Catalina) for running Java servlets
(HTML-generating programs) as back-end to Apache or
IIS
Can run stand-alone using Coyote HTTP front-end
72
Web Servers
Some Coyote communication parameters:
Allowed/blocked IP addresses
Max. simultaneous active TCP connections
Max. queued TCP connection requests
Keep-alive time for inactive TCP connections
Web Servers
Some Catalina container parameters:
74
75
76
77
78
79
80
82
Access control:
86
Secure Servers
Since HTTP messages typically travel over
a public network, private information (such
as credit card numbers) should be encrypted
to prevent eavesdropping
https URL scheme tells browser to use
encryption
Common encryption standards:
Secure
Servers
Id like to talk securely to you (over port 443)
HTTP
Requests
HTTP
Requests
TLS/
SSL
TLS/
SSL
Web
Server
HTTP
Responses
88
Secure Servers
Man-in-the-Middle Attack
Fake
DNS
Server
Whats IP
address for
100.1.1.1
www.example.org?
Browser
Fake
www.example.org
100.1.1.1
My credit card number is
Real
www.example.org
89
Secure Servers
Preventing Man-in-the-Middle
Fake
DNS
Server
Whats IP
address for
100.1.1.1
www.example.org?
Browser
Fake
www.example.org
100.1.1.1
Send me a certificate of identity
Real
www.example.org
90