计算机代考程序代写 javascript database Java cache Week 9: Application Layer Internet Technologies COMP90007

Week 9: Application Layer Internet Technologies COMP90007
Lecturer: Semester 2, 2021
© University of Melbourne 2020
1

World Wide Web (WWW)
n World Wide Web key components are?
q Client and Server software – Firefox is the client software for web access where Apache is on the server side
q Web mark-up languages – HTML – how webpages are coded
q Web scripting languages – More dynamicity to webpages – Javascript
q HTTP – about how to transfer
2

Web Access
n A web page consists of objects
n An object can be HTML file but also JPEG
image, Java applet, audio file, …
n A web page consists of a base HTML file which includes several referenced objects
n Each object is addressable by a URL (uniform resource locator)
n Example URL: www.someschool.edu/someDept/pic.gif
path name
host name
3

HTTP: hypertext transfer protocol
HyperText “text … cross-referencing between sections of text and associated graphic material”
n HTTP is at the application layer
n client/server model
q client: browser that requests, receives and displays Web objects
q server: Web server sends objects in response to requests
PC running Explorer
Mac running Safari
Server running
Apache Web server
4
HTTP request
HTTP response
HTTP request
HTTP response

HTTP Connections
n Non-persistent HTTP
q at most one object sent over a TCP connection
n Persistent HTTP
§ multiple objects can be sent over a single TCP connection between client and server
5

Non-persistent HTTP (I)
suppose user enters URL:
www.someSchool.edu/someDepartment/home.index
contains text and references to 10 images
1a. HTTP client initiates TCP connection to HTTP server (process) at www.someSchool.edu on port 80
2. HTTP client sends a HTTP request message (containing URL) into TCP connection socket. Message indicates that client wants
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
time object someDepartment/ message into its socket home.index
6

Non-persistent HTTP (II)
time
4. HTTP client receives response message containing HTML file
6. Parses HTML file, and finds 10 referenced jpeg objects
7. Steps 1-6 repeated for each of the 10 jpeg objects
5. HTTP server closes TCP connection.
7

Non-Persistent HTTP:Response Time
n Round Trip Time (RTT) – time for a small packet to travel from client to server and back
n Response time
§ oneRTTtoinitiateTCP
connection
§ one RTT for HTTP request
and first few bytes of HTTP
response to return
§ filetransmissiontime
n Total response time = 2 RTT+
file transmission time
client
initiate TCP connection
RTT
request file RTT
file received
server
time to transmit entire file
time
time
8

Non-Persistent HTTP – Issues
n Requires new connection per requested object n OS overhead for each TCP connection
n Delivery delay of 2 RTTs per requested object
9

Persistent HTTP
n Server leaves connection open after sending response
n Subsequent HTTP messages between same client/server sent over open connection
n Pipelining – client sends request as soon as it encounters a referenced object
§ èas little as one RTT for all the referenced objects
n Server closes a connection if it hasn’t been used for some time
10

Sequential vs Pipeline
Sequential Client
Sever
Pipeline Client
Sever
11
Time
Time

HTTP Request Message: Example
request line (GET, POST, HEAD commands)
header lines
indicates end of header lines
GET /index.html HTTP/1.1\r\n
Host: www-net.cs.umass.edu\r\n
User-Agent: Firefox/3.6.10\r\n
Accept: text/html,application/xhtml+xml\r\n
Accept-Language: en-us,en;q=0.5\r\n
Accept-Encoding: gzip,deflate\r\n
Accept-Charset: ISO-8859-1,utf-8;q=0.7\r\n
Keep-Alive: 115\r\n
Connection: keep-alive\r\n
\r\n
Persistent HTTP
12

HTTP Response Message: Example
200 OK – request succeeded, requested object later in this msg ….
404 Not Found – requested document not found on this server
status line:
header lines
HTTP/1.1 200 OK\r\n
Date: Sun, 26 Sep 2010 20:09:20 GMT\r\n
Server: Apache/2.0.52 (CentOS)\r\n
Last-Modified: Tue, 30 Oct 2007 17:00:02 GMT\r\n
Content-Length: 2652\r\n
Keep-Alive: timeout=10, max=100\r\n
Connection: Keep-Alive\r\n
Content-Type: text/html; charset=ISO-8859-1\r\n
\r\n
data data data data data …
data, e.g., requested HTML file
13

HTTP Request Methods
(write a new page / resource)
14

HTTP Error Codes
15

Cookies
n The http servers are stateless
n Cookies to place small amount (<4Kb) of info on users computer and re-use deterministically (RFC 2109) n Questionable mechanism for tracking users (invisibly perhaps) 16 User-server Interaction: Cookie Example 1 Susan always accesses the Internet from her (cookie- enabled) home PC. She visits a specific (cookie- enabled) e-commerce site for the first time n When the initial HTTP requests arrives at the site, the site creates: q unique ID q entry in backend database for ID n The e-commerce site then responds to Susan’s browser, including in the HTTP response ID q Set-cookie: 1234 17 User-server Interaction: Cookie Example (Contd.) n Susan’s browser appends a line to a cookie file that it manages § www.e-commerce-site.com1234 n Next time Susan request a page from that site, a cookie header line will be added to her request § Cookie:1234 n The server will then perform a cookie-specific action 18 Keeping state with Cookies: Example 2 client ebay 8734 cookie file ebay 8734 amazon 1678 one week later ebay 8734 amazon 1678 server Amazon server creates ID 1678 for user cookie- specific action cookie- specific action create entry backend database usual http request msg usual http response Set-cookie: 1678 usual http request msg cookie: 1678 access access usual http response msg usual http request msg cookie: 1678 usual http response msg 19 Beyond User Tracking: Advantages of Cookies n Authorization n Shopping carts n Recommendations n User session state 20 Cookies vs Sessions n Both introduce “memory” or state into HTTP and are about multiple TCP connections Sessions n Sessions information regarding visitor’s interaction stored at the server side: up to some hours n When user closes the website, the session ends n Sessions information size can be large Cookies n Cookies are transferred between server and client n Cookie information stored at both client and server n Maintain client information until deleted n Cookies information size limited 21 Web Caches (Proxy Server) Goal: satisfy client request without involving origin server v User sets browser to access Web via cache èbrowser sends all HTTP requests to cache § if object in cache, cache returns object § else cache requests object from origin server, then returns object to client origin server client Proxy server cache client 22 HTTP request HTTP response HTTP request HTTP response HTTP request HTTP response More about Web Caching n Cache acts as both client and server n Typically cache is installed by ISP (university, company, residential ISP) n Causes problems for frequently changing data though Why Web caching? n Reduce response time for client request n Reduce traffic on an institution’s access link 23