Networking Basics – Understanding Hubs and Switches

pingswitch

Newbie here. I'm trying to understand how hubs and switches work.
I read that hubs only forwards to all ports but a switch only forwards to the port it needs to.

So, If I connect 3 computers to the same hub, and use PC1 to ping PC2, then all the 3 computers will receive the ping?

But if I connect 3 computers to the same switch and used PC1 to ping PC 2, then only PC1 and PC2 sees the ping because switches only forward it to the correct port. Is that correct?

Best Answer

If I connect 3 computers to the same hub, and use PC1 to ping PC2, then all the 3 computers will receive the ping?

PC2 and PC3 receive the echo request, and PC1 and PC3 receive the echo reply. A sender's signal is repeated to the other ports but not back the sender.

However, receive depends on the point of view: since the echo request doesn't address PC3's MAC, its NIC physically receives the frame but drops it right away - the encapsulated packet isn't received by the IP stack.

But if I connect 3 computers to the same switch and used PC1 to ping PC 2, then only PC1 and PC2 sees the ping because switches only forward it to the correct port. Is that correct?

Yes. Ping uses IP and IP requires ARP before sending an IP packet (containing an echo request or anything else). ARP causes the switch to learn PC1's and PC2's MAC addresses, so the switch forwards the frames with the echo request/reply to just the intended destinations.