Switch – How It Routes Ping Packets

pingroutingswitch

i tried to browse all available answers on this subject, but it's still not clear to me what a switch can or can't do.

I understand that when a host sends out a ping command, for instance ping 192.168.1.5, the switch will only look at the frames, since it is a very simple version of a switch that doesn't operate in layer 3. But in my case, when using this ping command i do get a response from another host, so it seems that the switch did some routing?

Also, when a host is sending a packet to another host on the same switch network, before the ARP process, how does the sending host know the recipient's MAC address in the first place, if they didn't communicate before?

Thanks for the answers!

Best Answer

A switch is a layer-2 device. It forwards (switches) frames by looking at the MAC destination address, and forwarding the frame out the port that's associated with the MAC. A switch has no inkling of what IP or ICMP are.

IP packets are transported across Ethernet or other MAC-based networks by resolving the destination (or next hop) address to a MAC address that is then used for frame addressing (on a layer-3 device, usually a host or a router). For this, IPv4 uses ARP and IPv6 uses NDP.

Routing is the term used for layer-3 forwarding in a router between different layer-2 networks.

A layer-3 switch is a switch that also provides (possibly limited) routing capabilities, usually routing between VLANs.