Skip to content
Skip to main content

About this free course

Download this course

Share this free course

Protocols in multi-service networks
Protocols in multi-service networks

Start this free course now. Just create an account and sign in. Enrol and complete the course for a free statement of participation or digital badge if available.

3.5.2 IP forwarding

At the internetwork layer, forwarding is based on the network address part of the IPv4 address. Two basic forms of forwarding are carried out by a router or host – direct and indirect. Direct forwarding takes place where the destination IPv4 address is on a network attached to the router or host. Indirect forwarding takes place where the destination IPv4 address is not on a network connected to the router or host, and the datagram therefore has to be forwarded to a router further along the path through the internetwork. Where a router is connected to several networks, forwarding is more complicated than in the case of hosts, which are typically connected to a single network. Figure 23 shows a simple internetwork in which we can look at examples of direct and indirect forwarding.

Figure 23
Figure 23 Direct and indirect forwarding

In Figure 23 there are four networks forming part of an internetwork. The IPv4 addresses are class B and the network addresses are given in the figure. Each of hosts A to J has a connection to only one network and their IP addresses can be found by prefixing the network addresses to the host addresses shown in the figure. For instance, the full address for host B is and that for host G is The router labelled R1 is connected to three networks, whereas router R2 is connected to only two. In each case the interface to each network has a separate IPv4 address.

Suppose that host B sends a datagram to host C. Assume that host B knows the IP address of host C ( and from this it knows that C is on the same network as itself. This means that B can invoke the services of its host-to-network layer to deliver the datagram.

Now suppose that host A wishes to send a datagram to host J. Assume that A knows the IPv4 address of the destination host J ( but this time from the address it knows that it does not have a direct connection to J. Host A therefore has to forward the datagram to a router. The actual delivery of the datagram is one of the functions performed by the host-to-network layer. The forwarding information is stored in a data structure called a. forwarding table. In this example the forwarding table for host A would be very simple, as is shown in Table 7. Note that the destination address (J) in the IP datagram is not changed.

Table 7: Forwarding table for host A
Network addressDirect/IndirectRouterInterface number

Host A forwards datagrams directly if they are addressed to network 128.20, or indirectly via router R1 if they are addressed to any of the other networks.

Table 8 shows the forwarding table for router R1. In this case, R1 has direct connections to three networks (128.20, 128.30, 128.40) and an indirect connection, via router R2, to the fourth network (128.50).

Table 8: Forwarding table for router R1
Network addressDirect/IndirectRouterInterface number

To give you some idea of scale, some routers in the Internet have forwarding tables containing of the order of 50000 entries. In practice, hosts and routers do not have entries for all network addresses and a default router may be specified for those network addresses that are not recognised. In addition, several network addresses that have the same interface may be amalgamated into a single entry by a process called route aggregation. This is discussed in more detail in the next section under the topic of forwarding equivalence classes. A datagram is discarded if it has a destination network address for which no entry appears in the forwarding table and if there is no default entry in the forwarding table.

For the host-to-network layer to deliver the datagram, the host must know the physical address of the destination host. The physical address is not the same as the IP address because different networks have different addressing schemes for identifying systems. For instance, terminals connected to an Ethernet LAN are given addresses by the manufacturer and these addresses do not change if the terminals are transferred to different LANs. How a host gets the physical address on a LAN is the topic of the next section. Other protocols exist for other types of network.