Take the following scenario :
1) PC1 is connected to port 1 of the switch and its ip address is 192.168.1.2/24.
2) PC2 is connected to port 2 of the switch and its ip address is 192.168.1.3/24.
The following are the sequence of events which would happen when PC1 pings PC2.
a) User on PC1 pings PC2.
b) The route entry corresponding to the destination IP address (In this case PC2) is checked on PC1.s local routing table.
c) In this case, since the destination and the source are on the same network, the ARP cache on PC1 would be looked into for PC2.s information.
d) If unavailable, an ARP Request would be sent to PC2 from PC1. ARP is sent to retrieve the mac-address of PC2 .
This is needed to construct the ethernet frame which is required for encapsulating the IP Packet.
e) After PC2 responds , the IP packet packet carrying the icmp data (Ping) will be encapsulated in the ethernet frame and sent to PC2.
f) PC2 would first check if the destination mac-address in the frame is it;s own address.
g) After verification, the destination IP address would be looked into. In this case , it is PC2.s IP address.
h) The data would now be processed (icmp data) and a response (icmp reply) to PC1 would be send.```