Current location - Quotes Website - Collection of slogans - How does the switch handle the packets sent by the ping command?
How does the switch handle the packets sent by the ping command?
If ping is in the same network segment, when the ICMP message arrives at the switch, the switch checks its own MAC address table according to the source and destination MAC addresses in the message, and forwards the ICMP message from the corresponding port if there is a destination MAC record; If there is no destination MAC record in the switch, it is flooded and forwarded from all other ports except the received message, and the port number of the destination MAC is obtained and recorded in the MAC address table to forward the data.

If you are not on the same network segment, that is, you have to go through the gateway, there are several situations. If there is a record in the ARP record of the ping host, the ICMP message will be sent to the switch, and the switch will send it to the gateway, which will forward it according to the route. If the switch has no MAC record, it will flood, and the gateway will reply to the source with its own MAC address and the IP address of the target computer according to the proxy ARP. At this time, the switch will write the destination MAC, that is, the MAC of the gateway and the corresponding port number into the MAC address table and forward it.

If the ICMP message is unreachable, an unreachable return will be echoed.

You may feel sorry if I say so. This problem should consider the working principle of three-layer ARP and proxy ARP under OSI and the MAC address table of the switch.

The above is my personal understanding. If not, please advise.