Basic of IP Routing Explained with Example
IP routing allows IP hosts to exchange data within the IP network. An IP network may use a single IP subnet or multiple IP subnets. If two hosts belong to the same IP subnet, they can exchange data directly. If two hosts belong to different IP subnets, they need a router to exchange data. A router connects different IP subnets.
How does IP routing work?
The IP routing process begins when a host creates an IP packet for another host. After creating the IP packet, the host takes the following steps.
The host determines the destination host's IP subnet.
To determine the IP subnet of the destination host, the host compares the destination host's address to its own.
If the network address is the same in both addresses, both addresses belong to the same IP subnet. If the network addresses differ, the addresses belong to different IP subnets.

If the destination host is on the same IP subnet, the host sends the packet directly to it. If the destination host belongs to a different IP subnet, the host sends the packet to the default gateway. IP routing works differently in both cases.

IP routing in the same subnet
If the destination host belongs to the same IP subnet, the host takes the following steps.
The host finds the destination host's MAC address. To see the MAC address of the destination host, it uses the ARP protocol.
Fundamentals of the ARP protocol
If a host knows the IP address of the destination host but does not know the MAC address of the destination host, it sends an ARP message to the broadcast address of the local network. This ARP message contains the destination host's IP address. All hosts on a LAN use a broadcast address. All hosts receive the ARP message and examine it to determine whether it is for them. When the destination host finds its IP address in the ARP message, it sends a reply message to the broadcast address. The reply message contains the destination host's MAC address. Since the destination host sends the reply message to the broadcast address, all hosts on the LAN receive it. From the reply message, the first host learns the destination host's MAC address.
The host encapsulates the IP packet with the destination host's MAC address in a data-link frame and sends it to the destination host. The destination host receives the frame and checks the frame condition.
If the frame contains no error, the destination host de-encapsulates it to extract the IP packet.
Since the IP packet belongs to the destination host, the IP protocol running on that host processes the IP packet. It transfers its data to the corresponding application for further processing.
IP routing in different subnets
If the destination host belongs to a different IP subnet, the host takes the following steps.
The host finds the MAC address of the default gateway. To find the MAC address of the default gateway, it uses the ARP protocol.
The host encapsulates the IP packet with the default gateway's MAC address in a data-link frame and sends the frame to the default gateway.
The default gateway router receives the frame and checks the frame condition. If the frame contains no error, the gateway router de-encapsulates the frame and extracts the IP packet. The gateway router checks the destination address of the IP packet and makes a routing decision. To make a routing decision, the router uses the routing table. A routing table entry contains a network address and the name of the interface connected to that network.
If the router finds no entry for the destination network, it discards the packet. If the router finds an entry for the destination network, it forwards the packet to the interface connected to that network.
If the interface has a direct connection to the destination network, the interface encapsulates the packet in a data-link frame and forwards the frame to the destination network.
If the interface is connected to a router (next-hop) that knows how to reach the destination network, the interface encapsulates the packet in a data-link frame and forwards the frame to the next-hop router.
The next-hop router repeats the same process. The next-hop router receives a frame, removes the packet from the frame, decides where to forward the packet, encapsulates the packet in another frame, and sends the frame to the next-hop router. The last router on the path forwards the frame to the destination network.
The destination host on the destination network receives the frame and inspects it. If the frame contains no errors, it de-encapsulates the frame and extracts the packet. The IP protocol running on the destination host processes the IP packet. It extracts data from the packet and transfers it to the corresponding application for further processing.

To view the full-resolution image, right-click the image and select 'Open Image in New Tab'.
Conclusion
IP routing is a fundamental process that enables communication between IP devices in the same and different subnets in an IP network. If hosts are in the same subnet, they can communicate directly. If they are in different IP subnets, they need a router or a series of connected routers. IP routing enables communication and ensures efficient and accurate data transmission across different networks.
Author Laxmi Goswami Updated on 2025-12-05