1 / 70

LECTURE

159.339. LECTURE. Client-Server Model. WWW, HTTP, INTERNET PROTOCOL STACK, TCP/IP, Xitami , CGI. Last time, we saw a quick tour of the different web technologies involved for a simple CGI program deployed in our own webserver .

lynley
Download Presentation

LECTURE

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 159.339 LECTURE Client-ServerModel WWW, HTTP, INTERNET PROTOCOL STACK, TCP/IP, Xitami, CGI

  2. Last time, we saw a quick tour of the different web technologies involved for a simple CGI program deployed in our own webserver. Next, we would like to see more details on the Client-Server interaction. We shall study the details of the internet protocol stack, the network core and the HTTP protocol responsible for allowing CLIENT-SERVER communication. We will also see how a webserver is installed and configured.

  3. Overview: Client-Server requests an Internet resource by specifying a URL and providing input via HTTP encoded strings Client Web browser OS Usually we want to open an HTML file from some website, but we can also open a program alternatively. HTML supports Javascript, DOM, CSS, HTML Events

  4. Overview: Client-Server requests an Internet resource by specifying a URL and providing input via HTTP encoded strings Client Web browser Server os Web server os Internet Network Core

  5. Overview: Client-Server Server-side program works out the necessary business logic and dynamicallybuilds an HTML response. Client Web browser Server os Web server os Internet

  6. Overview: Client-Server Client Server-side program sends back output as HTML using HTTPas transport mechanism Web browser Server Web server Internet

  7. Overview: Client-Server Client Client-side program (Internet Explorer, Firefox) displays the HTML output Web browser • HTML text • Graphics • Streaming video/audio • XML Server Web server Internet

  8. Overview: Client-Server Our codes might be embedded into an HTML, or vice-versa. It may generate an HTML on its own as well. Server My codes Web server PHP MySQL HTML Client Operating System Web browser Internet

  9. What is the HTTP protocol? What is a protocol in the first place?

  10. Hi TCP connection request Hi TCP connection reply 2:00 <file> time What’s a protocol? a human protocol and a computer network protocol: Got the time? Get http://www.massey.ac.nz/

  11. HTTP Protocol

  12. Client: makes a request requests an Internet resource by specifying a URL and providing input via HTTP encoded strings Client (browser) Web browser GET hello.php HTTP/1.1 Host: www.massey.ac.nz:80 Server os Web server os Internet Network Core

  13. Server: responds • Webserver supports HTTP. Server Web server My codes PHP MySQL HTML HTTP Client Operating System Web browser TCP/IP Internet

  14. HTTP and TCP/IP • Webserver supports HTTP. • HTTP compliancy is implemented • using TCP/IP components. Server Web server My codes PHP MySQL HTML HTTP Client Operating System Web browser TCP/IP HTTP/1.1 200 OK (document body) Internet

  15. Client-Server model • How do two computers talk to each other? Server Create a socket Bind socket to address Listen for connections Accept a client connection Send/receive data Client Create a socket Connect socket to server Send/receive data

  16. Internet protocols A bit of history... In a network, standards are needed for data representation, signaling, authentication, error detection etc In ARPANET, the network itself handled communication protocols using NCP (Network Control program). Highly incompatible with other networks. Now obsolete. 1983. NCP replaced by TCP/IP (Transfer Control Protocol/ Internet Protocol). Here the hosts are responsible for protocols.

  17. TCP/IP networking • Internet Protocol (IP) • Determines how a host is addressed on the Internet • Binds a software address to a hardware address • Transfer Control Protocol (TCP) • Determines how data is divided into packets and delivered • But these are not enough to allow the WWW to exist as it is today

  18. Hypertext/hypermedia A hypertext document is a text file with control instructions to cross reference with other documents, or perform some action - “branch or perform on request” (Nelson 1970). Hypermedia. Extends the concept of hypertext to include graphics, audio, and video. Key concept: hypertext/media entities are linked in a web like structure

  19. Hypermedia over networks • Early implementations (eg Apple’s Hypercard) worked fine on non-networked computers, but couldn’t be used to refer to documents distributed over a network. • TCP/IP says nothing about the structure of data sent from one computer to another • What is needed: • A standardized mechanism to determine how hypertext/media is encoded and transported • A standardized mechanism for identifyingresources on the Internet

  20. World Wide Web (1990s) • Tim Burners-Lee worked out how to use hypertext over networks. Two key inventions • HTTP: Hypertext Transfer Protocol • URL: Uniform Resource Locator • HTML (Hypertext Mark-up Language) was another important standard • The first web page is archived at: http://www.w3.org/History/19921103-hypertext/hypertext/WWW/News/9201.html

  21. W3C World Wide Web Consortium. Based at MIT, USA. Consortium that produces “recommendations” for the WWW Eg, there were some incompatible HTML versions from different vendors. W3C aims to get everyone to agree to common standards. Standards are crucial to effective internet programming.

  22. Uniform Resource Locator Standardized address name for resources (documents, images, …) on the WWW. a URL has two parts: [protocol scheme] :// [target] Eg: http://www.imdb.com ftp://astro.caltech.edu ftp://ftp.cs.cmu.edu/user/ai/areas/fuzzy/systems/anfis

  23. Hypertext Transfer Protocol An application layer protocol in the internet protocol suite. httpis a request/response protocol between clients and servers. Determines how client requests are structured Determines how hypertext is sent from server to client Clients: usually browsers Web servers: software program that (usually) works as a daemon listening to requests from clients and serving up the web documents.

  24. Hypertext Transfer Protocol • A “resource” could be: • An ASCII file (HTML, plain text,..) • An image file • Server-side application result (eg PHP output) • A database query result • A “service” offered by a server

  25. Identifying resources • Use a URL (Uniform Resource Locator) • Specifies the location of a resource, together with the means (http, ftp, …) of accessing it • A URL is actually a type of a more general URI(Uniform Resource Identifier) • Another type of URI is a URN (Uniform Resource Name) • Identifies a resource namespace without specifying where it is or how it is accessed • A URN is similar to a person's name, while a URL is like a street address Example: The URN for "The Last Unicorn", identified by its book number urn:isbn:0451450523

  26. Internet protocol suiteOSI (Open Systems Interconnection) model Application layer. Used by “network aware” programs to communicate with other programs Transport layer. Ensures data arrives at destination and provides reliability checks Network layer. Determines how nodes in a network are defined. Handles routing of datagrams from source to destination Data link layer. Specifies how packets are transported over the physical layer. Physical layer. The hardware that transports the data. Ethernet cards implement both Link and Physical Layers

  27. Layering: Physical Communication data application transport network link physical network link physical application transport network link physical data application transport network link physical application transport network link physical

  28. Examples Application layer. HTTP, SMTP, FTP, Telnet, ssh, … Transport layer. TCP Network layer. IP Data link layer. Ethernet, ISDN, WiFi Physical layer. Wire, radio, fibre optic

  29. Loading a web page What happens when I ask a browser to load something like ? http://www.massey.ac.nz/~nhreyes/index.html

  30. Client-server model Client Create a socket Connect socket to a server Send request as HTTP encoded string Receive http encoded response string • Server • Create socket • Bind socket to address • Listen for connections • Accept a connection • Receive string requesting a resource, eg • request a web page • Send resource using protocol in URL Important point Client/server transactions take place by exchanging request and response strings

  31. Loading a web page User Client (browser) Web Server Daemon URL Request string html source Displayed information Response string

  32. Sending the request • Client makes connection to server • If port not specified, default is port 80 • Request must specify a URL • Universal Resource Location • Structure of Request • Request method + e-mail like message

  33. Client request Location of resource Use this protocol Request command GET/~nhreyes/index.html HTTP/1.1 Host: www.massey.ac.nz:80 Resource is on this host (Internet address)

  34. The response SERVER-SIDE: Server waits for request string and then sends back a response string Response string format: a status line plus an e-mail like message. The message comprises headers plus the document body CLIENT-SIDE: The browser extracts the response body and displays it to the users

  35. Server response Status line Headers HTTP/1.1 200 OK Date: Mon, 23 May 2005 22:38:34 GMTServer: Apache/1.3.27 (Unix) (Red-Hat/Linux) Last-Modified: Wed, 08 Jan 2003 23:11:55 GMTEtag: "3f80f-1b6-3e1cb03b” Accept-Ranges: bytesContent-Length: 438 Connection: close Content-Type: text/html Content-Length: 32 --frontier This is the text body of the document --frontier Document body

  36. MIME types • Multipurpose InternetMail Extensions • Specifies the file format to follow • E.g. • text/html • image/jpg • application/pdf • Your server-side application must specify the correct MIME type it is delivering

  37. HTTP characteristics • Stateless Protocol • Each transaction is independent and no “state” information is retained • Clients and server don’t remember previous transactions • HTTP/1.1 adds a persistence of sorts by allowing multiple exchanges in one transaction

  38. Some Request Commands • OPTIONS • Request for communication options available for the Request-URI. • GET • Retrieve an entity requested in the Request-URI. • HEAD • Identical to GET but no message-body. • POST • Provide a block of data • PUT • Store the supplied Request-URI. • DELETE • Delete the resource identified by the Request-URI.

  39. GET/POST • Two very important HTTP constructs • These provide a mechanism for the client to send data to the server via HTTP • GETmethod • Data are encoded in the URL (URI) • POSTmethod • Data are encoded in the headers http://www.cs.tut.fi/~jkorpela/forms/methods.html

  40. Some status-line examples • 200 OK • 404 Not Found • 301 Moved Permanently • 302 Moved Temporarily • 303 See Other(HTTP 1.1 only) • 500 Server Error • 501 Not Implemented

  41. GET Request • Use to request a specific URI • Additional Parameters specified via URL • http://server/file?variable=val&variable2=val • Most servers have a limit on the size of a url that can be processed http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3

  42. POST Request POST /path/script.cgi HTTP/1.0 From:frog@jmarshall.com User-Agent:HTTPTool/1.0 Content-Type: application/x-www-form-urlencoded Content-Length:32 home=Cosby&favorite+flavor=flies http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html#sec9.3

  43. Summary • Computer networking - client/server model • Concept of hypertext/hypermedia • Problems implementing hyper-text/media over networks • The WWW - key inventions: HTTP, URL, (HTML) • Client-server model in Internet programming • HTTP characteristics

  44. Let’s see these web technologies in action.

  45. Network Core What’s in the network core? Server Web server My codes PHP MySQL HTML HTTP Client Operating System Web browser TCP/IP Internet

  46. Trace route from Massey to MIT Command: Tracert web.mit.edu

  47. Demonstrations Installing the Xitamiwebserver and configuring it’s port number and PHP connection. Configuring the webserver’s administrator’s password. Configuring the server’s port number. Deploying a CGI and an HTML in your own server. Requesting for the HTML from the server, using a web browser as a client. These demonstrations will show you how to set up the server and connect to it using a web browser as a client. You will also see the different network toolsyou can use to examine the network details.

  48. XitamiWebserver • free, fast and open source professional web server, written in ANSI C • Server supports HTTP/1.0, FTP, CGI/1.1, SSI protocols • Security: basic authentication per directory, FTP access rights per user and per directory • Deployment: installs ready-to-run, portable to Windows, OS/2, Unix, OpenVMS, fully portable web sites and web applications; • Performance: internal multithreading engine, fast even on slower systems • Configuration: editable config files, or through a web-based administration interface (WBA) Documentation: http://legacy.imatix.com/html/xitami/

  49. Webserver This is a snapshot of the webserver we are going to use, it’s called Xitami. Xgui32.exe To install Xitami, follow the instructions at xitami.docx and Xitami_cfg.docx (downloadable from our website)

  50. Interact with your webserver using PuTTY Using a simple tool called PuTTY, examine the HTTP protocol in action when a web client interacts with your webserver (Xitami, running in your own machine). PuTTY is a free implementation of Telnet and SSH for Windows and Unix platforms, along with an xterm terminal emulator. It is written and maintained primarily by Simon Tatham. What is the IP address of your machine? ipconfig /all Is your server running properly? What was the server’s response? Which port number is open? netstat -anop TCP http://surf11.com/entry/176/command-to-show-open-tcp-ports-windows

More Related