


Now how does this all work in reality? consider this setup. Host A and B want to talk, and there is host R between them routing between thier networks. Now host A's name resolution layer asks for a name lookup for B, and retrieved an IP address. It forms an ICMP packet, plugs in the IP address it found, sets itself to be an echo request, etc. Then ping sends its packet down to the kernel. The kernel through its routing table knows that B's net is not locally connected, but accessed through its next-hop gateway R, so this is who the packet will be sent to. Host A says "arp who-has host R's ip" and host R replies with its MAC. Now host A forms an ethernet frame, with host R's MAC as the destination and sends in on the ethernet. Host R sees this incoming frame, and looks at the frames payload, and notices its IP, so it looks to the IP destination address. It sees this IP and knows this address is on one of its locally connected interfaces (routing table at work again) and so on that interface it says "arp who-has Host B's ip". Host B replies and a new ethernet frame from host R's mac to Host B's mac is formed and sent on the wire.
