Wassupppp Nerds, Hope you guys are doing fine. As promised today we will understand deeply what is a ROUTERRRRRRRR and more important than that why do we even need it can't we just deal with the switches all over the place. We'll also see today how switches the MAC addresses when connection is just established, i gave you guys a little hint in the last blog, if you did research on that then i'm sure you would have got your answer if not then no problem brother, i'm here with all the answers as promised. There is only one pre-requisite for this blog that you must've read my last 2 blogs so that you get the context. You can read them here.
SO LETS GET STARTEDDD!
Importance of Routers
First and Foremost i want you guys to understand why do we even need routers can't we just connect two group of networks with a switch. If we talk about the real world case, then we can't because the simple reason is both networks are in the different IP group, yeah i promised i'll explain what are IP addresses, so now is the time we get a little touch of what IP addresses are really.
WHAT ARE IP ADDRESSES????
If we talk about the definition then we say that:
An IP is a 32-bit integer and it is the unique identifying number assigned to every device connected to the internet.
I know its nothing scary here, but trust me IP plays a very important role. You can understand it like this, suppose you want to send a letter to your friend who lives in Canada, and you live in India, then how you'll send him the letter(not talking about email, talking about physical letter). You'll probably mail it, you give it to a international mailing company with a addresses and they will ship it to your friend. But wait if you put a condition on that letter and say to the shipping company that give it only to the person i said, no one else. Then they will do as you instructed them to do.
So if you understood the above example then you've pretty much understood what is the role of IP, yes correct, IP addresses gives you the way reach the destination. But after reaching the destination how to find the exact person, who does that job, if you guessed MAC addresses then my friend you are 100% correct. And this is what we discussed in the last blog switches and mac addresses, Layer 2 stuff.
But wait a second isn't the topic of today's blog is WHAT IS A ROUTER, then why are talking about IP and stuff. I'll explain that in a bit but first i want you guys to explain how Switches get the MAC addresses when the connection is just established. So lets first understand that,
HOW SWITCHES GET THE MAC ADDRESSES OF THE DESTINATION WHEN THE CONNECTION IS JUST ESTABLISHED?
As i said IP addresses are just addresses of devices on the Internet, and for communicating to anyone on the internet you have to have his IP address. But you might think that you don't know the ip address of google but you still use it, yeah correct but you know that when you type www.google.com
on
the browser you get the google page. This www.google.com
is nothing but a name given to google's IP and this gets resolved through DNS, but thats a topic of another day. You just have to understand that for communicating to anyone on the internet you have to have its ip address.
Now go right now and open your terminal and type ping google.com
you'll get many results and it won't stop for stopping it press ctrl + c
or on mac cmd + c
. Just so that you guys know we do ping and type ip after that to confirm that server running that IP is up or not.
So if you get so many unstopping results then it means google server is up and you can communicate with it. But hold on how is this all related to switches. So lets understand that part first and for understanding that you need to understand what are ARP packets.
ARP Packets
The fullform of ARP is Address Resolution Protocol.
Suppose you ping your friends laptop who's ip is 192.168.32.24. And he is in the same network as you.
So you know that request will go to switch. But you just established connection with a switch then how switch knows the MAC address of your friends laptop from just the IP, to which he is sending the request. The answer is ARP packets.
So basically what happens is, when you say ping 192.168.32.24 then your switch does not understand it, it only knows the language of mac address, so what switch does is it sends an broadcast message to the whole network asking WHO IS 192.168.32.24, i need your MAC address
and whoever will be 192.168.32.24
in that network he will respond with his MAC addresses and the switch will then know what is the MAC address of that guy and he will store it in his CAM table and that how SWITCHES know about the MAC addresses, unlike dumb HUB which just sends the whole data to everyone on the network, switch knows his job and he carefully without sending the whole data to everyone, just asks WHO IS 192.168.32.24, i need your MAC address
.
AND THATS HOW SWITCHES WORK!
Now lets start with WHAT ARE ROUTERSSSS.
WHAT IS A ROUTER?
A router is a crucial networking device that operates primarily at the network layer (Layer 3) of the OSI model. Yeah i know we still haven't talked about OSI model but we will i promise. You can understand it like this, Router lives at layer 3 and understands the language of IP addresses. Yeah that pretty much it about router.
It main functions include packet forwarding, routing, and connecting multiple networks. Yeah thats correct, Its the routers which makes the connection of different networks possible. And due to routers only you and I are able to access Internet.
Routers are responsible for determining the best path for data packets to reach their destination by analyzing the IP addresses within the packets. As you know internet is nothing more than a group of networks and the role of routers is to locate whatever you need on the internet. And how router does that? The answer is routing table.
The routing table is a key component of a router. It is a data structure that stores information about known networks and their corresponding next hop destinations. When a packet arrives at a router, it examines the destination IP address and consults its routing table to determine the appropriate path for the packet to follow. The routing table is continuously updated and maintained through the exchange of routing updates between neighboring routers.
There is one more function of Router is to get the Mac addresses and guess how the router does that it's the same ARP Packets. As for Address Resolution Protocol (ARP) packets, they function at the data link layer (Layer 2) of the OSI model. ARP is used to resolve a known IP address to its corresponding MAC (Media Access Control) address. When a device wants to communicate with another device within the same network, it sends an ARP request asking for the MAC address associated with a specific IP address. The device with the matching IP address replies with an ARP response, providing the MAC address. This information is then used to establish direct communication at the data link layer.
In summary, routers play a critical role in network communication, operating at Layer 3 of the OSI model. They use routing protocols, maintain routing tables, and forward packets to their destinations. ARP packets, on the other hand, function at Layer 2 and help to resolve IP addresses to MAC addresses within the local network. 🌐🔄📡
That all for today, In next part we will learn what is this OSI MODELLLLLL!
Top comments (0)