In a computer network, you might have a number of wired optical and wireless devices connected to each other using a device known as intermediate devices, such as a LAN switch and or a wireless access point. The intermediate device provides interconnections between local hosts on the local network. The IPv4 address determines the destination of the packet. The packet may be destined for a local host or a remote host. The IPv4 address and subnet mask combination of the source device compared to the IPv4 address and subnet mask of the destination device. Packet forwarding decision between the different host is the role of the network layer. A host can send a packet to the following:
A host can ping itself sending a packet to a special IPv4 address 127.0.0.1. 127.0.0.1 also known as a loopback address or loopback interface. Pinging the loopback interface tests the TCP/IP protocol stack on the host.
If sending host and receiving host belong to the same network. The hosts share the same “network address”. The host can complete a connection with each other and share information without the need for any supplementary devices. If a host is sending a packet to a device that is configured with the samenetwork as the host device, the packet is simply forwarded out of the host interface, through the intermediate devices, and to the destination device directly.
If sending and receiving host not belongs to the same network both are a remote host for one another. For example out to other homes, businesses, and the Internet. So they cannot share the same network address. In nearly all situations we want our devices to be able to connect beyond the local network. When a source device sends a packet to a remote destination device; then the help of routers and routing is required. Routing is the process of identifying the best path to a destination. The router connected to the local network also referred to as the default gateway.