1

I understand that ping packet use layer the IP address of the destination. but I do not understand how it works between 2 hosts residing in the same subnet and they are both connected to the same layer 2 switch

how does the layer 2 switch act when receiving the ping packet

enter image description here

thanks

6

On a directly connected layer-2 network/segment, IP communication works by encapsulating IP packets into layer-2 frames addressed to the destination's MAC. The source learns the destination's MAC address by using ARP (IPv4) or NDP (IPv6).

The switch doesn't see the IP packet within the Ethernet frame, but it looks at the frame's MAC addresses. The destination MAC address is used to select the egress switch port. The source MAC address is used to update the switch's MAC table.

  • where does IP packets into layer-2 frames encapsulations happens ? – Ethem Oct 30 '18 at 10:41
  • L2 encapsulation is performed by any L3 entity needing to send an IP packet over an L2 network: the source host just encapsulates the packet; each hop/router on the way first extracts the packet, discards the frame, decides about routing and then encapsulates it in a new frame. – Zac67 Oct 30 '18 at 18:34
  • it looks crystal clear now,appreciated @zac6 – Ethem Oct 31 '18 at 4:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.