Question 1: In one of the videos describing how the server respond by sending packets to the client. It is observed that the router (to which a phone and a laptop are connected) sends the packets to both the laptop and the phone , even though the phone did not request those packets.
Doesn't this mean the router is just wasting time and bandwidth by sending the packets to the phone, is there a way to prevent this wastage and make the router aware of the node which actually requested for the respective packet.
Considering this scenario:
If i have my airtel hotspot up (acting like the router here) i have laptop and another phone connected with it. Now if we replicate the same scenario the phone would be using extra unecessary data for the router has to send the packet to phone and laptop , where the phone rejects the packet , in this process data is consumed causing loss.
Is the above scenario practically correct ?
Answer 1:
Yes but not exactly the way said the following is what happens:-
There are two kinds of devices that are used in a Network.
The hub works on the broadcast (send to all)
The switch works on the unicast (send to the person who requested by inspecting the mac.)
The switch has a mac address table which has entries of device's mac address connected to each of its port. When the switch receives a packet to be sent it checks the destination mac address on the packet and looks for the mac address in its table. Say that device was connected to port 5 so the switch would send it to port 5 and not everyone connected. A hub does not have such a table, so it sends it to everyone. Hub is very old tech and has been replaced by a switch.
Now coming to the scenario seen in Packet tracer. The device you saw sending the packets to both was a Wifi router. Wifi router especially the home router is a combination of a router and a switch (actually a hub). Since the router connects to devices via radio signal and uses a band of frequency, it can not maintain a one to one connection, unlike the switch which has a wired connection. So it sends the packet on the frequency and everyone listening checks if it's for them or not. Yes, it could be optimised, for example, have a subset of frequency for one device and another subset for another device but creating subsets will narrow your bandwidth.
Thirdly you data plans only count the data that transmits between you hotspot and tower (internet side) not the hotspot and your home devices (Home network /LAN side). When a packet is received by your airtel hotspot from say google and it was of 5kb, so the 5kb has been consumed from your data plan. Now that packet 5 kb is broadcasted as radio waves to all your devices, so essentially it's just one transmission that everyone receives. Its like FM the station sends one single transmission, and everyone receives it. Now if your FM radio has some mechanism of knowing that it was for you or not, it would play the transmissions for you and not the one which is not for you even though it receives it all.
Hence the confusion arose because how Cisco packet tracer represents the communication.
Question 2: Sir, as you have told in the previous vedio that the complete action of transferring the data packets from the source to destination is achieved with the help of ROUTERS and SWITCHES but when it come to the routing process which is achieved only with the help routers then whats the role of switches ?
Answer 2:
Switches and router the same function but at different layers and different places of the network. The difference is Router know the Internet well whereas switches know the Local network well
Let's talk about the local area network first:
So the most basic local network could be you connect one computer/laptop to another using a LAN cable. Now if you want to grow this network how do you do that? That is done using a switch. A switch has a large number of ports around 24 in some versions so you can connect 24 systems using LAN cable to a switch and the switch will have a table with stores the MAC address of the device connected and the port number it is connected to. When one computer wants to send a packet to another it basically adds the destination mac address of the destination computer to the packet and sends it. The switch receives it, checks the destination mac address of the destination computer mentioned in the packet. Looks for which interface the mac address is connected to and sends it to that interface.
Now, what happens when the packet its to go on the internet. A switch doesn't have the table of all mac addresses on the internet. So we call our advanced device called the router what has the powers of a switch but also another superpower that is it can understand IP addresses or the Layer 3 data. So what happens here?
The computer knows based on the destination IP address that the destination of the internet packet is not on the local network. It knows what has to be done in that case. Send it to the gateway which is a router. Based on the meaning of the word gateway it is the way of going out of the local network or your house to connect to the rest of the world. So the computer adds the destination MAC as the MAC of the gateway (router). The switch does its mac table check and sends the packet to the gateway (router). Now the router uses its superpower to check the destination IP address of the packet. The other superpower the router has is its super memory and its collaboration to other routers. It uses these to determine the best path for the packet and sends it to the next router. In doing so the router uses its advanced switching power and changes the destination mac address of the packet to the mac address of the next router. Just as a switch does it send it to the next router which is connected to it. This keeps happening till the packet reachers the gateway of the network to which the destination IP address belongs. Once it reaches the gateway of the destination IP address, the gateway knows the destination IP address belongs to its local areas network. So it uses its switching power to change the destination mac address of the packet to the MAC address of the machine to which the destination IP belongs.
To summarise the switch and router do the same thing. The router, however, has the functionality of the switch but more features and powers that allow it to route packets over the network and not just the local network. Routers have much more other features and there is also a special type of switch called the L3 switches which share some of the superpowers of the router. But that depends on the networks they are in and the roles they have to play.