Network Routing Protocols and Methods, Part 2
Overview
This article takes the theory of how a dynamic routing protocol should work, bringing it into reality with two walkthroughs. The first walkthrough focuses on how Routing Information Protocol (RIP) works as a dynamic vector protocol. The second walkthrough shows how the Open Shortest Path First (OSPF) protocol works as a link-state protocol.
For these walkthroughs, we'll use the simple three-router topology shown in Figure 1.
Figure 1 Topology for the walkthroughs.
The following table shows the IP addresses assigned for this topology. This information is common to the walkthroughs for both RIP and OSPF.
Router |
Interface |
IP Address/Network |
R1 |
Loopback0 |
10.0.0.1/24 |
GigabitEthernet0/1 |
192.168.1.1/24 |
|
R2 |
GigabitEthernet0/1 |
192.168.2.1/24 |
GigabitEthernet0/2 |
192.168.1.2/24 |
|
R3 |
GigabitEthernet0/2 |
192.168.2.2/24 |
Loopback0 |
20.0.0.1/24 |
RIP Walkthrough
Since RIP is a distance vector protocol, it learns about routes when its neighbors advertise a copy of their routing tables. After receiving the routing tables, RIP combines this information with its own interfaces to form its own routing table. This information for RIP is initially stored inside the RIP database that can be viewed on each respective device. Listing 1 shows an abbreviated version of this database for R1:
Listing 1R1 RIP Database.
10.0.0.0/24 directly connected, Loopback0 20.0.0.0/24 [2] via 192.168.1.2, 00:00:25, GigabitEthernet0/1 192.168.1.0/24 directly connected, GigabitEthernet0/1 192.168.2.0/24 [1] via 192.168.1.2, 00:00:25, GigabitEthernet0/1
Here, R1 is showing that the 10.0.0.0/24 (Loopback0) and 192.168.1.0/24 (GigabitEthernet0/1) networks are directly connected, and two additional networks are located out the GigabitEthernet0/1 interface (toward R2). The routing table of R1 reflects this same information, as shown in Listing 2:
Listing 2R1 Routing Table.
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.0.0.0/24 is directly connected, Loopback0 L 10.0.0.1/32 is directly connected, Loopback0 20.0.0.0/24 is subnetted, 1 subnets R 20.0.0.0 [120/2] via 192.168.1.2, 00:00:17, GigabitEthernet0/1 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, GigabitEthernet0/1 L 192.168.1.1/32 is directly connected, GigabitEthernet0/1 R 192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:17, GigabitEthernet0/1
Keep in mind that neither of these tables tells you about the devices connected to the 192.168.2.0/24 or 20.0.0.0/24 networks. The same details are shown on R2 and R3 when viewing their RIP databases and routing tables in Listings 3–6.
Listing 3R2 RIP Database.
10.0.0.0/24 [1] via 192.168.1.1, 00:00:21, GigabitEthernet0/2 20.0.0.0/24 [1] via 192.168.2.2, 00:00:22, GigabitEthernet0/1 192.168.1.0/24 directly connected, GigabitEthernet0/2 192.168.2.0/24 directly connected, GigabitEthernet0/1
Listing 4R2 Routing Table.
10.0.0.0/24 is subnetted, 1 subnets R 10.0.0.0 [120/1] via 192.168.1.1, 00:00:09, GigabitEthernet0/2 20.0.0.0/24 is subnetted, 1 subnets R 20.0.0.0 [120/1] via 192.168.2.2, 00:00:11, GigabitEthernet0/1 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, GigabitEthernet0/2 L 192.168.1.2/32 is directly connected, GigabitEthernet0/2 192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.2.0/24 is directly connected, GigabitEthernet0/1 L 192.168.2.1/32 is directly connected, GigabitEthernet0/1
For R2, the only networks that are not directly connected are the Loopback0 interfaces of R1 and R3.
Listing 5R3 RIP Database.
10.0.0.0/24 [2] via 192.168.2.1, 00:00:23, GigabitEthernet0/2 20.0.0.0/24 directly connected, Loopback0 192.168.1.0/24 [1] via 192.168.2.1, 00:00:23, GigabitEthernet0/2 192.168.2.0/24 directly connected, GigabitEthernet0/2
Listing 6R3 Routing Table.
10.0.0.0/24 is subnetted, 1 subnets R 10.0.0.0 [120/2] via 192.168.2.1, 00:00:10, GigabitEthernet0/2 20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 20.0.0.0/24 is directly connected, Loopback0 L 20.0.0.1/32 is directly connected, Loopback0 R 192.168.1.0/24 [120/1] via 192.168.2.1, 00:00:10, GigabitEthernet0/2 192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.2.0/24 is directly connected, GigabitEthernet0/2 L 192.168.2.2/32 is directly connected, GigabitEthernet0/2
The R3 tables look like a mirror version of R1, with the R1 Loopback0 interface and the link between R1 and R2 being advertised by RIP. R3 is not aware of which device(s) are connected to these other networks—only that they can be located out its GigabitEthernet0/2 interface.
OSPF Walkthrough
Unlike RIP, which is a distance vector protocol, , OSPF is a link-state protocol. OSPF makes its routing decisions based on a database that provides a picture of which networks are located off of every router in the same link-state domain. As with RIP, this information is stored initially in a local OSPF database, which is used to determine the best path for each specific destination, based on Dijkstra's shortest path first (SPF) algorithm.
The first part of the OSPF database we'll examine is the overview. Listing 7 shows a high-level view of the entries in the database; it doesn't show the specific advertised networks.
Listing 7OSPF Database Overview.
OSPF Router with ID (1.1.1.1) (Process ID 10) Router Link States (Area 0) Link ID ADV Router Age Seq# Checksum Link count 1.1.1.1 1.1.1.1 95 0x80000002 0x0076C0 2 2.2.2.2 2.2.2.2 96 0x80000003 0x00025C 2 3.3.3.3 3.3.3.3 102 0x80000002 0x0076A2 2 Net Link States (Area 0) Link ID ADV Router Age Seq# Checksum 192.168.1.2 2.2.2.2 96 0x80000001 0x0009B0 192.168.2.2 3.3.3.3 102 0x80000001 0x003478
Listing 7 shows that three different OSPF routers are in the network, advertised as router link states using the router-ID (RID): 1.1.1.1 (R1), 2.2.2.2 (R2), and 3.3.3.3 (R3). The entry also shows two network link entries that advertise two transit networks. Transit networks are links where multiple OSPF devices exist; in this case, the link between R1 and R2 and the link between R2 and R3 are transit networks.
Listing 8 shows the router link-state entry for R1:
Listing 8R1 Router Link-State Entry.
OSPF Router with ID (1.1.1.1) (Process ID 10) Router Link States (Area 0) LS age: 165 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 1.1.1.1 Advertising Router: 1.1.1.1 LS Seq Number: 80000002 Checksum: 0x76C0 Length: 48 Number of Links: 2 Link connected to: a Stub Network (Link ID) Network/subnet number: 10.0.0.0 (Link Data) Network Mask: 255.255.255.0 Number of MTID metrics: 0 TOS 0 Metrics: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 192.168.1.2 (Link Data) Router Interface address: 192.168.1.1 Number of MTID metrics: 0 TOS 0 Metrics: 1
This entry contains some useful information. It shows that R1 is connected to a stub network (not a link with another OSPF router), which is connected to the 10.0.0.0/24 network. It's also connected to a transit network. The information for the network connected to this transit network is shown in a separate linked network link-state entry shown in Listing 9 (To find the correct link, look at the advertising router and link ID.)
Listing 9R1 Linked Network Entry.
LS age: 248 Options: (No TOS-capability, DC) LS Type: Network Links Link State ID: 192.168.1.2 (address of Designated Router) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0x9B0 Length: 32 Network Mask: /24 Attached Router: 2.2.2.2 Attached Router: 1.1.1.1
This entry shows that R1 is connected to a transit network that's connected to the 192.168.1.0/24 network.
Now take a look at the R2 router link entry in Listing 10:
Listing 10R2 Router Link Entry.
OSPF Router with ID (1.1.1.1) (Process ID 10) Router Link States (Area 0) LS age: 482 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 2.2.2.2 Advertising Router: 2.2.2.2 LS Seq Number: 80000003 Checksum: 0x25C Length: 48 Number of Links: 2 Link connected to: a Transit Network (Link ID) Designated Router address: 192.168.1.2 (Link Data) Router Interface address: 192.168.1.2 Number of MTID metrics: 0 TOS 0 Metrics: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 192.168.2.2 (Link Data) Router Interface address: 192.168.2.1 Number of MTID metrics: 0 TOS 0 Metrics: 1
This entry shows that R2 is connected to two different transit networks. As with the R1 entry, these transit networks can be linked to their respective entries, as shown in Listing 11:
Listing 11R2 Linked Network Entries.
OSPF Router with ID (2.2.2.2) (Process ID 10) Net Link States (Area 0) Routing Bit Set on this LSA in topology Base with MTID 0 LS age: 551 Options: (No TOS-capability, DC) LS Type: Network Links Link State ID: 192.168.1.2 (address of Designated Router) Advertising Router: 2.2.2.2 LS Seq Number: 80000001 Checksum: 0x9B0 Length: 32 Network Mask: /24 Attached Router: 2.2.2.2 Attached Router: 1.1.1.1 Routing Bit Set on this LSA in topology Base with MTID 0 LS age: 558 Options: (No TOS-capability, DC) LS Type: Network Links Link State ID: 192.168.2.2 (address of Designated Router) Advertising Router: 3.3.3.3 LS Seq Number: 80000001 Checksum: 0x3478 Length: 32 Network Mask: /24 Attached Router: 3.3.3.3 Attached Router: 2.2.2.2
These entries show that the two R2 connected transit networks are connected to the 192.168.1.0/24 and 192.168.2.0/24 networks, respectively.
Finally, let's take a look at the R3 router link entry in Listing 12:
Listing 12R3 Router Link Entry.
OSPF Router with ID (1.1.1.1) (Process ID 10) Router Link States (Area 0) LS age: 720 Options: (No TOS-capability, DC) LS Type: Router Links Link State ID: 1.1.1.1 Advertising Router: 1.1.1.1 LS Seq Number: 80000002 Checksum: 0x76C0 Length: 48 Number of Links: 2 Link connected to: a Stub Network (Link ID) Network/subnet number: 10.0.0.0 (Link Data) Network Mask: 255.255.255.0 Number of MTID metrics: 0 TOS 0 Metrics: 1 Link connected to: a Transit Network (Link ID) Designated Router address: 192.168.1.2 (Link Data) Router Interface address: 192.168.1.1 Number of MTID metrics: 0 TOS 0 Metrics: 1
Like the R1 router entry, this entry shows that R3 is connected to a stub network and a transit network. The stub network connects to the 20.0.0.0/24 network, and the transit entry can be linked to the entry shown in Listing 13:
Listing 13R3 Linked Network Entry.
Routing Bit Set on this LSA in topology Base with MTID 0 LS age: 779 Options: (No TOS-capability, DC) LS Type: Network Links Link State ID: 192.168.2.2 (address of Designated Router) Advertising Router: 3.3.3.3 LS Seq Number: 80000001 Checksum: 0x3478 Length: 32 Network Mask: /24 Attached Router: 3.3.3.3 Attached Router: 2.2.2.2
This entry shows that R3 is connected to a transit network that is connected to the 192.168.2.0/24 network.
When you combine all of this information, you get a view of how the network is seen by OSPF. The protocol is able to get a complete list of all the networks that are inside the OSPF domain and make forwarding decisions based on this full view. (This view can be restricted as well, with other features not discussed in this article.)
Obviously, walking through the OSPF database is quite a bit more confusing then walking through the RIP database. The way that OSPF organizes information is intended to be efficient for the protocol—not necessarily for the viewing engineer. Although this article picks out the specific linked entries that match with the specific devices in the network, it's important to remember that all of these entries exist in the OSPF database of all routers in the OSPF domain (by default). Differentiating which entry links with which router is a matter of tracing the RIDs and networks, which is well outside the scope of this article.
To bring the OSPF portion of this article together, let's look at the routing tables of the routers in Listings 14–16, to see how this information contained within their databases is translated once OSPF has a chance to calculate the best routes to insert.
Listing 14R1 Routing Table.
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.0.0.0/24 is directly connected, Loopback0 L 10.0.0.1/32 is directly connected, Loopback0 20.0.0.0/24 is subnetted, 1 subnets O 20.0.0.0 [110/3] via 192.168.1.2, 01:04:32, GigabitEthernet0/1 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, GigabitEthernet0/1 L 192.168.1.1/32 is directly connected, GigabitEthernet0/1 O 192.168.2.0/24 [110/2] via 192.168.1.2, 01:08:50, GigabitEthernet0/1
Listing 15R2 Routing Table.
10.0.0.0/24 is subnetted, 1 subnets O 10.0.0.0 [110/2] via 192.168.1.1, 01:04:07, GigabitEthernet0/2 20.0.0.0/24 is subnetted, 1 subnets O 20.0.0.0 [110/2] via 192.168.2.2, 01:04:07, GigabitEthernet0/1 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, GigabitEthernet0/2 L 192.168.1.2/32 is directly connected, GigabitEthernet0/2 192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.2.0/24 is directly connected, GigabitEthernet0/1 L 192.168.2.1/32 is directly connected, GigabitEthernet0/1
Listing 16R3 Routing Table.
10.0.0.0/24 is subnetted, 1 subnets O 10.0.0.0 [110/3] via 192.168.2.1, 01:04:39, GigabitEthernet0/2 20.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 20.0.0.0/24 is directly connected, Loopback0 L 20.0.0.1/32 is directly connected, Loopback0 O 192.168.1.0/24 [110/2] via 192.168.2.1, 01:09:23, GigabitEthernet0/2 192.168.2.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.2.0/24 is directly connected, GigabitEthernet0/2 L 192.168.2.2/32 is directly connected, GigabitEthernet0/2
Summary
While this article (especially the OSPF portion) could be a bit confusing, you must remember that this is how the databases look in a very simple network. Imagine what they look like in a larger network! Keep in mind that many network engineers don't completely understand the contents of these tables; they're able to get through their work by using this information combined with network documentation and other observed configuration on the devices.
In reading through this article (possibly multiple times), you should get an idea of how distance vector and link-state protocols differ in their view of the network and how they make their decisions.