OSI Model and overview of HTTP

Ramsunthar Sivasankar
Nerd For Tech
Published in
10 min readMay 27, 2021

--

(source: https://www.youtube.com/watch?v=lmFFc8ih244)

What is HTTP?

The World Wide Web’s foundation is the Hypertext Transfer Protocol (HTTP), which is used to load web pages(such as HTML documents) via hypertext links. HTTP is an application layer protocol that operates on top of other layers of the network protocol stack to convey data between networked devices. A typical HTTP flow comprises a client sending a request to a server, which then responds with a message.

This was designed in the early 90s. With the help of this protocol, data are exchanged between the client devices and the server through the internet. So basically, the client devices send requests to the server for the data that needed to load a webpage. So the server will send the responses to the client.

A web server contains an HTTP daemon (a program that listens for HTTP requests and responses and handles them as they come in). When a user tries to visit a webpage(typing the URL), at that time the browser builds an HTTP request and sends it to the IP address pointed by the URL. The request is received by the HTTP daemon on the destination server, which then sends back the requested file or files.

If you notice properly, you will see HTTPS in the URL and what does that mean?. It uses SSL as a sub-layer on HTTP. HTTPS encrypts and decrypts both user HTTP page requests and the web server’s response pages.

HTTP is a client-server protocol and all the requests are sent by one entity(mostly Web browser). Between the client and the server communication, there are a lot of entities and we commonly call them Proxy. The proxy performs different tasks and also it acts as a gateway or cache. For more information Click here.

So now, we know the basic idea of HTTP. Lets look at the history of HTTP,

(source: https://dzone.com/articles/http2-server-push)

HTTP/0.9

This is the first version of the HTTP protocol, at the beginning, this version had no version number and later it was named to distinguish it from the later versions. This version is very simple because the request only comes in one single line. That is why this version is also known as “The one-line protocol”. Let’s see an example,

GET /hello.html

This is how a request will look like in HTTP/0.9. In a single line with the only method GET followed by the path. The response looks like the following,

<HTML>
Hello World!
</HTML>

It only has the file nothing else. (no headers or any other type of documents). And the funny part is there is no status or error codes in this version. If there are any error, a particular HTML file will be sent back with a brief of the error.

HTTP/1.0

In this version, versioning information will be sent with the request itself(HTTP/1.0 added to the GET method line). Status codes are also sent with the response. Here, the client will open a tunnel to the server and send the request in plain text. A single connection will be established for each request.

The sample request will look like follows,

GET /TheProject.html HTTP/1.0

The following segment shows how a HTTP/1.0 response will look like. (credits: https://condor.depaul.edu/dmumaugh/readings/handouts/SE435/HTTP/node16.html)

HTTP/1.0 200 OK 
Date: Fri, 08 Aug 2003 08:12:31 GMT
Server: Apache/1.3.27 (Unix)
MIME-version: 1.0
Last-Modified: Fri, 01 Aug 2003 12:45:26 GMT
Content-Type: text/html
Content-Length: 2345
** a blank line *
<HTML> ...

HTTP/1.1

In this version, it is just upgrade to HTTP/1.0 and this is where persistent connection in HTTP was introduced. Because of that, it saved time. Instead of opening and closing the connection for each request, this will allow multiple requests. This increased the performance optimizations such as keep-alive connections, byte-range requests, additional caching mechanisms, encoding transfers, request pipelining, and transfer encodings.

I talked about the HTTP versions 1.0 and 1.1 and the difference in the ‘SOAP and REST” article. Click here to read that.

HTTP/2.0 and Above

This begins as a SPDY protocol. Between the server and the client, HTTP/2 uses a single TCP channel. When content is downloaded from multiple servers, the client will eventually open separate TCP channels for each server, but HTTP/2 only uses one TCP channel for content pieces that come from the same server. Using multiple TCP channels between a single client and a single server does not speed up a communication; it was only used in HTTP/1.1 as a workaround to partially alleviate the choking effect of slow resources.

The binary framing layer, which may be regarded as a part of the application layer in the internet protocol stack, is one of the most significant aspects that divide HTTP/1.1 from HTTP/2 from a technical standpoint. Unlike HTTP/1.1, which leaves all requests and replies in plain text, HTTP/2 employs the binary framing layer to wrap all communications in the binary format while still preserving HTTP semantics like verbs, methods, and headers. An application-level API would continue to produce messages in standard HTTP forms, but the underlying layer would transform them to binary. This guarantees that web apps built before HTTP/2 may communicate with the new protocol in the same way they did previously.

And then there is HTTP/3.0 (which is now in development) or you can call “HTTP over QUIC” as it was known back then. To read more about HTTP/3.0, Click here

OSI Model

When you take the network, it a gigantic topic to discuss. The OSI Model helps us better understand it. OSI stands for Open Systems Interconnection. This explains how a network functions when systems are communicating with each other. This model is categorized into 7 layers. So through each layer, we will be able to understand how data is traveling from one system to another through the internet. Let’s discuss one by one,

(Source: https://www.stemjar.com/osi-model-seven-layers-explained/)

In the sending process, it is from the Application layer to the Physical layer and in the receiving process, it’s from the physical layer to the application layer. Lets look in detail,

Layer 7 : Application Layer

Actually, this is the 7th layer and Once a connection has been established, this layer allows programs to interact over the network because this layer directly interacts with a software application. (closest to the user). This layer interacts with the application communicating with the network when the user wishes to send files or pictures.

There are several protocols which used in this player and they are HTTP, Telnet, POP3 or SMTP (for email purpose), FTP, IMAP, etc.

So the particular application allows this layer to send data and receive data from the Presentation layer.

Layer 6 : Presentation Layer

This layer is responsible for converting data according to the end system’s syntax or semantics. This layer is also called Syntax Layer because this layer manages the encryption and decryption. Let’s say that you are ordering food in UberEats, these transactions are often handled in a secure transmission, which means that data flowing between you and the “UberEats” is encrypted and must be decrypted and processed by this layer.

Finally, before transferring data to the Session layer, the presentation layer compresses the data received from the application layer. By reducing the quantity of data exchanged, helps to enhance communication speed and efficiency.

Layer 5 : Session Layer

The session layer will establish communication channels between devices, which will be referred to as sessions. This layer is in charge of starting such sessions and making sure they work during data transfer. This layer is responsible for establishing, managing, terminating, and communicating sessions. This layer manages different types of connections as well as authentication and re-connection in the event of a network interruption. The session layer allows two systems to begin communicating in half-duplex or full-duplex. This layer allows to add checkpoints when transferring the data in an order, If a data transmission error occurs amid the process, the transmission will be restarted from the checkpoint. Synchronization and recovery is the term for this procedure.

The data will be passed to the transport layer once the session is established successfully.

Layer 4 : Transport Layer

This layer is mainly responsible for data transmission across the network connection, error checking, flow control, and sequencing data packets. This layer determines how much data to send, how fast it should be sent, and where it should be sent, among other factors. TCP and UDP are the protocols used in this layer.

TCP (Transmission Control Protocol)

(source: https://www.freecodecamp.org/news/an-introduction-to-http-understanding-the-open-systems-interconnection-model-9dd06233d30e/)

TCP offers connection-oriented communication by making a handshake protocol between end-users to make sure the connection is properly established before the data(as packets in this layer) exchange. In this layer, it uses a checksum(In the TCP header) to make sure the packets send by a user and received by a user are the same. Usually, all the packets will be numbered because TCP will make sure the received packets are in order or not before it passes it to the upper layers(if not, it reorders). Flow Control is one of the features in TCP and it will prevent buffer overruns. In the connection-oriented protocol, this is the most common one and the way of establishing and maintaining the connection will be defined in this protocol. So this will make a connection (socket) between the client and the host in a three way handshake as shown in the above diagram.

UDP (User Datagram Protocol)

This is a totally connection-less protocol and opposite to TCP because this sends the data in an unordered manner which makes it unreliable. Whenever the packets are dropped it won’t resend the packets which causing gaps in the data. The main difference between TCP and UDP is the acknowledgment won’t be sent back to the receiver. This also a reason for UDP became unreliable.

Layer 3 : Network Layer

This layer will handle the routing of the data and it sends the data packets to the designated place through the most logical path because this layer knows all the path which takes the lowest time and the number of routes exists in the network. Then there is another function of this layer which is Logical Addressing and let’s discuss that.

IP Header (Source: http://www.highteck.net/EN/Network/OSI_Network_Layer.html)

This diagram shows the IP header which is attached to the data in this layer. In the header, you can see there are Source address and Destination address which will have the IP address of the sender and the receiver respectively. So through this packet will be sent to the specific destination based on the destination address.

Layer 2 : Data Link Layer

This layer is considered the most complex layer of all 7 and this layer corrects the errors(if any occurred in the physical layer). This will ensure error-free data transmission between nodes through the physical layer. Here the data is called frames. There are two subsections in this layer such as MAC (Media Access Control) and LLC (Logical Link Control).

  • MAC (Media Access Control) — Flow control and multiplexing device communications over the network are handled by the MAC address layer.
  • LLC (Logical Link Control) — Over the physical media, the LLC layer offers error control and flow control, as well as identifying network layer protocols from the header.

Layer 1 : Physical Layer

This is the lowest layer of the OSI model where network devices take part entirely such as cables, routers, switches, and hubs, etc. This layer is responsible for the actual physical connection between network devices over the physical layer in the world. Here the data is transferred in the form of Bits. So when receiving data, this layer receives the signal and converts it to 0s and 1s before sending it to the Data Link layer.

So now I hope you will have a basic idea of HTTP and how OSI Model works.

References

--

--

Ramsunthar Sivasankar
Nerd For Tech

MSc student of Greenwich University || Software Engineer