IP FORWARDING

Internet routers and hosts (communally known as routing nodes) use IP addressto allow them to direct datagrams towards their destination. Routing nodes maintain forwarding tables (also called routing tables) that allow them to determine where best to direct a datagram that has arrived for forwarding. A router makes this decision solely using the network number field of the destination IP address as a key to look up the table. Each table entry corresponds to some network, A, and has the form:

network address    network mask    next hop    interface    metric

The fields are used as follows.

 

network  

the network address of A which may be classful or classless;

network mask  

the network mask for A ;

next hop  

the IP address which any packet trying to reach a destination on A should be sent to;

interface  

the IP number of the routing node's network interface on which a packet trying to reach a destination on A should be forwarded;

metric  

the number of hops to A;

 

In the case where A is a remote network (not a network to which the node has an interface), the next hop field is the IP address of the next router on the best route to A . If A is directly attached to the node, next hop is the same as interface, the IP address of the router’s own interface to A. In the former case, the node sends the datagram to the next router, sometimes called the gateway, while in the latter case, it sends it directly to its destination. The gateway in an entry for a remote network must of course be a router on a network which is directly attached to node.

When an IP packet arrives for routing the routing node extracts its destination IP address and compares it against each entry in the routing table. The address is bitwise-ANDed with the network mask and if the result matches the network address the entry is used to forward the packet. If more than one entry gives such a match, the one with the longer network mask is preferred. Thus if a packet with destination address 130.209.240.128 encounters entries

        130.209.0.0        255.255.0.0        ....

        130.209.240.0     255.255.240.0     ....

both give matches, but the second is preferred. Every routing table will contain a default route

0.0.0.0        0.0.0.0    ....

which matches every address and will catch any packet which cannot find a more specific entry, directing it to a default gateway on some directly attached network.

A typical host on an IP network has (for a given network  interface) an IP number, A, and a mask called a subnet mask, S, which defines the network it belongs to. A bitwise-AND of A and S (A & S) yields the network address of the local network. Given a default gateway, G, the host will construct a routing table including:

A host's routing table is usually static, fixed at its default state unless updated manually. A router's table on the other hand is dynamic, being constantly updated by interchanging routing information with neighbouring routers.

Exercise: You can use the Windows 2000 route command to view and edit a host's forwarding table.

Open a Command Prompt Window and type:

route print

This will display the forwarding table.

The command can also be used to add, delete or modify entries in the forwarding table. For details type:

route /?

This gives usage and examples allowing a user to change the forwarding table as desired.

Address Resolution Protocol

Once a forwarding decision has been made the IP packet is dispatched to the appropriate interface where it will be transmitted by the data-link (typically the MAC) layer (assume, for simplicity, that no fragmentation is required). To send a frame containing the datagram to its destination router or host, some way of determining the MAC address of this destination is needed. The problem is to determine the MAC address of the target, knowing its IP number. It is not feasible for each device to maintain a full address resolution table, containing mappings of IP to MAC addresses, for each network to which it is connected, because new hosts are frequently being added, and such a table would require constant updating.

This is solved by the address resolution protocol, ARP, which allows the sender to broadcast an ARP request packet, containing the IP address in question, to all other devices attached to the local network. Only the device that recognises its own IP number replies with an ARP response containing the required MAC address, resolving the query (Figure 1). To improve efficiency, however, it makes sense for each routing node to maintain an ARP cache, with a list of the most recent address resolutions.

 

Figure 1           Operation of address resolution protocol

 

Exercise: You can use the Windows 2000 arp view and edit a host's ARP cache

Open a Command Prompt Window and type:

arp -a

This will display the ARP cache.

The command can also be used to add, delete or modify entries in the arp cache. For details type:

arp /?

Windows 2000 uses a 2 minute lifetime for entries in the ARP cache. If an entry is referenced its lifetime is increased in 2 minute increments up to a maximum of 10 minutes whereupon the entry is deleted and must be rediscovered by another ARP request.