How your Browser lets you watch Youtube? Understanding behind the scenes of the Internet 🌟
Someday on a warm afternoon, while watching Samay Raina, Rahul randomly thought, 'How am I actually able to watch this video just by searching Youtube on my browser? ah...MAGIC? 🤔
No? Then how is it all happening so seamlessly?
Well, Rahul didn’t know that some very smart logic is going on behind the scenes, which we don't usually see on our screens but are crucial for us to understand 😲
Jargon involved ( just some fancy terms ) :
Server - A host machine that stores all the data and responds when requested
Client - User who requests data
request - This term also known as verb, used to request data from the server
IP - Internet Protocol i.e., your location on the internet
ISP - Those who provide you the internet (eg - Jio, Airtle etc)
URL - Address of the website
User Agent - Software which helps the user to access the internet, and in this case it’s our browser (eg - Brave, Arc, Chrome etc)
Packets - Small packets of data
Step 1: Getting an address on the Internet
As soon as you get connected to the internet, the very first thing that happens is your device gets an IP address
Q. But how does it works? you might ask
Answer : How you get an IP address 👇
How you can check your IP address 👇
Open terminal
Type ipconfig (windows)/ ifconfig (linux)
Your IP address will be the IPv4 address
IP address - 192.168.1.8
Now, as you have got your IP address, you can start navigating through the internet :D
Step 2: Requesting Information
Now, as Rahul has connected to the internet. He will use his User Agent to find Youtube, and for that he would have to type it’s URL on the search bar i.e., https://www.youtube.com
Q. But what does this URL signify? you might ask
Answer : Well, it’s just a collection of useful components.
And when Rahul types this in his browser, the request is sent over the internet to YouTube’s servers.
But how does this happen? That leads us to DNS (yep, technical terms ik)
Step 3: Resolving the Address (DNS)
Q. But what is DNS? you would ask
Answer: So, DNS (Domain Name Server) is just like an address diary which stores addresses of all the websites present on the internet just with their URL. YEAH, so now you might be able to connect the dots from our previous steps 😁
So as soon Rahul would enter www.youtube.com (url)
Rahul’s browser will send a request to the nearest DNS server.
The DNS server looks up the IP address for
www.youtube.com
.The browser gets the IP address and forwards the request to YouTube’s server. (easy 😄)
Step 4: Now finally, connecting to Youtube
Now as soon as the DNS lookup is resolved, his browser will send an HTTP
request to Youtube which would contain
The resource Rahul wants to access (video/channel in our case).
Headers: Containing metadata, like the type of device Rahul is using and his preferred language.
Step 5: Receiving the Data
After sending the request from the browser :
Youtube would provide the requested files in packets
The browser decodes all these packets
And finally, Rahul can watch the video displaying on his screen (time taken <5sec)
This is the beauty of Internet and it’s nuance working 😇