Overview of the HTTP Protocol and OSI model

Bavatharany Mahathevan
8 min readJan 13, 2022

--

What is the protocol?

The protocol is a set of predefined rules or procedures to make a successful communication between the devices such as client machine, server machine and other intermediate devices which are over the network.

There are multiple protocols are available, In this article, we are going to look at the HTTP protocol.

What is HTTP?

  • HTTP stands for HyperText Transport Procol to transfer the data on the world wide web and is an application-level protocol.
  • HTTP works as a request-response protocol between a client and server.
  • The communication usually takes place through TCP/IP sockets, but any reliable transport can also be used.
  • The standard (default) port for HTTP connection is 80, but other ports can also be used.
  • Whenever a user opens their Web Browser, that means the user indirectly uses HTTP.
  • When you enter an address in your browser, the address of the particular wen page will start http://, it tells that this communication will occur HTTP protocol internally.

Characterise of HTTP are :

  1. Connectionless : The client can disconnect the connection after sending a request to a server and wait until receiving the response from the server. The server will reconnect the appropriate client who sent the request and send the response to the client.
  2. Media independent : HTTP can transfer any type of data between any devices.
  3. Stateless : It does not store the client data during the communication. once a connection is disconnected, and they want to connect again, they need to provide the information again.

What is different between HTTP and HTTPS.

  • The HTTPS stands for HyperText Transport Protocol Secure. The basic difference is secure. To make it secure, the HTTPP protocol encrypts and decrypts the requests and the responses using the TLS and SSL.
  • So, The HTTPS protocol secures the communication on WWW from the man middle attack.
  • HTTPS use port 443 by default.

HTTP Request

An HTTP request is a set of messages which are sent to the server by the client. In order to communicate the client and server, There are several HTTP request methods are behind it such as GET, HEAD, POST, PUT, PATCH, and DELETE and there are responsible for handling the CRUD operations. Let's see one by one here.

  1. GET : get method for getting or reading information from a server using a given URL.
  2. HEAD : The head method is also for retrieving data from the server but only the header part of the GET request. Get method to retrieve with a body, head method retrieve the header.
  3. POST : The post for sending data to the server to store like file upload, customer information, using the HTML forms.
  4. PUT : The put method is used to replace all the current representations of the target resource with the uploaded content.
  5. PATCH : the patch method is also used to update the resources but, unlike the put method, the patch method updates the target resource only rather than updating all.
  6. DELETE : The delete method is used to remove all the current representations of the target resource, which is given by URI.

Q & A What is the difference between PUT and PATCH requests?

  • Both are related to updating resources based on the client request.
  • PUT is a method that updated the entire resources according to the sent data by a client.
  • When we need to update the name of the employee then we have to pass all fields including which do not need to update. Otherwise, it will replace the other fields with names.
  • PATCH is a method that updates resources according to the partial data sent by a client. In this case, we can pass the name field only in the request body.

HTTP Response.

HTTP requests will be sent by the server to the appropriate client who sent the request using the URL.

And, It will inform the user about the stage of what is the current status of a request-response process like successfully receiving your request, or going process or server error etc.

In order to send the staus, The HTTP protocol uses a three-digit code. let's see some of the example HTTP status codes.

All HTTP response status codes are separated into five classes or categories. The first digit of the status-code defines the class of response, while the last two digits do not have any classifying or categorization role. There are five classes defined by the standard

  • 1xx informational response — the request was received, continuing process
  • 2xx successful — the request was successfully received, understood, and accepted
  • 3xx redirection — further action needs to be taken in order to complete the request
  • 4xx client error — the request contains bad syntax or cannot be fulfilled
  • 5xx server error — the server failed to fulfil an apparently valid request

To know about each status code. please refer to this page.https://www.restapitutorial.com/httpstatuscodes.html.

image from google

What is the OSI model?

The OSI stands for Open System Interconnection, is just a model or a framework to explain the internal work of how computers communicate with each other over the networks.

The OSI model was developed in late 1970 by International Organization for Standardization to describe the various type of computer networking operations. But, It failed to describe more detailed concepts between the networking, then the TCP model became a solution. Even though, the OSI model is still used as a reference a lot when troubleshooting or describing network operations.

This OSI model is divided into 7 abstract layers of work. Each layer has its own functionalities.

https://www.guru99.com/layers-of-osi-model.html

The basic idea of these layers is a package of protocols. Let’s see each layer with a serial example. Let’s start with the top layer 7th layer.

7. Application Layer.

The Application Layer is responsible for making the interaction with the real end-user.

For example, If you want to go to Facebook, you need to open your favourite web browser and go to the Facebook page and then you will be shown with login page.

To web browsing, you use the HTTP or HTTPS protocol.

These all processes such as, working web browser and entering the URL of the Facebook page are working on the Application layer.

In order to user communicate with other software applications like mail service, file transfer, there are some protocols such as HTTP, HTTPS, SMTP, DNS, DHCP are used in this layer.

6. Presentation Layer

This layer is responsible for preparing data for presenting the user in a readable format.

This layer receives data from the application layer and the presentation layer is used by the application layer.

For example, when you log in to your Facebook account, you will enter the user username and password and press the login button. In this case, for security purposes, your credential will be sent to the server in an encryption format, then it will be decrypted at the server level.

In this case, the data changed to machine-readable code (0 / 1) and the date is compressed with only necessary data. It improves the speed and efficiency of communication.

after successful login and finding your page, you will be shown your Facebook page and the page is reformated to human-readable format as well.

The presentation layer is responsible for such inner work that encryption description and translates in a readable format like image, text, audio, HTML formats. Hence, the layer is called as Translation Layer. The SSL, TLS protocols are used in this layer.

5. Session Layer.

This is the layer responsible for opening and closing communication between the two devices. The time between the open and closed is named as session, This layer actually establishes maintain and terminate the session.

for example, After you go to your Facebook page, if you didn’t do any action on it, then it may terminate automatically, then you have to religion the page.

These processes are maintained in the session layer. So that,

The session layer ensures that the session stays open long enough to transfer all the data being exchanged, and then promptly closes the session in order to avoid wasting resources.

4. Transport Layer

The Transport layer is responsible to transfer the data to end communication.

For example, when you post an image on your Facebook account. Then your image will be displayed on your friend’s Facebook account.

At the same time, The notification of successfully uploaded should come to your Facebook, not any other pages which are dealing at the same time like listing songs on youtube.

The transport layer provides services to the application layer and takes services from the network layer.

In order to do that, the transport layer has the following responsibilities that divide your data as segments, deliver your data and then gives you an acknowledgement whether it is successfully delivered or not.

TCP and UDP protocols are used in this layer.

Each segment is encapsulated with the port number.

3. Network Layer

The Network Layer is responsible for transmitting the data from one host to another host in the same network or another network. But, If the bother sender and receiver are in the same network, then the network later is not important.

The network layer breaks up segments from the transport layer into smaller units, called packets, these packets are encapsulated with the sender IP address and receiver IP address.

for example, When you post an image on Facebook, the packet has your IP address and the Facebook server IP address.

It also finds the best physical path for the data to reach its destination, which is known as routing.

Ipv4, Ipv6 and all other network protocols are used in this layer.

2. Data Link Layer

The data link layer is responsible for transferring the error-free data from one node to another, over the physical layer. When a packet arrives in a network, it transmits it to the Host using its MAC address.

  1. Physical Layer

This layer is responsible for the physical connection for the two devices and includes the physical equipment involved in the data transfer, such as the cables and switches.

The data gets converted into a bitstream, 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, any type of communication between devices over the network, the data must be travelled through these layers of the OSI model.

The device of the sender will start from the Application layer to the physical layer to send the data.

The device of the receiver will start from the physical layer to the Application layer to see what I have received from the sender.

For more examples, details check my reference too.

Reference:

https://www.cloudflare.com/learning/ddos/glossary/open-systems-interconnection-model-osi/

--

--