Caching Technique Case Study
The cache is built from the routing table. In the scheme prior to CEF, the routing table is built when the routing protocol injects routes. Before a packet is forwarded, a process performs a lookup in the routing table and decides how the packet should be forwarded. Each entry in the routing table for the network is considered. An example of entries in the routing table is shown here: Show ip route
150.150.6.0/24 [20/30] via 150.150.5.31, 00:00:23, Fddi2/0
150.150.0.0/16 [20/10] via 150.150.5.31, 00:20:23, Fddi2/0
171.68.0.0/16 [20/40] via 131.108.5.31, 01:50:2, Serial 0/0
171.68.0.0/16 [20/40] via 131.108.5.10, 01:05:2, Serial 0/1
10.10.10.1/32 [110/1572] via 131.108.5.10, 01:5:23, Serial 0/1
10.0.0.0/8 [20/10] via 131.1.1.1, 01:5:11, Ethernet 3/1
204.10.0.0/16 [20/40] via 150.150.5.31, 00:20:23, Fddi2/0
204.10.10.1/32 [20/30] via 150.150.5.31, 01:20:23, Fddi2/0
0.0.0.0/0 [20/20] via 150.150.5.31, 00:20:23, Fddi2/0
In the show ip route output shown above, the router has nine routing entries in the routing table. The first two routing entries correspond with network 150.150.0.0. The first of the two is a subnet entry 150.150.6.0/24, and the second correlates to the major network 150.150.0.0/16. The next two entries correspond to major network 171.68.0.0/16. Following that, there are two entries for the 10.0.0.0 network; the first is a host route to 10.10.10.1/32, and the second is an entry corresponding to major network 10.0.0.0/8.
Next, there is a single entry for a CIDR block for 204.10.0.0/16. A host route to 204.10.10.1/32, which is a network out of the CIDR block range, follows. The final entry corresponds to the default route 0.0.0.0/0.
This example of an ip route explains how a Cisco router creates fast-switching cache entries, which is shown in a show ip cache. We will begin by looking at the entries for network 150.150.0.0. The router has two entries in the routing table—one for the major network of 150.150.0.0/16 and one for the subnet of 150.150.6.0/24. Because the longest prefix mask for this major net is /24 in the routing table, cache entries for any destination in 150.150.0.0 are created as /24. If you send a packet to a destination of 150.150.8.1, the entry will be cached as 150.150.8.0/24, even though the major network of 150.150.0.0/16 covers the route for this destination.
Now, consider the second case for the network 171.68.0.0/16. In this case, you have two equal cost paths to the network. In this instance, /32 host entries are cache.
There is a misconception that load sharing is performed per session. In actuality, load sharing is performed per destination. As an illustration, assume that a user wants to Telnet to 171.68.1.1. The router will cache 171.68.1.1/32 via one of the interfaces. All future packets to this destination will use this cache entry, so it will always be sent out the same interface. The host sending a packet through the router will make a connection to 171.68.1.1 TCP port number 23. If another user FTPs to the same host, 171.68.1.1, via this router, the router will use the newly created cache entry.
Although both users are connecting to the same destination, each session is different, but all packets take the same path that was created originally in the cache entry. This is the reason that load sharing is per-destination and not per-session in fast switching. Now assume that another user wants to connect to a different host on the same destination subnet. For example, if a third user wants to connect to 171.68.1.2, this will cause a second cache entry to be created through the second path, which is also a /32 entry. For this reason, cache entries during load sharing can become very large. The third entry in the routing table corresponds to network 10.0.0.0/8.The router has a /8 entry and a /32 entry in the routing table. Each entry in the routing table would be cached for network 10.0.0.0/32, although there are only two entries in the routing table for the network 10.0.0.0/8. All the entries for this network are created as /32. Remember from previous discussions that caching is always done on the longest prefix in the routing table for the same major network.
TIP
A good practice for ISPs is to avoid receiving a /32 route from the Internet. ISPs should use an access list to avoid routes with longer prefixes from being received from other ISPs or customers. The only /32 routes an ISP should have in its routing table are routes from its own autonomous system. Note that Cisco routers still cache a classful entry for a CIDR route unless you are using CEF.
The routing table shown in the previous example has an entry of 204.10.0.0/16 and 204.10.10.1/32—in this case, the caching for all the CIDR networks would be performed as a classful entry. If the router wanted to send a packet to the network 204.10.1.0/24, it would not cache this route as a /16 because no explicit entry exists for network 204.10.1.0/24, and because it is covered by 204.10.0.0/16.
The router also would not cache the route as a /32. Only entries for network 204.10.10.0 would be cached as /32 because a host route of 204.10.10.1/32 exists in the routing table. No other entry in the CIDR block of 204.10.0.0/16 would be cached as a /32.
Finally, the routes not found in the routing table will take the default route 0.0.0.0. All the entries would be cached as a classful mask. If, for example, the router needs to send a packet to the destination of 161.10.1.1, a cache entry would be created for network 161.10.0.0/16, not for 0.0.0.0/0.



