# IP forwarding algorithm

## Learning goals

1. review the definition and concept of an IP network
2. understand that IP routing works on the level of IP networks
3. understand the concept of subnetting
4. review network classes and understand classless inter domain routing.

## Script

Internet Protocol Forwarding Algorithm

Let’s assume that you are connected to the Internet. You have a computer with IP Address 67.68.50.1 and this computer is in the 67.0.0.0-network (you can identify this from the 1-st number of IP Address as it’s an A-class). There is special computer in this network – the router with IP Address 67.68.50.13. This computer has 3 other network interfaces or network cards:
- 62.206.17.3 (part of 62.0.0.0)
- 88.41.79.55 (part of 88.0.0.0)
- 141.71.30.6 (part of 141.71.0.0)
We are interested in the 141.71.0.0 – network. Because this network has another router – 141.71.30.58. But as the first router it has other network devices which are connected to other networks. The network of particular interest is 205.34.55.0 – network which is a C-class network. In this network is a destination computer you want to send data later – 205.34.55.1.
Let’s see how we can forward data from 67.68.50.1-computer to 205.34.55.1-computer.
What you need for this is IP routing and routing tables.
Wherever the package arrives at the router, the router needs to decide whether this package needs to stay at this network and be delivered to some host there or it has to be passed to the next network. In order to make this decision router maintains the routing table.
Let’s look at 67.68.50.1-computer. It also has a routing table because each device on the Internet has to have a routing table:

Destination network next hop interface
67.0.0.0 67.68.50.1 eth0
0.0.0.0 67.68.50.13 eth0

The first entry says that the destination network is 67.0.0.0 and the entry for the next hop is device’s IP address and interface is Ethernet eth0 that is a network card for this device. The other entry has the destination network 0.0.0.0 that means that this is the default rout and the destination for the next hop will be 67.68.50.13. It means that whatever package is sent that is not for 67.0.0.0 network and what the computer will do is it will assemble an Ethernet frame that goes to 67.68.50.13-computer. These computers are in the same network so it’s obligatory to know the MAC Address of that computer (67.68.50.1). But there is another protocol – the Address resolution protocol that resolves this problem. But then computer can assemble an Ethernet frame and use the MAC Address of 67.68.50.13-computer and put it in the IP-package for other network that is supposed to be sent. All this will happen as the Internet protocol package inside the Ethernet package.
Lets’ have a look at another routing table. We have a 67.68.50.13-computer and it has several network interfaces.

Destination network next hop interface
67.0.0.0 67.68.50.1 eth0
62.0.0.0 62.209.17.3 eth1
88.0.0.0 88.41.79.55 eth2
141.71.0.0 141.71.30.6 eth3
205.44.55.0 141.71.30.58 eth3
26.0.0.0 141.71.30.58 eth3

Here we have the entrance for the next hop to each network and the interface to send out data (for the first 4 entries). But what we also have is the address of some other networks. So if we have a package and it comes from the anywhere to the 26.0.0.0 – network, the routing table will say that the next stop will be 141.71.30.58 IP Address. We can see that computer can maintain the table for almost all networks that exist that’s why we need hierarchical classfull network addresses and can make routing decisions to forward packages.
Let’s see an example.
67.68.50.1-computer’s routing table:

Destination network next hop interface
67.0.0.0 67.68.50.1 eth0
0.0.0.0 67.68.50.13 eth0

You have to send your package to 67.68.50.13-computer. So you do ARP request (Address Resolution Protocol) and the computer answers with it’s MAC Address. We assemble Ethernet frame and send it to that computer (67.68.50.13). Inside this frame you put an IP package and there is the source IP Address and the destination IP Address inside and of course the data. The computer starts to read the IP header and sees that this package is supposed to be send to 205.34.55.1-computer.

Destination network next hop interface
67.0.0.0 67.68.50.1 eth0
62.0.0.0 62.209.17.3 eth1
88.0.0.0 88.41.79.55 eth2
141.71.0.0 141.71.30.6 eth3
205.44.55.0 141.71.30.58 eth3
26.0.0.0 141.71.30.58 eth3

The computer looks inside his routing table and sees the entrance for 205.44.55.0. So it forwards package to the next stop - 141.71.30.58. The new Ethernet frame is assembled. The IP package doesn’t change but you exchange the Ethernet header. Again you forward package to the next computer.
The next computer device receives the package and the network device with the 205.34.55.0 – network. So it already knows where to forward the package. It does the ARP request and the computer-destination can finally read the data.
--Jane Kruch (discusscontribs) 21:51, 2 November 2013 (UTC)

## Quiz

1

Read the following article on Classless Inter-Domain Routing. Which are valid entries in a routing table?

with CIDR without CIDR
11.0.0.0
12.3.1.1
192.162.2.0
192.162.0.0
14.31.0.0
14.31.0.1

2

CIDR is backward compatible

 yes no it depends on the size of the routing table Only for entries in the routing table that go through class A and B networks

3

A network device from a class A network receives an IP package with the destination IP address in a class B network. Which of the following is true?

 The package will be send back to the source since no routing from class A to class B networks is possible The package will be dropped since no routing from class A to class B networks is possible If a route to the network of the destination adress exists the package will be routed. If no route to the destination network exists the package will be send to the default route. If the package cannot be routed there will be a forwarding error message send to the source.

4

An IP package is sent from host A to Z. It is being routed via B, C and D. Now network D cannot forward the package. Which of the following is true?

 There will be an error send back to A. The route will be exactly via C and B. There will be an error send back to A. The route is not quite clear. A will certainly receive an error message that the package could not be forwarded.