0

Assuming 10 computers are connected via hub. Pc1 sends data to ip address of pc2. But hub broadcasts it to all computers.

Whereas if I replace hub with switch, then switch will maintain table of switch plug and Mac address.

When PC1 sends data to PC2's ip address, then how does switch ensure that it is send to correct computer (Pc2)? I am asking because switch doesn't keep record of ip address.

variable
  • 137
  • 7
  • The switch doesn't care about IP addresses. If you have such questions, probably SuperUser is a better place to ask, but I am sure this topic is it is answered in vast amount of places in the Internet, even in the Wikipedia. Just google it. – Nikita Kipriyanov Oct 05 '21 at 08:34
  • Is this a layer 2(L2) or layer (L3) switch? The former (hub) is very insufficient as you already mentioned. It will always broadcast to all connected devices since a hub doesn't keep a Mac address table. Assuming you are using an L2 switch then the switch will keep record of mac addresses of all devices connected to that switch. At this point, data is exchanged only at layer 2. No IP header is added to the payload.. so until L3.. IP's are irrelevant – Valentin Bajrami Oct 05 '21 at 09:06
  • @ValentinBajrami the question is basically how switch operation is different from hub opertaion. Don't scare this young soul with L3 switches, they simply aren't ready for that depth. And, as I mentioned, it is answered virtually everywhere, but it is offtopic on ServerFault. We deal with business problems here, not with novice questions about basic networking concepts. – Nikita Kipriyanov Oct 05 '21 at 09:48
  • @NikitaKipriyanov you are right. Hopefully all these little pieces of information get`variable` going! The intension is definitely not to scare this young soul :) – Valentin Bajrami Oct 05 '21 at 14:07

1 Answers1

1

In a nutshell, a switch learns which MAC addresses are associated with which switch ports. A network host wishing to communicate with another network host resolves the ip address of the destination host to the MAC address of the destination host and addresses the communication (at the data link layer) to that MAC address. The switch sees the destination MAC address and forwards it to the appropriate switch port.

joeqwerty
  • 108,377
  • 6
  • 80
  • 171
  • So the pc2 must have an ip address for it to receive data from pc1? – variable Oct 05 '21 at 14:59
  • Yes............ – joeqwerty Oct 05 '21 at 15:15
  • Wrong. No. The IP-address requirement is the result of Internet widespread, which uses Internet protocol (IP for short), which uses a 32-bit number ("address") to identify a machine. If you don't need Internet, you are free to use any other communication protocol, not necessarily IP, so you don't always need IP address to communicate. Use IPX, IPv6 (which is different from IP), etc. – Nikita Kipriyanov Oct 05 '21 at 18:14
  • @NikitaKipriyanov In the context of this question the OP requires an ip address for his hosts. This answer isn't meant to be a comprehensive networking lesson. For that the OP can purchase and read the following. - https://www.amazon.com/TCP-Illustrated-Vol-Addison-Wesley-Professional/dp/0201633469 – joeqwerty Oct 05 '21 at 19:00
  • Not only the question is offtopic here, but learning material or course recommendations too :) By answering this question, you gave the impression that it is appropriate. Do you want to have a blast of such questions on ServerFault? – Nikita Kipriyanov Oct 06 '21 at 06:46