12.2 How are routing decisions made?
In this section you will have a look at how a router makes its routing decisions, using the same demonstration network made in Packet Tracer as you used in the previous section, and running in simulation mode to show you what the packets are doing at each stage.
Watch the video below, which is about 4 minutes long.
How are routing decisions made?
In order to demonstrate how the router makes its routing decision, we will use the same demonstration network we have used in the previous demonstrations.
This time we will use a ping from PC0 to PC1. We will ignore what happens in the internet router at first, and just look at the decisions made by Router0. As the ICMP packet comes in from the internet router it will have the destination IP address of 192.168.0.10 in its Internet layer header. The destination IP address in the packet is 192.168.0.10. The routing table contains entries for the connected networks of 172.16.0.0/24, 192.168.0.0/24 and also the 188.8.131.52/30 network in which the packet came in from. Note that each connected network shows up twice, one with the code of C which is the network it is on, and one with the code of L – which is the exact IP address of the router’s port. Note also that there is an entry marked S* at the end of the list. We will come back to this in a moment.
Now, back to the routing decision. The router will look at the destination address of the packet, in this case 192.168.0.10, and compare this address with the addresses in the routing table. The router will try and match the address with the entries in the routing table. If it finds multiple matches it will choose the best match – the one with the most bits matched will be selected. In this case there is a match with the network 192.168.0.0/24, which is on GigabitEthernet0/0. The packet will now be sent out of this interface and on to the switch, which will then send it on to PC1. PC1 will then respond with an echo-reply, which will have the source address of itself, and the destination of 10.0.0.10, which was the source of the echo request in the first place. When Router0 receives this packet it will look for 10.0.0.10 in its routing table. As you can see, there is no entry for any 10.0.0.0 network in this routing table. If the router does not find any match, it should drop the packet completely. This would cause the ping to fail and is not a very desirable outcome. We could either fix this by putting static routes into the routing table for all networks we wish to reach, or we can put a default route into it. This default route would then direct any traffic for networks not in the routing table to a valid destination. This default route has already been put into the routing table and is the entry with the code of S* we mentioned earlier in this presentation. This S* entry will also be listed above the routing table as the gateway of last resort when you do a show ip route.
So, back to our ping packet. There is no match for 10.0.0.0 in the routing table so the router will use the default route, which will send the packet out of GigabitEthernet0/2, which points towards the internet router. The ping will now continue on its journey to PC0. Now let’s have a quick look at the command prompt output which has happened while we were watching our ping packets going from the source to the destination and back. The first three ping packets have in fact failed, and the fourth one has succeeded. You should be able to guess why this happened. Think further back in this session to the ARP problem. The reason for the first failures is because the ARP process needed time to obtain all the MAC addresses for each section of the network – so PC0 needs to find the internet router’s MAC address, the internet router needs to find R0’s mac address, R0 needs to find PC1’s MAC address. This all takes time and means that some pings may be dropped. Remember we told you that these MAC addresses are cached for a period of time. This can be proved when you execute the ping again soon after. This time all four pings pass.
Activity 2 Test yourself
1. What component of the router’s system does the router use to decide which port to send the data packet out from?
(a) ARP table
(b) MAC address table
(c) Routing table
(d) Default gateway
The correct answer is c.
2. What does a router do with any packet it cannot find a destination network for in its routing table?
(a) Sends it out of all ports.
(b) Creates a new route.
(c) Returns the packet to the sender.
(d) Drops the packet.
The correct answer is d.
Correct. Routers should drop a packet if there is no matching destination network – unless there is a default static route set up.
3. Why do the first few ping packets fail when you ping an IP address you haven’t pinged recently?
(a) The layer 2 address (MAC address) is not present in the ARP table and must be looked up by the ARP process; this takes time, so the first few packets will fail.
(b) The router doesn’t know where to send the packet and takes too long to decide.
(c) The destination device is busy at the time.
(d) The router was switched off at the time.
The correct answer is a.
Activity 3 Try it out
1. Openin a new tab or window so you can read these instructions. A ‘spare’ PC is provided at the bottom for use in step 4 of this activity.
Investigate the network and enter the configuration settings into a copy of the table.
|Device||Interface||IP address||Subnet mask||Default gateway|
2. Check to see if there is a gateway of last resort set on each router. If there is, make a note of each one. (Hint: use the command show ip route.)
3. Ping PC1 from PC0. What happened?
4. Connect an additional PC (PC2) to the switch on the network 192.168.8.1 and configure it with an appropriate IP address, subnet mask and default gateway. (Use the spare PC provided at the bottom for this.)
5. Ping PC0 from PC2. What happened?
1. On both routers the command show ip interface brief should have given you the IP address of each configured interface. (It will also have given you the status of the configured interfaces which should have been ‘up’). To check the IP addresses and default gateway for each of the PCs you can use the command ipconfig. This is what your table should have looked like.
|Device||Interface||IP address||Subnet mask||Default gateway|
2. To show the gateway of last resort of each router, you need to use the command show ip route. You should have discovered that for both routers, the gateway of last resort was g0/0.
3. When pinging PC1 from PC0 you may have found that the first two or three pings timed out. As you learned in this session, this is because the ARP process needs time to ascertain all MAC addresses for each section of the network.
4. A suitable IP address for PC2 would have been anything in the range 184.108.40.206 to 220.127.116.11, but a logical choice would be 18.104.22.168.
5. When pinging PC0 from PC2 you may again have found that the first two or three pings timed out for the reason given above.
Activity 4 Think about
As you learned in the video ‘How are routing decisions made?’, configuring a static route by setting a router’s gateway of last resort is one way of ensuring that a packet doesn’t get dropped when its destination address isn’t in a router’s routing table. This is how the network in Activity 3 was configured, with each router using the other one as its gateway of last resort. This isn’t an ideal solution though. Can you see why?
It is possible that a packet could arrive at the router with an IP address that neither router knew anything about. In this event, the packet could end up going backwards and forwards between the routers until it is eventually discarded as it reaches its maximum number of hops specified in its ‘time to live’.