Alison's New App is now available on iOS and Android! Download Now

Module 1: Application Layer

    Study Reminders
    Support

    Application Layer: Hypertext Transfer Protocol
    Hello. So, we will continue our discussion on Computer Networks and InternetProtocols. So, we are discussing primarily on Application Layer Protocols and whichtoday we will be primarily focusing on HTTP, HTML and TELNET. Though HTML isnot a protocol it is a language but it comes hence in an with HTTP. So, I thought that itwill be good to talk about little brief about HTML. Most of you may be already familiarwith HTML but to for the sake of completeness, we will have a quick discussion onHTML protocol, right.So, what we have seen in previous lectures? So, it is primarily a client server modelwhere the server is active on some system on a particular port of the system, right; like aserver program is active on a particular port and the client from other system or from thesame system request the server for that service, right. So, primarily, in any client thistype of client server paradigm, we require this five element or five tuple to be there, oneis that server IP, server port, client IP, client port and this protocol number or protocol ID,right.So, this five will be there. Any of them is different will give a unique type ofconnectivity. That’s why, even if you open up number of pages by the same browser,from the same server, it is it is not the it never happens that one page, you request a pagefor one, like see one particular link, you click in one browser and the it comes up in theother browser, right. So, it is the, is the this five tuple decides that how the wholeuniqueness of the connectivity. One thing to be remembered that this can be anywhere inthe things, the overall networking paradigm takes care of the thing, right.So, some of the, some of the communication is connection-oriented, so or some sort of aTCP type of protocols are there and some of the things are connectionless or UDP type ofprotocols are there. The beauty of this layer or the layering technique is that every layerbasically concerned with the functionality of its peer at that layer only, right. So, rest ofthe things that taken care by the underlying layers to be there like, if I have n layer inwhich it do not support reliable service, but the so, I need to have a other mechanism totake care at the upper layer etcetera to have a reliability, etcetera. So, any way that is alayer to layer phenomenon, the peers talk at the layer at the that phenomenon only, right.So, if we look at our HTTP type of protocol, then what we see it is a Hypertext TransferProtocol allows primarily allows web document to be communicated over the network.And in doing so, what we get realized in a in a sense, it is the basic foundation to for therealization of this dub dub dub www world wide web. So, the whole World Wide Web isone of the predominant things which is, which makes it happening is this HTTP protocol.So, HTTP protocol that supports communication between the web browser and the webserver, so here we say HTTP server and the HTTP browser, right or in other sense, HTTPbrowser are clients right like our Internet Explorer or Mozilla or Chrome or anything,any browser which are a primarily HTTP client and the HTTP server as the other end ofthe thing. It can be in the same machine, can be in the same network, can be in a differentnetwork, different machine and anything right. The only thing is that it should have somesort of connectivity between the thing.So, a web browser is a typically known as a is referred as a HTTP server or rather HTTPserver is referred to as web browser whereas HTTP client is synonymous, moresynonymous with the sorry, web server is a HTTP server and the web browser is theHTTP client. And we predominantly we are having two version; one is the HTTP 1.0 thatis RFC 1945 specified.(Refer Slide Time: 04:59)So, if you if those who are interested, can open up the RFC and see that how thisdefinition is there and RFC 2616 which is the HTTP 1.1, right rather HTTP version 1.1specifies a persistent connectivity by default otherwise, the connectivity are notpersistent.(Refer Slide Time: 05:18)So, HTTP is a application-level protocol with the lightness and speed necessary fordistributed hyper media information system. Now, one thing we need to keep in mindthat in that when we are when we are exchanging information or data over across theacross the network, it need to be light weight so that I can have, first of all thecharacteristics is distributed, I heterogeneous systems are storing the data and there is aconstrained on the bandwidth or the at the backbone bandwidth.So, in order to address that, what it requires the lightness and for the speed necessary fordistribution hypertext information, why this hypermedia type of information? See Ishould have in some generic way of representation so that it can inter operate easily,right. I do not have any control like you do not have any control that how HTML, howthe data is stored in IIT Kharagpur website or a web server, right. Similarly, in yourorganization web server, we do not have any control or the other people.So, but to when I am keeping in something web server at IIT KGP, that the basic idea isto distribute the data, right. It is not for only for my consumption, but the rest of theworld what I want to show need to see it. In order to achieve these, there should be asome sort of formatting where easily which is easily parsable which we can interrupt,interpret or parse in a much easier way. So, this HTTP gives a basis for that, its aprotocol which supports that. So and it is transport independence, transport independencemeans underlying transport layer independence.Though it is generally take place over TCP connection, HTTP comes by default with theTCP connection. However, protocol itself do not depend in on the specific transport layerwhen the protocol itself is not specify that this transport layer is this transport layer ismandatory etcetera, but the predominant protocol, predominant underlying protocol orby default what we consider that the there is a connection-oriented or TCP type ofconnection is there at the transport layer, right. So, that HTTP tries to the - HTTP takescare is basically work over this any transport layer but primarily TCP is the predominantprotocol.(Refer Slide Time: 08:02)So, its as a simple structure. It says a client sends a request, server returns a reply right.So, it is a very vanilla type of tracker request response thing, HTTP can support multiplerequest reply exchanges over a single TCP connection right. Like if I have a underlyingone transport layer connection, HTTP can support multiple request respond exchangesover a particular connection.The well known port for the HTTP is port 80, right. So, the by default if you do notspecify anything, the port is port 80 right, but other ports can be used. So, if you againcome back to the thing, like whenever you say, when we type key in into the browser say“www iit kgp dot ac dot in” or say “www nptel” or say “nptel dot iitm dot ac dot in” orsomething, “nptel dot iit kgp ac dot in”, so what the this browser or the client does? It atthe underlying, it has to because it is a name cannot be communicated. So the first of allthe name is converted to the as a IP address, right and by default as you don’t specifyanything, by default it will take port 80 as the port right, otherwise, you need to specifythe port like you have to specify xyz dot com colon say port 7126; that means, you arespecifying that it hit to that port. By default, as the as the HTTP server this is to port 80.So, it is the default port, other ports can also be very well used.So, overall architecture as it is a basis for www. So its a distributed if you look at theWorld Wide Web, it is a distributed client server service, in which HTTP client browsercan access a service by from a HTTP server, right. So, it is a HTTP client server service.So, there are client so, who are the parties?(Refer Slide Time: 10:09)Client, Server, there is a URL or Uniform Resource Locator and there are Cookies, right.Cookies as you there is primarily to remember your previous data or it helps in amaintaining your session but primarily, what you say we require a URL for connectivity,a client or a browser for request and server for responding.(Refer Slide Time: 10:32)So, if you look at the thing, so that the client is sending request for a particular site,getting a web page back, it may have link for other web page to connectivity, it gets thisback. So, it this way it goes on referring to the web pages, right. So, this is typically andit can be any type of number of connectivity, etcetera.(Refer Slide Time: 11:00)So, if we look at little bit on the browser point of view, so what at the browser end, whatit is having? It is having a controller which is which can have different type of protocolto support right like HTTP, FTP, TELNET, SMTP and type of things and if it is thecontroller hits, if it is a normal HTML page or static page type of things, it goes and getthe things, there can be JavaScript where you where you which you which is adynamicity brings into the things or there are other Java programs the Java is one of thething. So, that what we say that you can, you can have program level or some sort of aAPI level things, right.So, this one is that you request for a page you get the page, one you run the thing at theserver site, you run something and the client site the reflection is there right, like say Isend a roll number, get the rank. I send a particular bank account number, get some statusreport of the things. So, that can be one way of looking at that, there can be other thingslike some sort of a things which can be need to be checked at the client end, like I enter aroll number: typically, say roll number is a only numeric character, numeric you need toenter the numeric but instead if you enter a character set or say puts a character, it saysthat it is a invalid thing.So, there is that that I can do at the client end, no need of bringing this whole thing to theserver, check it and flash it back. So, that I can have a client side scripting or server sidescripting, those things are supported by the HTTP protocol.(Refer Slide Time: 12:42)And URL as we all know, it is a protocol like if it is a HTTP colon name or IP againcolon port slash the path where you want to access; like if that is not by default if it is aport 80, then the port is not required, right. So, it can be HTTP, it can be FTP right;anything any protocol which support this type of thing. So it is a Unified ResourceLocator or uniform resource locator and we this is the overall structure, this is alreadyknown to us. If your HTTP protocol HTTP server is running in some other port, you givethe port number.(Refer Slide Time: 13:23)So, typically web document can be grouped into three broad categories right, one isstatic, you request and get the page; one is dynamic, you request get something executedand get the page; one is active which is on the on your side of the browser, where yousay some checking, authentication, some processing at the browser end. Like static page,you request and get the static page there.(Refer Slide Time: 13:47)(Refer Slide Time: 13:55)In case of like one common, in case of dynamic, we have a concept of CommonGateway Interface or CGI. So, through that I can have a request and based on that, theHTML page dynamic HTML page is written right. In the static page, say I request for afor something and I get the list of I get a static page of the list of students roll numberverses the name released. In the in case of a dynamic page, I send a request with astudent roll number say and get a data related to the student roll number back to me as aHTML document right. If the student roll number changes, this document also changesright. So, that is a dynamicity is there. In other sense, there should be some programrunning at the other end, right. Based on your request, it execute and generate adynamically a page and returns back. So, that is the dynamicity on the things. One of the,one of the very popular technique is using the Common Gateway Interface or CGI orCGI programming some of you might have done.(Refer Slide Time: 15:05)So, dynamic document also sometimes that we refer as a server side scripting right; soruns a script inside the HTML document which execute the thing and generate thegenerate the dynamic HTML thing. So, that is at the server end, so server side script.
    Application Layer: Hypertext Transfer Protocol - Part 2
    Similarly, there can be active document which are at the client side or what we say it is aclient side script right. So, I can run a Java applet at the client side and it gets executed, Irequest for the thing, it returns a applet and the applet goes on being executed at theclient side, right. So, this sort of things it is a also active document, not a static one basedon your request the applet comes is returned back and it goes on executing.(Refer Slide Time: 16:07)So, this is also, it is also a active page or dynamicity here or I can have a instead aJavaScript which will be executed here right. It can be used for some basic levelauthentication say whether it is a valid character set or some sort of a those type of thingswhich can be done at the scripting at the client end without transferring the thing. So wehave this server side scripts which, sorry client side scripts and when you do that whenyou say that active documents, right.So, whenever we are running on something on the server client side is active document,it is referred as active document. When you are running something at the server side andthe dynamic HTML comes back its a dynamic and if it is nothing is there, you request fora page, get the output and get the page displayed on the screen and its a static page thenwe have a static document.(Refer Slide Time: 17:05)So, coming back to the thing, so what we have HTTP is a request response thing. So,again, let me little bit repeat it. So, server is running a HTTP server, typically we referthis as HTTPD, HTTP daemon right. It is running at the server. Client is the sending aHTTP client request right. In our cases, it is mostly the browser.So browser construct the data and send it to the thing and the server response back to thething. So the transaction is pretty simple. Every request get a response to the thing.Typically, this is typically HTTP request response are stateless, that it will not rememberwhat happened in the earlier state, right. In order to do that, we need to do some otherthings to handle that. Anyway, though what at the present we send a request, get a returnback.(Refer Slide Time: 18:09)So, HTTP Request Response Messages, so what we have? This is again very a standardformat. We have a Request line, a set of Headers, a blank line and the body of the thing.It may be possible that the body may not be always present in the in the message. In thein case of a response message, again it has a status line that based on the request, what isthe status line, a set of header lines, blank line and the body of the message right. Againthere can be, there may be possibilities that there may not be message on the thing. So,this is the basic block of the things but it what are the different type of request, responsesor what are the different type of comments, status reports etcetera, that we will seeslowly.(Refer Slide Time: 19:05)So, if you say the request and status line, so what we have? The request type, the URLwhere the request is there and the HTTP version where which is being used. Similarly,for the status thing, we have that HTTP version, status code and the status phrase of thething. So, particular status code like say 200 is OK, for successful type of status code andthen like that. So it comes to the thing like if you had 404 or 4xx error, those areprimarily error status.(Refer Slide Time: 19:48)So, there are different HTTP methods. One is say GET method, which request adocument from the server, there is a HEAD method, requests information about adocument but not the document itself right. POST method, sends some information fromthe client to the server, PUT sends a document from the server to the client, TRACEechoes incoming request, CONNECT is reserved method and OPTION that inquiresabout the available options.So, there are different set of methods right, we are discussing some. So, primarily morepopular are Get, Head, Post, Put, these are the most popular widely used, not popular Ishould say others are also there etcetera.(Refer Slide Time: 20:41)Similarly, if you look at the status code, 100 is a code of continue type of things that theinitial part of the request has been received, the client may continue with the request, thisis the status code. 101 is the switching, the server is complying with a client request toswitch protocols defined in the upgrade header, there are status code of 2xx series that is200, that is OK, the request is successful; 201 that is created; 202 accepted, the request isaccepted but it is immediately not immediately acted on and 204 no content, that means,there is no content in the body, right.(Refer Slide Time: 21:29)So, there is that say that there is no content in the body.And there are more status report that is 3xx series; primarily moved, permanently ormoved temporarily or not modified this type of things, 4xx series are primarily, so 3xxseries are redirection. So, here what we have seen, 1xx series is informal, informational,it gives information, it is more for informational purpose; 2xx is mostly reportingsuccess; 3xx is redirection, so it is any redirection of the page or change or somewhere;4xx is the client error or the whatever the client sides error that bad request, unauthorizedrequest, forbidden, not found, methods not allow allowed, not acceptable and these areset of requests which are at the client error whereas, server errors are 5xx series thatinternal server error, not implemented, service unavailable. So, these are all server sideerror. So there are client side errors, server side error.So everything has a status code and if you minutely check that whenever it keeps youwhether accept the, you mostly see this sort of error by that you can decipher that; one is404 is the most what we say mostly most seen error type of thing that the document notfound type sort of error.(Refer Slide Time: 22:59)So, if we look at the HTTP header, header name colon a space and the header value. So,header are different type of header like one is Cache control specify informationalinformation about the cache caching; Connection shows whether the connections wouldbe closed or not; Date, current date; MIME upgrade and so and so.(Refer Slide Time: 23:23)And there are this, this are mostly request type of header like these are set of request typeof request header. So, what we have seen request header and the response or statusheader. So, these are the set of the request header: Accept, Accept-charset, Acceptencodingand so and so forth. So, these are more in detail if you want to look at, thosewho are interested look need to be looked into the any standard book or RFC maybe agood place a look at.(Refer Slide Time: 23:55)So, there are response header like Accept-range, Age shows the age of the document,Public shows the supported list of methods, Retry after specify the date after which theserver is available, Server shows the server name and version number and like that. Sothese are different response headers.(Refer Slide Time: 24:15)So, HTTP Entity headers, so allow say allow the list of valid methods, content encoding,so these are more related to the entity right. So, that is content length, content range,content type, when it expires, last modified date, location specifies the location of thecreated or modified document. So these are the different entity headers.(Refer Slide Time: 24:46)So what we see, it is a rich collection or rich set of commands or control is there. So itthat is why it is able to handle a variety of say media or the variety of data or the varietyof information across the across the www. And we need to also keep in mind that thereare data are stored in a heterogeneous version in across the network and every data hastheir own payload or data load which takes time to the thing. HTTP has it is own saytiming issues like how long, suppose I request a particular page, how long I should waitthe page will come right. So, that is a that there is a timeout thing also is there. Sokeeping in mind so, in the overall management of this type of distributed and looselycoupled system, you need to have lot of flags and what we say so called headers andother informations to handle that.The example here, a example again from that book that example retrieves a document,we get a get method to retrieve an image with a path slash usr slash bin slash image 1.The request line shows the method get and thing.(Refer Slide Time: 26:20)So, if we come to the example, so this is the request to get method HTTP version 1accept it is looking for a image and accept this image type of things. If you look at theheader thing, so accept, so the medium format the client can accept, right. So, that itshows that what are the format it can accept right, it is a image of gif type or image ofjpeg type and the at the other end, it gives a status of 200 that if you remember that thesuccess header, then the date server is what sort of server, what sort of MIME version isthere how much content length is there and the body of the document right. So, this is theway request comes. So, if you if you expand the HTTP, it will be looking like that.(Refer Slide Time: 27:06)Similarly, in another example, so this is a request and this example it is a post, rightwhere in this example, a client want to send a data to the server. Use post method, therequest line shows the POST, URL and HTTP version 1. There are four lines of theheader. The request body contains the information and so and so, what we see? So, it is aposting something against the image type, some data and the code either g for jpeg and itis content is some content length is there; on the other side, the server replies with 200OK and it is the type of things it is able to handle it is showing, right.So, it is a response message contains the status line and the four lines of the header, thecreated document which is a CGI document that is if you remember a Common GateWay Interface document and is included as the in the body of the thing, right. So, itcomes as a request message as is as encoded as a CGI document for the body of themessage.(Refer Slide Time: 28:12)Now, just to look at that connecting HTTP server using I can have a TELNET also, right.TELNET will see subsequently, it is primarily used to connect to some other remotelogin type of situation but I can have TELNET, the name of the things it is that I canhave TELNET www mhhe dot com dot 80, right. So it will hit and try to retrieve,provided that if it is not blocked that the particular TELNET function etcetera but it thatwill retrieve back. So, what we mean to say that underlying, I can use some otherprotocol at that particular port and if the HTTP server or the server which is listening atthe port is responding to the request, it will respond right. In this case, it gets a I a afterdoing that I give a get message of a something, this is actually from that datacommunication of the Forouzan book.So, that is the examples on there. And the server in also it responded, we 200 and so andso forth, right. So, what we see here that it is it is the server which is listening at port 80in this case. It could have been in other port also, accept that message and respond itback to the thing and its a, I am sending an HTTP sort of request through a other protocolthat is a TELNET protocol, right. So, this is feasible right.So, what we see a HTTP is a hyper text transfer protocol where a server side that at theserver is listening to a particular port and the client or client or the clients knows thatwhich where is the IP and the port of the things. Whenever it wants to connect to thething, connect to that particular port and get the result, and based on the things that canbe different type of status right, it can be it mostly it is successful, otherwise if the erroris there, so there should be a error flagging and so and so forth.And get displayed on the things; another part if you see, it is a it is, it can handledifferent type of media. It can handle text, it can handle your different version on thething, it can handle image, it can handle video, it can handle voice. So, it is a some sortof a, it can handle any hyper media type of thing but as the as the communication or theformatting is in a particular generic format, so it is able to that at the client or the browserable to accept it.So, that that’s the beauty of this HTTP which can access across the across the over theinternet. So with this, let us conclude here and we’ll be discussing little bit on HTML andother TELNET in the subsequent lecture.Thank you.