Understanding HTTP Protocol & OSI Model

Nisal Pubudu
Geek Culture
Published in
7 min readMay 16, 2021
Photo by Leon Seibert on Unsplash

If you ever ask me about what’s happening at fundamental level when you browse a web page, my answer will be this; So, whenever you visit a page on the web, your browser makes an HTTP request to a server. Then that server responds with a resource such as images, videos, or HTML web page, which your browser going to displays for you. So, this is the simplest way to answer that question. However, we all know there are lot more happening on the underline. But in this article, we are going to learn about one of the main components of this process, HTTP protocol.

What is HTTP?

The HTTP acronym stands for HyperText Transfer Protocol. HTTP is a set of standards that allow users of the World Wide Web (WWW) to exchange information, that found on web pages. When accessing any web page entering “http://” in front of the address tells the web browser to communicate over HTTP. For example, the URL for Google is https://www.google.com. But if you notice, today’s browsers no longer require HTTP in front of the URL since it is the default method of communication. However, it is kept in browsers because of the need to separate protocols such as File Transfer Protocol (FTP).

Other notable protocols are:

File Transfer Protocol (FTP): is a standard protocol used for transferring files between a client and a server over a network.

Simple Mail Transfer Protocol (SMTP): is a standard for email transmission.

HTTP is defined as a stateless, “client-server” protocol or “request-response” protocol. Stateless means that all requests are separate from each other. So, every request from your browser must contain enough information on its own for the server to fulfill the request. That means each request is executed without any knowledge of the requests that were executed before it or after it.

The client-server protocol describes the communication between two computers. The client (browser or another application) requests data and the server provide a response. So, this is how we can go to a website and see information on that website. With HTTP protocol, the client request always happens first and is followed by the server’s response.

Image: How HTTP Works (https://whatis.techtarget.com/)

HTTP vs. HTTPS

The S in HTTPS is stands for “secure.” HTTPS uses TLS or SSL to encrypt HTTP requests and responses. So basically, the only difference between the two protocols is that HTTPS uses TLS (SSL) to encrypt normal HTTP requests and responses. As a result, HTTPS is far more secure than HTTP. Because of that HTTPS can protects against eavesdropping and man-in-the-middle (MitM) attacks. A website that uses HTTP has “http://” in its URL, while a website that uses HTTPS has “https://”

HTTP Requests

When you want to access a web site using web browser, you simply type the URL and press the enter. So, this is when a client device (web browser), asks the server for the information needed to load the website. The request provides the server with the desired information it needs to adjust its response to the client device. There are several HTTP request methods known as Get, Post, Delete, Put, and Head. However, in this case it used the Get request, because it is how we get the content of that web site.

  • GET: The GET method is used to retrieve information from the given server using a given URI. Requests using GET should only retrieve data and should have no other effect on the data.
  • HEAD: Same as GET, but transfers the status line and header section only.
  • POST: A POST request is used to send data to the server, for example, customer information, file upload, etc. using HTML forms.
  • PUT: Replaces all current representations of the target resource with the uploaded content.
  • DELETE: Removes all current representations of the target resource given by a URI.
  • CONNECT: Establishes a tunnel to the server identified by a given URI.
  • OPTIONS: Describes the communication options for the target resource.

HTTP Responses

The HTTP response message is the data that sent by the web server to a client device, based on the HTTP request made by the client device. Well, every time there is a request, HTTP will always response it. The information contained in a HTTP response is modified to the context the server received from the request.

So, whenever server response to HTTP requests, usually it issues response codes, indicating the request is being processed, there was an error in the request or that the request is being redirected.

Image: HTTP Status Code (https://softcrony.com/)

OSI Model

So, what is this OSI Model or the Open Systems Interconnection model. This model is used to describes seven layers that computer systems use to communicate over a network. It was the first standard model for network communications, adopted by all major computer and telecommunication companies in the early days. But the thing is modern Internet is not based on OSI, but on the simpler TCP/IP model.

However, the OSI 7-layer model is still widely used, because it’s very useful in various use cases such as, it helps visualize and communicate how networks operate, and helps isolate and troubleshoot networking problems.

Image: 7 layers of OSI Model (https://www.cloudflare.com/)

Now I am going to explain each layer of OSI Model from top to bottom.

Application Layer

This is the only layer that directly interacts with data from the user. Software applications like web browsers and email clients depend on the application layer to initiate communications. To make things clear, that client software applications are not part of the application layer. However, the application layer is responsible for the protocols and data manipulation that the software relies on to present information to the user. Application layer protocols include HTTP, File Transfer Protocol (FTP), Post Office Protocol (POP), and Simple Mail Transfer Protocol (SMTP).

Presentation Layer

This layer is mainly responsible for preparing data so that it can be used by the application layer. So, it defines how two devices should encode, encrypt, and compress data, so it received correctly on the other end. The presentation layer takes any data transmitted by the application layer and prepares it for transmission over the session layer.

In case if there are devices that communicating over an encrypted connection, presentation layer is responsible for adding the encryption on the sender’s end as well as decoding the encryption on the receiver’s end as well. So, it can present the application layer with unencrypted, readable data.

Session Layer

This layer is responsible for creating communication channels, called sessions, between devices. Also, the Session Layer is responsible for opening sessions, ensuring they remain open and functional while data is being transferred, and closing them when communication ends.

Additionally, it can set checkpoints during a data transfer, if the session is interrupted, devices can resume data transfer from the last checkpoint.

Transport Layer

This layer is responsible for end-to-end communication between the two devices. It takes data transferred in the session layer and breaks it into “segments” on the transmitting end. Transport Layer responsible for reassembling the segments on the receiving end, turning it back into data that can be used by the session layer. The transport layer is also responsible for flow control and error control as well.

Network Layer

This layer is responsible for facilitating data transfer between two different networks. If there are 2 devices that communicate on the same network, then the network layer is unnecessary. The network layer breaks up segments from the transport layer into smaller units, called “packets.” So, on the sender’s device, these packets reassembled on the receiving device. The network layer also finds the best physical path for the data to reach its destination; this is known as routing.

Data Link Layer

This layer is very similar to the network layer, except the data link layer facilitates data transfer between two devices on the same network. The data link layer takes packets from the network layer and breaks them into smaller pieces called as “frames.” The data link layer is also responsible for flow control and error control in intra-network communication.

Physical Layer

This layer is responsible for the physical cable or wireless connection between network nodes. This is also the layer where the data gets converted into a bit stream, which is a string of 1s and 0s. The physical layer of both devices must also agree on a signal convention so that the 1s can be distinguished from the 0s on both devices.

So, this is the end of the article and I hope you enjoyed it. Happy Coding👨‍💻.

References

Adebesin, B., 2021. Introduction to HTTP. [online] DEV Community. Available at: <https://dev.to/mobolanleadebesin/introduction-to-http-4lc0> [Accessed 15 May 2021].

Aviani, G., 2019. An introduction to HTTP: everything you need to know. [online] freeCodeCamp.org. Available at: <https://www.freecodecamp.org/news/http-and-everything-you-need-to-know-about-it/> [Accessed 16 May 2021].

Learning Center. n.d. What is OSI Model | 7 Layers Explained | Imperva. [online] Available at: <https://www.imperva.com/learn/application-security/osi-model/> [Accessed 16 May 2021].

--

--