How internet works? - An overview

How internet works? - An overview

Introduction

The internet is an incredible invention that has revolutionized the way we live, work, and communicate. But how does it actually work? What happens when you type https://google.com into your web browser? In this article, we'll explore the inner workings of the internet and answer these fascinating questions.

OSI Model

The computers on internet share data with each other using the OSI Model, which has 7 layers as given below.

  1. Physical layer

  2. Data Link layer

  3. Network layer

  4. Transport layer

  5. Session layer

  6. Presentation layer

  7. Application layer

the data is transmitted in small chunks called as ‘packets’, which can be lost while sharing. this loss can be prevented using various methods and set of protocols.

Protocols

The data transmission between different devices in the network needs to follow some set of rules knows as Protocols. It determines what is being communicated, how it is being communicated, and when it is being communicated. It permits connected devices to communicate with each other, irrespective of internal and structural differences.

Different layers of OSI model use different types of protocols, such as IP(Internet Protocol) is used in Network layer, TCP & UDP are used in the transport layer, & FTP, HTTP & SMTP are used in application layer. So when we say that HTTP uses TCP to transport data do not get confused as they are used in different layers of the model.

Here are some of the popular protocols -

TCP - Transmission Control Protocol

Transmission Control Protocol popularly known as TCP is a widely used protocol on internet, mostly used to serve webpages on the internet. this protocol ensures reliability and ordered data transmission using 3 way handshake which has 3 steps as give below.

Although this three-way handshake assures reliability and no packet loss, it increases the data processing time and slows down data transit. One of the protocols that is faster but less reliable is UDP.

UDP - User Datagram Protocol

User Datagram Protocol popularly known as UDP is popular for its speed. it is widely used in video streaming, gaming and DNS lookup which we will discuss further in this article. in this protocol the user just sends a request and immediately receives a response.

it is fast because there is no permanent connection between the client and server. and it also doesn't guarantee delivery or order of data packets. that’s why it is also called Unreliable Data Protocol

some more popular protocols are: HTTP, HTTPS, FTP, SMTP, VOIP etc.

What happens when you visit a website?

When you enter a website address on the browser, what you see is that the webpage is served immediately, but in reality there are many actions happening behind the scene. Actually that web address first goes to a DNS server which further sends the web address to a root name server from there it goes to a TLD nameserver (.com, .ai, .in etc.) then it further travels to the authoritative nameserver (GoDaddy, Namecheap, etc.) which returns an IP address to the browser (An IP address is a network address for your computer). this process is known as DNS Resolution or DNS lookup.

using the IP address from DNS resolution the browser sends a HTTP request to the web server where the website is hosted and receives a webpage as response. to learn more about the DNS visit here.

What is a HTTP Request? or what even HTTP is??

HTTP - Hyper Text Transfer Protocol

As suggested by its name the Hyper Text Transfer Protocol, commonly referred as HTTP, is a protocol (set of rules) which is used in the transfer/transmission of Hyper Text (hyperlink embedded text) in application layer. it is the most popular protocol for accessing webpages. in the beginning phase of the internet, it was just a network to publish your research papers, but these papers needed to link a reference paper to it, this lead people to the Hyper Text which allowed to embed link to other research papers. it uses a request response model to transfer data, which was human readable.

In present time we use HTTP-2 which helps us in various ways like, Compression, Multiplexing, Encryption etc. The ability of encryption evolved as HTTPS which is a secure version of HTTP, in this method we use TLS certificates to authenticate the connection. Transport Layer Security (TLS) certificates are digital credentials that verify a website's identity and encrypt data sent between a client and the website.

HTTP Request Response Model

The HTTP request-response model, uses TCP to establish connection between client and server to ensure no loss of data and describes a communication pattern in which a client makes a request to a server, and the server replies with a corresponding response.

Format of a Request

  1. HTTP Methods -

    Methods are basically the actions you want to perform on a server, like GET, POST, PUT, DELETE etc.

  2. Request Headers -

    Headers provide additional information about the request, like from where it is sent or which device it is sent from. e.g. User-Agent, Authorization, Content-Type.

  3. Request Body -

    Data sent by the client in the request is called request body.

Format of a Response

  1. Status Code -

    Status Code shows the outcome of request. Some examples of the status codes are, 200, 404, 500 etc.

  2. Response Headers -

    Like Request header the response headers also give additional information about the response. e.g. HOST - gives information about the host port.

  3. Response Body -

    Data returned by the server to client is called response body.

Workflow of Modern Request Response model

  1. Setup a TCP Connection.

  2. Exchange TLS Certificates.

  3. Send Method + URL + Data + Headers

  4. Receive a response with Status Code + Data + Headers

  5. Close the TCP Connection.

Summary

The internet is a vast network of computers that communicate using protocols like TCP and UDP. When you visit a website, your browser first translates the website address (like [invalid URL removed]) into an IP address using DNS. Then, it sends an HTTP request to the web server at that IP address. The server responds with the webpage data, which your browser displays. HTTPS is a secure version of HTTP that encrypts data for safe transmission.