In a home or business network, you might have a number of wired and wireless devices interconnected each other using an intermediate device, such as a LAN switch and or a wireless access point (WAP). This intermediate device provides interconnections between local hosts on the local network. Whether a packet is destined for a local host or a remote host is determined by the IPv4 address and subnet mask combination of the source (or sending) device compared to the IPv4 address and subnet mask of the destination device. Packet forwarding between different host as the role of the network layer. A host can send a packet to the following:
A host can ping itself by sending a packet to a special IPv4 address of 127.0.0.1, which is called a loopback address or loopback interface. Pinging the loopback interface tests the TCP/IP protocol stack on the host.
This is a host on the same network as the sending host. The hosts share the same network address. The host can accomplish 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 same IP network as the host device, the packet is simply forwarded out of the host interface, through the intermediate devices, and to the destination device directly.
This is a host on a different network. So these hosts do not share the same network address. In nearly all situations we want our devices to be able to connect beyond the local network. for example; out to other homes, businesses, and the Internet. Devices that have beyond the local network are known as remote hosts. When a source device sends a packet to a remote destination device, then the help of routers and routing is needed. Routing is the process of identifying the best path to a destination. The router connected to the local network is referred to as the default gateway.