Basic of IP Routing Explained with Example

This tutorial explains the basic concepts of IP routing. Learn what IP routing is, how IP routing works, and how computer networks use IP routing.

What is IP routing?

IP routing is a process that an IP host uses to transfer data to another IP host in an 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.

different ip subnets

How does IP routing work?

The process of IP routing starts when the host creates the IP packet for another host. Once an IP packet is created for another host, the host takes the following steps.

The host determines the IP subnet of the destination host.

To determine the IP subnet of the destination host, the host compares the address of the destination host to its address.

If the network address is the same in both addresses, both addresses belong to the same IP subnet. If the network address is different in both addresses, both addresses belong to different IP subnets.

The following image shows an example of this comparison.

host logic to determine destination network

If the destination host belongs to the same IP subnet, the host sends the packet to the destination host directly. 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. We will discuss both cases separately. Let's start with the first case.

If the destination host belongs to the same IP subnet, the host takes the following steps.

The host finds the MAC address of the destination host. To find the MAC address of the destination host, it uses the ARP protocol.

Before we move to the next step, let’s briefly discuss how ARP protocol works.

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 IP address of the destination host. A broadcast address belongs to all hosts of the LAN network. All hosts receive the ARP message and examine the message to find out whether the message is intended 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 MAC address of the destination host. Since the destination host sends the reply message to the broadcast address, all hosts of the LAN network receive the reply message. From the reply message, the first host learns the MAC address of the destination host.

The host encapsulates the IP packet with the MAC address of the destination host in a data-link frame and sends the frame 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 the destination host processes the IP packet and transfers the packet's data to the corresponding application for further processing.

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 MAC address of the destination host 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 that is connected to the 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 transfers the packet to the interface that is connected to the destination network.

If the interface is directly connected 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 the 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 inside the frame, decides where to forward the packet, puts the packet into 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 checks the condition of the frame. If the frame contains no error, it de-encapsulates the frame and extracts the packet from the frame. 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.

The following image shows how IP routing works.

how ip routing works

To view the full resolution image, right-click the image and click the option 'Open Image in New Tab'.

The entire process of IP routing is controlled by two types of protocols: routed protocols and routing protocols. The following tutorial explains both types in detail.

Routed, Routable, and Routing Protocols

That’s all for this tutorial. In this tutorial, we discussed the basic concepts of IP routing and learned how IP routing works in a computer network.

ComputerNetworkingNotes CCNA Study Guide Basic of IP Routing Explained with Example