Tuesday, March 31, 2020

Dynamic Routing

As networks grow, the need to subnet them also grows too.  Eventually you will find that you have a lot of subnets that cannot all be tracked easily, especially if they are being managed by different network administrators.   In this complex situation, going around and asking everyone to update their routing tables would be impossible and would lead to all sorts of network confusions and headaches.

The solution to this problem is to use "Dynamic Routing".  The concept behind dynamic routing is that each router only knows its immediately adjacent networks when it starts up.  It then announces to other routers connected to it what it knows, and the other routers reply back with they know.  This is similar to "word of mouth" advertising for your network.  You tell the people around you about your network, they then tell their friends. and their friends tell their friends, and so on.  Eventually everyone connected to the network knows about your new network.

On campus-wide networks, like in a large corporate with many buildings, you will typically see this method of announcing route information.  The two most commonly used routing protocols are Routing Information Protocol RIP and Open Shortest Path First OSPF.

RIP is a simple protocol that is easy to configure.  Just tell the router information about one network, making sure that each subnet in the company has a connection to a router that knows about RIP, and then have the routers connected to one another.  RIP broadcasts happen at regular time intervals, usually less than a minute, and in only a few minutes the entire campus network knows about you.

Let us consider a scenario of four routers in a campus network.  Events happen in parallel but for simplicity we take it step by step:




As illustrated in this diagram, Router A would be told about 10.145.71.0/23 and about the default route to the company corporate network.  Router B would be told about 10.145.73.0/23, Router C would know about 10.145.75.0/23, and Router D about 10.145.77.0/24  .  At startup, each router's table looks like this:

                Router                    Table

                Router A                10.145.71.
                                                Gateway to the company corporate network
                Router B                10.145.73.
                Router C                10.145.75.
                Router D                10.145.77.

Router A then makes a broadcast stating what routes it knows about.  Since Router B and Router D are connected to it, they update their routes.  This makes the routing table look like:

                Router                    Table

                Router A                10.145.71.0/23
                                                Gateway to the company corporate network
                Router B                10.145.73.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A
                Router C                10.145.75.0/23
                Router D                10.145.77.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A

Router B then makes its broadcast.  Router A and Router C see these packets and update their tables, and now the updated routing table will be:

                Router                    Table

                Router A                10.145.71.0/23
                                                Gateway to the company corporate network
                                                10.145.73.0/23 through Router B
                Router B                10.145.73.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A
                Router C                10.145.75.0/23
                                                10.145.73.0/23 through Router B
                                                10.145.71.0/23 through Router B
                                                Gateway to the company corporate network through Router B
                Router D                10.145.77.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A

Router C then makes its broadcast, which Router B and Router D hear.  This is where things get interesting sinc ethis introduces enough information for multiple routes to get established for the same destination.  The routing tables now look like this:

                Router                    Table

                Router A                10.145.71.0/23
                                                Gateway to the company corporate network
                                                10.145.73.0/23 through Router B
                Router B                10.145.73.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A
                                                10.145.75.0/23 through Router C
                Router C                10.145.75.0/23
                                                10.145.73.0/23 through Router B
                                                10.145.71.0/23 through Router B
                                                Gateway to the company corporate network through Router B
                Router D                10.145.77.0/23
                                                10.145.71.0/23 through Router A or Router C
                                                Gateway to the company corporate network through Router A or Router C
                                                10.145.75.0/23 through Router C
                                                10.145.73.0/23 through Router C


Next, Router D makes its broadcast.  Router A and Router C hear this and update their tables, and the new routing tables now will be:

                Router                    Table

                Router A                10.145.71.0/23
                                                Gateway to the company corporate network
                                                10.145.73.0/23 through Router B or Router D
                                                10.145.75.0/23 through Router D
                                                10.145.77.0/23 through Router D
                Router B                10.145.73.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A
                                                10.145.75.0/23 through Router C
                Router C                10.145.75.0/23
                                                10.145.73.0/23 through Router B
                                                10.145.71.0/23 through Router B or Router D
                                                Gateway to the company corporate network through Router B or Router D
                                                10.145.77.0/23 through Router D
                Router D                10.145.77.0/23
                                                10.145.71.0/23 through Router A or Router C
                                                Gateway to the company corporate network through Router A or Router C
                                                10.145.75.0/23 through Router C
                                                10.145.73.0/23 through Router C


Once all the routers go through another round of broadcasts, the complete table would be:


                Router                    Table

                Router A                10.145.71.0/23
                                                Gateway to the company corporate network
                                                10.145.73.0/23 through Router B or Router D
                                                10.145.75.0/23 through Router D
                                                10.145.77.0/23 through Router D
                Router B                10.145.73.0/23
                                                10.145.71.0/23 through Router A
                                                Gateway to the company corporate network through Router A
                                                10.145.75.0/23 through Router C
                Router C                10.145.75.0/23
                                                10.145.73.0/23 through Router B
                                                10.145.71.0/23 through Router B or Router D
                                                Gateway to the company corporate network through Router B or Router D
                                                10.145.77.0/23 through Router D
                Router D                10.145.77.0/23
                                                10.145.71.0/23 through Router A or Router C
                                                Gateway to the company corporate network through Router A or Router C
                                                10.145.75.0/23 through Router C
                                                10.145.73.0/23 through Router C


Why is this mesh important ?  Let's say Router B fails.  If Router C was relying on Router B to send packets to the company corporate network, it can immediately update its tables, reflecting that Router B is no longer available, and then forward the company-bound packets through Router D.

Why RIP is generally less preferred over OSPF:
Unfortunately when it comes to figuring out the most optimal path from one subnet to another, RIP is not very smart.  Its method of determining which route to take is based on the fewest number of routers (hops) between itself and the destination.  Although that sounds optimal, what this algorithm does not take into account is how much traffic is on the link or how fast the link is.

Referring back to our diagram, we can see where this situation can lead us to.  Let us assume that the link between Router C and Router D becomes congested.  Now if Router C wants to send a packet out to the company network, RIP will still evaluate the tow possible paths i.e. Router C to Router D and Router C to Router B to Router A as being equidistant.  As a result the packet may end up going through Router D when, clearly the path through Router B whose links are not congested would be much faster.


OSPF is similar to RIP in how it broadcasts information to other routers.  What makes it different is that instead of keeping track of how many hops it takes to get from one router to another, it keeps track of how quickly each router is talking to the others.  Thus in our example, when the link between Router C and Router D becomes congested, OSPF will realize that and route the packets destined to Router A through Router B.

Another feature of OSPF is its ability ro realize when a destination address has two possible paths that would take an equal amount of time for throughput.  When it sees this, OSPF will share the traffic across both links --- a process called "equal-cost multipath" thereby making optimal use of available resources.

There are two drawbacks with OSPF.  Older networking hardware and some lower-end networking hardware may not have OSPF available or have it at a significant cost.  The second drawback is complexity: RIP is much simpler to set up than OSPF.  For a small network RIP may be a better choice.

No comments:

Post a Comment