2.2 The Web and HTTP (part 1)

112.66k views2900 WordsCopy TextShare
JimKurose
Video presentation: Computer Networks and the Internet. 2.2 The Web and HTTP (part 1). Web, HTTP ov...
Video Transcript:
[Music] in this first section on http we're going to start off with just a very quick overview of the web and http then we're going to dive down into the two types of http connections persistent and non-persistent connections and look at the major messages used by http the request message and the response message and then finally we'll wrap up this first section by taking a look at what are known as cookies a ways for state to persist at a server between one client connection and another client connection now this is just the first of two parts that we're going to cover on http but we've got a lot to cover here so let's get started well let's begin our discussion of the web and http with just a very quick review to set the stage remember that a web page consists of a base html file as well as a set of referenced objects and each of these objects can be stored on different web servers an object can be an html file jpeg image a java apple audio file or many other things and the web page itself as well as the reference objects are each addressable by what's known as a url there's a host name associated with it and then on that host there's a path name piece to it well let's get started with our study of http and the very first thing to know is that http adopts the client server model that we just studied in section 2. 1 a client might be a web browser like firefox or safari or edge or it might actually be embedded in a device and you might not even see it a server might be a traditional web server that only serves web pages or a more general purpose server like gaia. cs.
umass. edu which provides a number of services in this animation here we see on the top pc running the firefox browser making an http request to a server and getting a response back at the bottom we see an iphone running safari browser also making an http request and getting an http response back both of those browsers are speaking the http protocol with the apache web server http uses the transport services provided by the tcp protocol and here's how an http transaction works the http client your web browser for example opens a tcp connection to a web server using port 80. we'll learn about port numbers in just a second one or more messages http messages are then exchanged between the client and the server and then the tcp connection is closed http is a stateless protocol this means that the server maintains no internal state about the ongoing request there's a single request for an object and a single reply that's it there's no worrying about something like well this transaction has five steps we're now in step three and if i fail i'm going to need to roll back my state to what it was before this five step transaction started none of that with http it's stateless and you might ask why well because of its simplicity as we'll see protocols that maintain state will need to deal with clean up problems when a multi-step transaction fails returning to the initial state and resolving inconsistent state there are two types of http connections what are called persistent connections and non-persistent connections and it's important to remember these http connections between a browser and a server are different than the tcp connection which is provided at the transport layer underneath in non-persistent http a tcp connection is opened at most one object is then sent over the tcp connection and the tcp connection is closed downloading multiple objects is going to require multiple tcp connections to be established and we'll see that it takes a round-trip time first to open the tcp connection and then another rtt to make the request and receive the response in persistent http a tcp connection is again open to the server but this time multiple objects can be transferred serially over the single tcp connection between the client and the server once those multiple objects have been requested and returned the tcp connection can be closed persistent http corresponds to http version 1.
1 which is probably the most common form of http in use today here's an example of non-persistent http and operation let's assume that the user in step 1a here enters a url www. sumschool. edu and asks for a web page that contains text as well as references to 10 jpeg image in that base html file so in step 1a we see the client initiating the tcp connection to the http server at port 80 at www.
sumschool. edu in step 1b the http server at the host which has been waiting for a tcp connection at port 80 accepts this tcp connection and notifies the client and notice in steps one a and one b no http requests have actually flowed yet this happens in step two in step two the http client sends the http request message into the tcp connection that's just been established this http message indicates that the client wants to receive this base html file in step 3 the servers now receive this http request message and forms the response message that contains the requested object and sends this message back to the http client after sending the response message in step 4 the http server closes the tcp connection in step 5 the http client receives the response message containing the html file displays the html file parses it finds the 10 reference jpeg objects and in step 6 now it's going to have to repeat the preceding five steps for each of the reference jpeg objects now we can take a look at the response time for non-persistent http we can define the response time as the amount of time from when a user first enters a url into a browser until that base html file is received and displayed so let's define the rtt the round trip time as the amount of time needed for a very small packet to travel from the client to the server and back and so we can see that the non-persistent http response time per object has the following components well one rtt is needed to initiate the tcp connection and another rtt a second rtt is needed for the http request to be transmitted and received and for the first bytes of the http response to be returned and then finally there's the amount of time needed for the server to actually transmit the file into its internet connection and so overall the non-persistent http response time is two rtt plus whatever amount of time is needed to transmit the file so we've seen that two rtts are needed to fetch a web object now multiple objects can often be retrieved in parallel but still two rtts is well two rtts and you know we really want to get our information as fast as possible so it's possible using a simple technique to actually cut this latency from two rtts to one rtt and that's to use a technique known as persistent connection and this is the way that most web servers are now operating in persistent http http 1. 1 the server leaves the connection open after sending the response subsequent http messages between the same client and server can then be sent over this open connection without having to wait that rtt to establish a new tcp connection when a client has a new request to send it sends it as soon as it encounters a referenced object and so we can see here how persistent http cuts the response time in half to one rdt now that we've looked at the two styles of http connections we can dive down into the details of the http messages themselves and remember way back in section 1.
1 we said that a protocol defines the format and the order of messages sent and received among network entities and the actions taken when these messages are sent and received let's take a look at the http protocol and let's take a look at its messages there are two types of http messages request messages and response messages let's take a look at a request message first a request message starts with a single request line with that line beginning with a method name for example get as shown here a url in this case the name of the html file being requested the version of http in this case 1. 1 and a new line that is a carriage return line feed the single request line is then followed by a number of header lines that provide additional information for example the name of the host where the request is being made the type of browser making a request in this case firefox the types of objects that can be accepted and preferred language in this case u. s english and the fact that this connection should be kept alive the request message ends with an empty line so as you can see very human readable here's the general format for an http request message we see the request line followed by header lines http protocol specification rfc 7320 is 85 pages long and has all the details about the methods header field names and values fortunately for us as networking students we don't need to know all of those details but if we were implementing an http client or server we'd have to know every detail when we looked at the get message in the previous slide there was no entity body that's needed by some request messages like post which we'll see in a second that need to send additional information not in the header fields to the server here are the four types of http request messages we've seen the get method already the post method is used to upload completed form data to the server and the put method can be used to upload a new object to the server with a given url possibly replacing an existing object and last the head method ask for a response that's identical to that of a get request but without the response body this could be used for example to determine the size of an object that would be retrieved but without actually retrieving that object now let's quickly take a look at the http response message the response message begins with a status line and the first thing on the status line is the version number of the http protocol being used in this example here 1.
1 following the version number are the two most important pieces of information in the response message a status code and a short message in this case the status code shown is 200 which means that everything went okay and a short status phrase in this case the word ok following the status line there are response header lines as in the case of the request message that provide additional information for example shown here you can see that the date and time the response was sent the type of server is also shown in this case an apache server version 2. 4.
Copyright © 2024. Made with ♥ in London by YTScribe.com