Web Essentials: Clients, Servers, and Communication
Web Essentials: Clients, Servers, and Communication
The Internet
Technical origin: ARPANET (late 1960s)
One of earliest attempts to network
heterogeneous, geographically dispersed
computers
Email first available on ARPANET in 1972
(and quickly very popular!)
The Internet
Open-access networks
Regional university networks (e.g., SURAnet)
CSNET for CS departments not on ARPANET
The Internet
The Internet
Internet: the network of networks
connected via the public backbone and
communicating using TCP/IP
communication protocol
Backbone initially supplied by NSFNET,
privately funded (ISP fees) beginning in 1995
Internet Protocols
Communication protocol: how computers
talk
Cf. telephone protocol: how you answer and
end call, what language you speak, etc.
IP
IP function: transfer data from source device to
destination device
IP source software creates a packet
representing the data
Header: source and destination IP addresses, length
of data, etc.
Data itself
IP
Source
Network 1
Gateway
Destination
Gateway
Network 2
Network 3
TCP
Establish
connection.
{
{
{
Send packet
with
acknowledgment.
Resend packet if
no (or delayed)
acknowledgment.
Destination
Got it.
Heres a packet.
Heres a resent packet.
Got it.
11
TCP
TCP also adds concept of a port
TCP header contains port number
representing an application program on the
destination computer
Some port numbers have standard meanings
Example: port 25 is normally used for email
transmitted using the Simple Mail Transfer
Protocol (SMTP)
TCP
13
Host names
Labels separated by dots, e.g.,
www.example.org
Final label is top-level domain
Generic: .com, .org, etc.
Country-code: .us, .il, etc.
15
DNS
Domains are divided into second-level
domains, which can be further divided into
sub-domains, etc.
E.g., in www.example.com, example is a
second-level domain
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
Recall that single host may have multiple IP
addresses.
Address returned is the canonical IP address
specified in the DNS system.
17
18
Higher-level Protocols
Many protocols build on TCP
Telephone analogy: TCP specifies how we
initiate and terminate the phone call, but some
other protocol specifies how we carry on the
actual conversation
Some examples:
SMTP (email)
FTP (file transfer)
HTTP (transfer of Web documents)
19
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
24
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
25
HTTP Request
Structure of the request:
start line
header field(s)
blank line
optional body
26
HTTP Request
Structure of the request:
start line
header field(s)
blank line
optional body
27
HTTP Request
Start line
Example: GET / HTTP/1.1
28
HTTP Request
Start line
Example: GET / HTTP/1.1
29
HTTP Request
Start line
Example: GET / HTTP/1.1
30
HTTP Request
Uniform Resource Identifier (URI)
Syntax: scheme : scheme-depend-part
Ex: In http://www.example.com/
the scheme is http
URI
URIs are of two types:
Uniform Resource Name (URN)
Can be used to identify resources with unique
names, such as books (which have unique ISBNs)
Scheme is urn (urn:isbn:0451450523)
HTTP Request
Start line
Example: GET / HTTP/1.1
33
HTTP Request
Common request methods:
GET
Used if link is clicked or address typed in browser
No body in request with GET method
POST
Used when submit button is clicked on a form
Form information contained in body of request
HEAD
Requests that only header fields (no body) be
returned in the response
34
HTTP Request
Structure of the request:
start line
header field(s)
blank line
optional body
35
HTTP Request
Header field structure:
field name : field value
Syntax
Field name is not case sensitive
Field value may continue on multiple lines by
starting continuation lines with white space
Field values may contain MIME types, quality
values, and wildcard characters (*s)
36
37
HTTP Request
Common header fields:
HTTP Response
Structure of the response:
status line
header field(s)
blank line
optional body
40
HTTP Response
Structure of the response:
status line
header field(s)
blank line
optional body
41
HTTP Response
Status line
Example: HTTP/1.1 200 OK
42
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
HTTP Response
Structure of the response:
status line
header field(s)
blank line
optional body
44
HTTP Response
Common header fields:
Connection, Content-Type, Content-Length
Date: date and time at which response was generated
(required)
Location: alternate URI if status is redirection
Last-Modified: date and time the requested resource
was last modified on the server
Expires: date and time after which the clients copy of
the resource will be out-of-date
ETag: a unique identifier for this version of the
requested resource (changes if resource changes)
45
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
Ex: icon appearing multiple times in a Web
page
46
Client Caching
Server
Client
Web
Server
3. Store image
Cache
47
Client Caching
Client
Browser
I need that
image
again
Server
Web
Server
Cache
48
Client Caching
Server
Client
This
HTTP request for image
Browser
I need that
image
again
Web
Server
Cache
49
Client Caching
Server
Client
Web
Server
Browser
I need that
image
again
Get
image
or this
Cache
50
Client Caching
Cache advantages
(Much) faster than HTTP request/response
Less network traffic
Less load on server
Cache disadvantage
Cached copy of resource may be invalid
(inconsistent with remote version)
51
Conditional GET
Goal: dont send object if
cache
cache has up-to-date
HTTP request msg
cached version
If-modified-since:
cache: specify date of
<date>
cached copy in HTTP
HTTP response
request
HTTP/1.0
304 Not Modified
If-modified-since:
<date>
HTTP request msg
server: response contains
If-modified-since:
no object if cached copy
<date>
is up-to-date:
HTTP response
HTTP/1.0 304 Not
HTTP/1.0 200 OK
<data>
Modified
server
object
not
modified
object
modified
52
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:
Accept-Charset: request header listing character sets
that the client can recognize
Ex: accept-charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7
Character Sets
Technically, many character sets are
actually character encodings
An encoding represents code points using
variable-length byte strings
Most common examples are Unicode-based
encodings UTF-8 and UTF-16
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
UTF-8 can represent all ASCII characters using a
single byte each and arbitrary Unicode characters
using up to 4 bytes each
ISO-8859-1 is 1-byte code that has many characters
common in Western European languages, such as
55
Web Clients
Many possible web clients:
Text-only browser (lynx)
Mobile phones
Robots (software-only clients, e.g., search
engine crawlers)
etc.
56
Web Browsers
First graphical browser running on
general-purpose platforms: Mosaic (1993)
57
Web Browsers
58
Web Browsers
Primary tasks:
Convert web addresses (URLs) to HTTP
requests
Communicate with web servers via HTTP
Render (appropriately display) documents
returned by a server
59
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:
Execution of scripts (e.g., drop-down menus)
Event handling (e.g., mouse clicks)
GUI for controls (e.g., buttons)
Secure communication with servers
Display of non-HTML documents (e.g., PDF)
via plug-ins
62
Web Servers
Basic functionality:
Receive HTTP request via TCP
Map Host header to specific virtual host (one of many
host names sharing an IP address)
Map Request-URI to specific resource associated
with the virtual host
File: Return file in HTTP response
Program: Run program and return output in HTTP response
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
64
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:
Virtual host names and associated ports
Logging preferences
Mapping from Request-URIs to server
resources
Password protection of resources
Use of server-side caching
66
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 Socket Layer (SSL)
Transport Layer Security (TLS)
67
Secure Servers
Id like to talk securely to you (over port 443)
HTTP
Requests
HTTP
Requests
TLS/
SSL
TLS/
SSL
Web
Server
HTTP
Responses
68
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
Real
www.example.org
69
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
Real
www.example.org
70
End of Lecture 1
71