Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 29

hello everyone my name is Abhishek and welcome back to my Channel today is

episode two of networking fundamentals and in this video we will Deep dive into
the concept called OSI model before we do that let's quickly recap what we have
learned as part of episode one in episode one we learned about IP address what
exactly is a subnet what are the different types of subnets we learned about cidr
how to read write and perform calculations on cidr blocks if you are not aware of
this networking Basics I'll highly recommend you to watch episode one and the
link to episode one is in the description now let's move towards the Whiteboard
and start understanding the concept for today that is OSI model we all interact
with servers on a day-to-day basis let's take a simple example let let's say I
open my laptop open one of my favorite browsers and search for google.com within
a fraction of seconds I receive a response back which is nothing but Google
homepage a HTML page basically but how does this thing happen how is my request
from my personal laptop sent over the internet to one of these Google servers
and how is the response received back to my personal laptop what are the
different components that are involved and what are the different layers in
which the Journey of data takes place I'm calling it as journey of data because
whatever you are trying to request and whatever you are trying to send is all
data so OSI model is one of the popular models that helps you understand the
Journey of data across the internet what are the different layers that are
involved and OSI model explains this entire thing in seven layers layer 7 to
layer 1 sometimes it can be layer 1 to layer 7 if you are at the end of the data
but what exactly each of these layers do what happens to my data in each of these
layers when I say layer seven layer six layer five layer four layer 3 2 and 1
what each of these layers actually do how my data gets transformed in each of
these layers and finally how does it reach one of these Google servers let's try
to understand the same thing in today's video we we will use the same example
that is request to google.com and let's try to understand the complete workflow
here before we understand the Journey of data that is even before your browser
initiates a request to the Google server there are two things that happens that
is even before the OSI model comes into picture they are number one is DNS
resolution it is also good to understand these Concepts before you understand the
OSI model and what each and every layer does because this is also part of the
entire workflow that you are trying to learn the networking Concepts DNS
resolution and the second thing that happens is the TCP handshake now why these
things happens even before your request is initiated right even before the
request starts or even before the request is sent why these things happens
because let's say you are searching for or you are trying to make a request to
https www.google.com first of all what your router that is your home router or
your browser tries to do is they will try to verify if www.google.com is mapped
to any particular IP address so so there is a system called DNS which is nothing
but domain naming service you can understand it as a simple database right just
try to understand it as simple database where records are maintained right if I
have to explain this in a very simple way just try to understand that every
router has this information which is records of domain name mapping with IP
address right so when you are saying www.google.com in this domain naming
service there is an IP address against the google.com domain name now when you
search for this www.google.com router verifies this initially in the local cache
right just like your laptop has a local cache or you know you have uh the local
memory similarly your router initially searches this for in the uh local cache
where previously if your router has made a reest to this particular website it
might have maintained it record its records in the local cache if this
information is not available in the local cache then it goes to your internet
service provider and verifies this particular mapping if there is any mapping for
the domain name in your internet service providers DNS every internet service
provider maintains a DNS where the complete records are available right so
google.com is usually mapped to the IP address 88.8 eight so if this mapping
happens if this domain that you're trying to reach is actually valid only then
you will move to the second stage why this needs to be performed because let's
say I'm trying to access something like www. abishek vera.com now this is
something that does not even exist I did not create this domain I did not map it
to particular IP address now what's the point point of you know starting with
this entire data Journey sometimes you might be uploading some 10gb file or you
might be sending a huge amount of data now if the DNS itself is not resolved
what's the point of even starting the data Journey or what's the point of even
initiating the request why should your browser or router initiate a request right
so this is the first step that happens DNS resolution if the DNS resolution
happens then comes your second step stage which is nothing but TCP handshake
now what is the TCP handshake again it's a very simple concept let's say this is
your laptop and this is the Google server now you are trying to send a request
to it you are ready to send a request but is the server that you're trying to
send is ready to access accept your request what if it denies your request even
after sending this entire thing right what if you cannot make a handshake with it
handshake is nothing but you are just trying to say hi and it says hi I'm okay to
accept your request so there is a TCP handshake which is usually called as a
three-way handshake that gets performed even before your request initiation or
even before your OSI model comes into to picture now how does this three-way
handshake perform So when you say www.google.com what your router or browser what
they try to do is they initially send a high to the server like let's say this
is your laptop and this is your server so initially router tries to send a high
in networking terminology we call it as sync and if this server is ready to
accept if it says that okay I'm good then it says hi which is in the networking
terminology sync acknowledged and finally your laptop says acknowledged so this
happens in three steps that's why we call it as a three-way handshake now you
might ask me but abishek why can't it be very simple as you say sync and it say
sync technowledge and it's done so it's a very uh detailed explanation let's not
go into it but if you are interested there is also something called two-way
handshake and there's also something called four-way handshake so if you are
interested you can go through these things you can read about difference between
two-way 3-way and four-way handshake three-way is the most popular and which is
mostly used so that's why uh I'm talking about the three-way handshake but you
can also read about these things so these are the two you can consider as
prerequisites even before your data uh request initiation takes place one is DNS
resolution two is the TCP handshake now that you understand both of these
Concepts that is if DNS resolution is done and TCP hand check is also done then
your data initiation or your data request initiation starts now let's try to
understand that in terms of the OSI model now I hope you understood why did I
explain this even before the OSI model because when you are learning networking
it's important to understand the end to- end part of it now to start with OSI
model let's take same example when you search https www. google.com and I'm
assuming DNS resolution is successful and TCP handshake is successful so what
happens after that is your browser right understand this carefully your browser
initiates a HTTP or https request to the server that is this one right so you are
searching for google.com in the browser so your browser is initiating a request
now it did not send the request but the initial process has started now when the
initial process has started it says use HTTP based request why because you have
asked for it let's say you're asking for FTP then your browser initiates a FTP
based request right so this particular stage is called as layer 7even which is
the initial stage and also called AS application layer in this particular layer
you can pass some headers right and you can also provide information for the
authentication or whatever is required but this happens in the layer seven then
comes like once you or browser has initiated the HTTP request right if I go back
to this particular thing once the request is initiated now what should be the
next step if you think about it the next step should be data encryption right
because no one in the entire process like from your laptop to the server data
goes through multiple routers I'll talk about it what are these routers but
basically data first goes to your home router then it goes to your internet
service provider from them it goes to a different router different router and
finally it goes to the Google server so if your data is encrypted then even if
someone tries to hack your data they don't understand what exactly it is and that
where we use https right so when you use https The Next Step that has to happen
after the HTTP request initiation is data encryption which is also called as
data formatting and this layer in
OSI model is called as layer six which is also called as presentation layer now
all of these layers are virtual just for you to understand so Osa model is trying
to just explain you that okay this is the first step that happens this is the
second step that happens and once HTTP request is made data is encrypted what
should be the next step The Next Step should be your browser should create a
session what exactly this is very simple let's say today you can go to
facebook.com and probably search for facebook.com/ abishek vamala 20 minutes
later take a different tab or probably take a different window as well and search
for facebook.com/ Raju or John your browser will not ask you to authenticate one
more time initially when you search for facebook.com/ abisheka it will ask you to
login into Facebook but even after 20 minutes if you search for slj or/ XYZ
facebook.com does not ask you to authentic indicate because there is a session
that is maintained and this session is very very important because sometimes
let's take example of your banking transaction okay so initially you log to your
bank and probably you try to send someone uh some amount or you know you try to
make a transaction what if your session gets disconnected in 1 minute you just
have one minute you complete your transaction or you make a transaction and you
want to make one more transaction right unless you log out your bank server
should not ask you to log in one more time and that happens only if your browser
creates a session we all use sessions on a day-to-day basis whether you using
Instagram Facebook or anything there are sessions that are maintained so once the
HTTP request is initiated second thing that happens is encryption which is
nothing but data formatting in the presentation layer and then a session is
created with you and the server so so that the server does not ask you to
authenticate multiple times and this particular thing is called as session layer
and one interesting thing about all these three layers right layer seven layer
six and layer five is that all of these three layers are maintained by your
browser right so all these three layers happen at your browser level what does
that mean let's say you using Chrome or you're using Firefox or you're using any
particular browser layer seven layer six and layer five are taken care by those
browsers itself right your browser initiates a request then your browser
depending upon https and what kind of certificates that you're providing it takes
care of encryption and your browser only takes care of session if you want an
example just go to your browser go to your browser settings and try to clear cash
as well as cookies and then try to authenticate with the facebook.com let's say
you authenticated facebook.com two minutes later if you delete the cookies and
cash it will ask you to authenticate one more time because you have deleted the
session session is basically stored in cookies and cash right so layer 7 six and
five are taken care by your browser itself we did not even come to to the router
part if this is my laptop and this is my server laptop is connected to my home
router till now whatever I discussed happening is happening in the browser itself
my request even did not reach this particular browser if I'm talking about only
layer 6 5 and four now the next thing that happens is once the session is also
created to transmit the data right if we are taking this example some cases the
data that can transmitting can be of 10 GB also right probably you trying to
upload a movie or you are trying to do something so if you are trying to do data
in one at a time like if 10 GB if you're trying to upload at once or you know
even simple things such as requesting to google.com what usually happens is your
data is segmented right that is the data that you're trying to send or the data
that you are trying to receive is segmented and split into parts so this
particular thing is called as segmentation and this happens in layer four along
with the segmentation in this particular layer the protocol is also defined
whether you want to use TCP or UDP right so there are only two protocols which
are like these are the widely used TCP as well as UDP and in layer four once all
of these things happen data segmentation takes place and the particular protocol
is also identified in this layer how is the protocol identified mostly these are
standardized let's say if you're using HTTP the protocol is TCP if you're using
something like DNS or something else the protocol is UDP so this protocol are
standardized and whether I mean if you using HTTP PCP is the protocol that is
used to transmit the data from here on that is the segments of data that got
split are transmitted using the TCP protocol and this layer is called as
transport layer now once the data segmentation is also done now it's time to send
the data and to send the data the first thing thing that happens is the data
that send is received by your router and what your router does is router does two
particular things one is to the segmented data let's say you want to travel from
Delhi to Mumbai here you know what is your destination right you know that you
want to travel from Delhi to Mumbai and second thing is what is the sh shortest
path probably you can travel from T to Mumbai in 20 different ways but you will
only pick up the shortest path similarly even in this example data from your
personal laptop to google.com that is from India to the US there will be multiple
hops for your data that is there are multiple routers that are involved probably
your home router then your internet service provider from your internet service
provider to etc etc XY Z and finally it reaches the Google server so which
routers or which hops should your data take to reach the Google server in the
fastest way to understand that what we will do in the layer three is that we will
add Source IP address as well as destination IP address to each segment right and
here once you add the source IP address and the destination IP address we call
this data as packets right so packets have a clear information of how to travel
which path to take and who takes this decision this decision is taken by your
router and this layer is called as networking layer just try to take this example
Delhi to Mumbai if you have to travel you need to know what is your source and
what is your destination if you want to send 100 people from Delhi to Mumbai to
each and every person you will tell them that okay this is the path that you have
to take similarly in layer three your router comes into picture and your router
tells each and every packet that okay this is the source this is the destination
IP address and you need to travel through these hops right and this layer is
called as networking layer then comes your Layer Two and in Layer Two like okay
now your router received the information but if you understand it carefully
usually these routers are connected to switches right even if you look at your
home network your router is connected to a ethernet port and from the ethernet
port your router is connected to the cables right so if you're talking about this
ethernet ports or if you're talking about the switches right now data has to be
sent some or the other time to these ethernet uh ports or to the switches right
so at this point of time when the dat data has to be sent to the ethernet ports
the data has to be transformed from the packets to frames depending upon the
medium that you're using if you're using router the data is converted into
packets then if you're using these switches the data is converted into frames and
in this frames along with this IP address that you have provided Mac information
is also added which is nothing but Mac Mac information tells these switches what
are the other components within your network right so here Mac components are
also added now you might be thinking but why can't I use packets because your
medium has changed from router this request is being sent to switches and
switches only understands how data can be transmitted in the frames so this layer
is called as data link layer finally you have layer one that is your data end of
the day or your router switches end of the day are connected to optical cables
and guess what language this optical cables understand the language these optical
cable understands is electronic signals right so here your data is transmitted
into electronic signal and using optical cables data is transmitted very fast
right and this is how your data is transformed right if if I have to explain this
in one single slide one more time you have layer 7 layer 6 layer five layer 4 3 2
and 1 so if you take your personal laptop and this is your Google server for
example now when you initiate a request to www.google.com so initially what your
browser does starts with layer 7 I mean the process starts with layer 7 where
first of all it defines what is the type of request so mostly we use HTTP type
requests so HTTP or https now once it identifies that okay I have to initiate a
HTTP based request second thing that it does in the layer six is encrypt the data
once the data is also encrypted the next thing that happens is create a session
with the server now once the session is created with the server because data has
to be transmitted within fraction of seconds segmentation of data is important
and that happens in layer four and here along with the segmentation the protocol
is also identified depending upon the request that you are making if it is HTTP
TCP request is most widely used once the segmentation
is also done right now the data is divided into small parts after that data
reaches your routers and within the routers the path to transmit the data is
identified because in this layer we add the IP address for each and every segment
and here we call them as packets once packets are also created then the next
thing is from the routers you will move towards the switches and here data is
converted into frames where you add the MAC address of each and every component
that is there so that you know like you add the MAC address so that within the
network this switch can understand what are the other components to transmit the
data and finally layer one is a physical layer where these switches are connected
to optical cables and here the data is converted to electric signals or
Electronics whatever you would like to call right so when you initiated the
request from from layer 7 layer 6 5 4 3 2 1 what happened from your laptop it
went to your router from router it went to switch and it connected to the cable
now it goes through multiple hops over the internet and finally it will reach one
of these Google servers right from layer one which is let's say this is one of
the cables then it is connected to other routers other switch and again cable and
this entire thing happens and the data is transmitted and finally it reaches one
of these Google servers Now understand carefully what happens here when this data
received by one of these Google servers again the OSI model comes into picture
where initially data is received by one of these Google physical servers so one
of these Google physical servers is connected to a optical cable so L1 from there
it will go to one of the switch boards then it identifies which router to use
from there the data which you have been using as uh packets like whether it's a
TCP or UDP right let's say we are using the TCP protocol so here the TCP data is
taken into place from there once you have the TCP data here then session is
validated after that de encryption takes place from there it will go to one of
the Google's applications and this Google application will say hey okay this is
your request so let me give you a HTML page as a response pack here this
application is a microservice or any particular monolith application which has
the source code and it understands depending upon your request okay I want to
generate a HTML page now again this HTML page is sent back to your personal
laptop and same thing happens right before it reaches your personal laptop your
router is connected to a physical cable so it has to move from L1 1 L2 L3 L4 5 6
and finally reach your particular laptop so this is the entire OSI model and you
know basically when you are sending the request L7 to L1 data is transmitted
right data is transmitted through L7 to L1 layers now when you are at the
receiving end data is received from layer one to layer seven so these are all the
these are not the physical layers right these are just just a way of explanation
of OSI model for you to understand the data transmission in a better way OSI
model explains it in this particular way of course Osa model is not the latest
model there are models like TCP IP model right which is again based on OSI model
but the thing is in TCP IP model L7 L6 L5 is combined because you know more or
less these are are performed by the same component that is your browser so L7 L6
and L5 are combined and called as a single layer in the tcpip model so why people
usually prefer OSI model because this is a standard and if you understand this
standard you typically understand the entire transmission of data whether it's
tcpip model or any new model they are all based on the OSI model right so don't
get confused if you see TCP I model it's exactly the same only difference is L7
L6 and L5 are combined and usually they are called as one single layer in the
tcpip model right so this is the video for today and how this OSI model is
helpful for the devops engineers I will tell you that it is not completely must
have thing right this knowledge is kind of a good to have thing I'll tell you the
reason why because these days all of these things is standardized and this entire
thing is completely automated like you won't see anyone using wi Shack these days
unless you are working in the core networking company and probably if you're
dealing with the layer three layer two or you know if you are involved in any
sort of uh networking companies only then you see people using these kind of
things right the wi shark or any tools to decrypt the packets understand these
things but if you have a high level know of OSI model that is more than enough
you don't have to dig dive and try to understand what are the different protocols
in layer three right you don't have to understand what are the different types of
uh techniques that are available in layer 2 because there are this is a ocean and
whatever I taught in this particular video it's more than enough if you are
trying to understand networking as a devops engineer thank you so much for
watching today's video see you all in the next one bye-bye

You might also like