When RIP starts on a switch, the RIP routing table on the switch contains only direct routes. Neighboring switches on different network segments can communicate with each other only after they learn routing entries from each other.
Figure 1 shows the process of generating a RIP routing table.
RIP updates and selects routes through route advertisements. In this situation, switches do not know the entire network topology and just know the distances to destination networks and the direction or interface used to reach destination networks. In Figure 2, SwitchB receives a route advertisement from SwitchA and knows that it can reach the network 192.168.1.0/24 through SwitchA with the hop count 1. Even though information contained in this advertisement becomes incorrect, SwitchB still considers that it can reach the network 192.168.1.0/24 through SwitchA with the hop count 1. This is the root cause for routing loops on a RIP network.
In RIP, the default hop count from a device to its directly connected network is 0, and the hop count from a device to a reachable network through another device is 1. That is, the hop count (the metric) equals the number of devices along the path from the local network to the destination network.
In Figure 3, S1 has two paths to the network segment 192.168.10.0/24:
One path is S1-S2-S5, passing through two devices: S2 and S5. It has a hop count of 2 and bandwidth of 1.544 Mbit/s.
The other path is S1-S3-S4-S5, passing through three devices: S3, S4, and S5. It has a hop count of 3 and bandwidth of 1 Gbit/s.
As required by the RIP metric standards, packets will be forwarded along the path passing through S2; however, the link bandwidth of this path is not the highest. This causes low bandwidth efficiency on the RIP network and hinders QoS management.
To prevent the hop count from becoming infinite when RIP routes are flooded indefinitely on the network, and to limit the convergence time, RIP allows a maximum of 15 hops. A hop count of 16 or greater is defined as infinity, making the destination network or host unreachable. This design limits the network scale that RIP supports. Therefore, RIP is not suitable for large-scale networks.
RIP uses three timers to update and maintain routing information:
Update timer
When this timer expires, a RIP device immediately sends an Update packet.
Age timer
If a RIP device does not receive any Update packet of a route from a neighbor within the Age timer, the RIP device considers this route unreachable.
Garbage-collect timer
If a RIP device does not receive any Update packet of an unreachable route within the Garbage-collect timer, the device deletes this route from its RIP routing table.
The interval for sending Update packets is determined by the Update timer, which is 30 seconds by default.
Each routing entry has two timers: Age timer and Garbage-collect timer. When a RIP device adds a learned route to the local RIP routing table, the Age timer starts for the route. If the RIP device does not receive an Update packet from the neighbor within the aging time, the RIP device sets the Cost value of the route to 16 (unreachable) and starts the Garbage-collect timer. If the RIP device still does not receive an Update packet within the Garbage-collect timer, the RIP device deletes the route from the RIP routing table.
When routing information changes, a device immediately sends an Update packet to its neighbors without waiting for the Update timer to expire. This function prevents routing loops.
Figure 4 shows the process of triggering a route update.
SwitchC first learns that network 10.4.0.0 becomes unreachable.
If SwitchC does not support triggered route update when detecting a network fault, it must wait until the Update timer expires. Before this timer expires, if SwitchC receives an Update packet from SwitchB, it learns an incorrect route to network 10.4.0.0. In this case, SwitchB and SwitchC are each other's next hop to network 10.4.0.0. This results in a routing loop.
If SwitchC supports triggered route update when detecting a network fault, it immediately sends to SwitchB an Update packet, preventing a routing loop.