Mapping between a hardware address and a protocol address is known Address Resolution. A router or host uses address resolution when it requires to transmit a packet to another device on the similar physical network. A computer never replace the address of a computer that attaches to a server.
In the diagram below a simple Internet with routers R2 & R1 connecting three physical networks is given each network has two host devices attached.
In the diagram, A resulted protocol address for B for protocol data packet from an application on A transmit to a program on B. A does not find a protocol address for F. Through the Internet layer, A sends to F by routing through R2 and R1. A find R1 hardware address.
Network layer on A passes packet having resultant protocol address F for delivery to R1.