Saturday, February 25, 2012

Static Routing vs. Dynamic Routing


For routing between routers to work efficiently in an internetwork, routers must have knowledge of other network IDs or be configured with a default route. On large internetworks, the routing tables must be maintained so that the traffic always travels along optimal paths. How the routing tables are maintained defines the distinction between static and dynamic routing.
Static routing is not really a routing protocol. Static routing is simply the process of manually entering routes into a device’s routing table via a configuration file that is loaded when the routing device starts up. As an alternative, these routes can be entered by a network administrator who configures the routes manually. Since these manually configured routes don’t change after they are configured (unless a human changes them) they are called ‘static’ routes.
Static routing is the simplest form of routing, but it is a manual process.
Use static routing when you have very few devices to configure (<5) and when you know the routes will probably never change.
Static routing also does not handle failures in external networks well because any route that is configured manually must be updated or reconfigured manually to fix or repair any lost connectivity.

Advantages of Static Routing
Static routing has some enormous advantages over dynamic routing. Chief among these advantages is predictability. Because the network administrator computes the routing table in advance, the path a packet takes between two destinations is always known precisely, and can be controlled exactly. With dynamic routing, the path taken depends on which devices and links are functioning, and how the routers have interpreted the updates from other routers.
Additionally, because no dynamic routing protocol is needed, static routing doesn’t impose any overhead on the routers or the network links. While this overhead may be minimal on an FDDI ring, or even on an Ethernet segment, it could be a significant portion of network bandwidth on a low-speed dial-up link. Consider a network with 200 network segments. Every 30 seconds, as required by the RIP specification, the routers all send an update containing reachability information for all 200 of these segments. With each route taking 16 octets of space, plus a small amount of overhead, the minimum size for an update in this network is over three kilobytes. Each router must therefore send a 3 Kb update on each of its interfaces every 30 seconds. As you can see, for a large network, the bandwidth devoted to routing updates can add up quickly.
Finally, static routing is easy to configure on a small network. The network administrator simply tells each router how to reach every network segment to which it is not directly attached. Consider the network shown in Figure 5-1. This network has three routers connecting five network segments together. Clearly, the only path from Router1 to a host on 172.16.3.0/24 goes through Router2. Likewise, the only path to hosts on subnet 172.16.4.0/24 goes through Router3.
 A small network using static routing A small network using static routing
Here are the relevant fragments of the configurations of these three routers using static routing. Note that each router configuration must contain a static route for the networks attached to the other routers, but not those directly attached to the router itself.
Configuration for Router1:
hostname router1
!
interface ethernet 0
ip address 172.16.1.1 255.255.255.0
!
interface ethernet 1
ip address 172.16.2.1 255.255.255.0
!
ip route 172.16.3.0 255.255.255.0 172.16.1.2
ip route 172.16.4.0 255.255.255.0 172.16.1.2
ip route 172.16.5.0 255.255.255.0 172.16.1.2

Configuration for Router2:
hostname router2
!
interface ethernet 0
ip address 172.16.1.2 255.255.255.0
!
interface ethernet 1
ip address 172.16.3.1 255.255.255.0
!
interface ethernet 2
ip address 172.16.5.1 255.255.255.0
!
ip route 172.16.2.0 255.255.255.0 172.16.1.1
ip route 172.16.4.0 255.255.255.0 172.16.3.2

Configuration for Router3:
hostname router3
!
interface ethernet 0
ip address 172.16.3.2 255.255.255.0
!
interface ethernet 1
ip address 172.16.4.1 255.255.255.0
!
ip route 172.16.1.0 255.255.255.0 172.16.3.1
ip route 172.16.2.0 255.255.255.0 172.16.3.1
ip route 172.16.5.0 255.255.255.0 172.16.3.1
Each configuration starts by giving the router a name, and then defines an IP address and subnet mask for each of the router’s interfaces. For example, on Router2, the second Ethernet interface (ethernet 1) is assigned the IP address 172.16.3.1, and the netmask 255.255.255.0. Similar commands defining addresses and netmasks for local interfaces will appear in all router configurations, regardless of whether a router is participating in a dynamic routing protocol. If the configurations stopped here, each router would have entries in its routing table for the networks attached to its own interfaces, and no others. But the configurations go on to define static routes showing how to reach networks attached to the other routers. Each ip route statement defines a static route to the destination indicated by the network number and mask by way of the router IP address listed. For example, the first ip route statement in Router3′s configuration defines a route to 172.16.1.0, with a mask of 255.255.255.0 (172.16.1.0/24) via the router at 172.16.3.1. The static routes, together with the the local interfaces, let each router populate its routing table with information about each destination and the next hop to reach it.
While this small network doesn’t require many static routes to achieve complete connectivity, and Router1 and Router3 could get by with static default routes pointing to Router2, it is easy to see that the configurations for a large network with hundreds of network segments and routers would be very complex.

And the Disadvantages of Static Routing
While static routing has advantages over dynamic routing, it is not without its disadvantages. The price of its simplicity is a lack of scalability. For five network segments on three routers, computing an appropriate route from every router to every destination is not difficult. However, many networks are much larger. Consider what the routing might look like for a network with 200 network segments interconnected by more than a dozen routers. To implement static routing, you would need to compute the next hop for each network segment for each router, or more than 2,400 routes! As you can see, the task of precomputing routing tables quickly becomes a burden, and is prone to errors.
Of course, you could argue that this computation need only occur once, when the network is first built. But what happens when a network segment moves, or is added? While the computation may be relatively easy, to implement the change, you would have to update the configuration for every router on the network. If you miss one, in the best case, segments attached to that router will be unable to reach the moved or added segment. In the worst case, you’ll create a routing loop that affects many routers.
Finally, because static routing is, by definition, static, it cannot use redundant network links to adapt to a failure in the network. Consider what would happen to our network if we add an additional interface to Router3 and connected it to 172.16.2.0/24, but left routing unchanged. If Router2 fails, Router3 would be unable to adapt to the change in the network topology and would still be unable to reach hosts on 172.16.1.0/24. This inability to adapt to network failures, even when redundant paths are available, and the problems associated with scaling, are the primary motivations behind dynamic routing.

Dynamic Routing
Dynamic routing protocols are supported by software applications running on the routing device (the router) which dynamically learn network destinations and how to get to them and also advertise those destinations to other routers. This advertisement function allows all the routers to learn about all the destination networks that exist and how to to those networks.
A router using dynamic routing will ‘learn’ the routes to all networks that are directly connected to the device. Next, the router will learn routes from other routers that run the same routing protocol (RIP, RIP2, EIGRP, OSPF, IS-IS, BGP etc). Each router will then sort through it’s list of routes and select one or more ‘best’ routes for each network destination the router knows or has learned.
Dynamic routing protocols will then distribute this ‘best route’ information to other routers running the same routing protocol, thereby extending the information on what networks exist and can be reached. This gives dynamic routing protocols the ability to adapt to logical network topology changes, equipment failures or network outages ‘on the fly’.

Advantages of Dynamic Routing
The chief advantages of dynamic routing over static routing are scalability and adaptability. A dynamically routed network can grow more quickly and larger, and is able to adapt to changes in the network topology brought about by this growth or by the failure of one or more network components.
With a dynamic routing protocol, routers learn about the network topology by communicating with other routers. Each router announces its presence, and the routes it has available, to the other routers on the network. Therefore, if you add a new router, or add an additional segment to an existing router, the other routers will hear about the addition and adjust their routing tables accordingly. You don’t have to reconfigure the routers to tell them that the network has changed. Similarly, if you move a network segment, the other routers will hear about the change. You only need to change the configuration of the router (or routers) that connect the segment that moved. This reduces the chance that errors will occur.
The ability to learn about changes to the network’s configuration has implications beyond adding new segments or moving old ones. It also means that the network can adjust to failures. If a network has redundant paths, then a partial network failure appears to the routers as if some segments got moved (they are now reached via alternate paths), and some segments have been removed from the network (they are now unreachable). In short, there’s no real difference between a network failure and a configuration change. Dynamic routing allows the network to continue functioning, perhaps in a degraded fashion, when a partial failure occurs.

And the Disadvantages of Dynamic Routing
I would be a liar if I told you that dynamic routing has no disadvantages. Chief among the disadvantages is an increase in complexity. Communicating information about network topology is not as simple as saying, “Hey, I can reach the following destinations…” Each router participating in the dynamic routing protocol must decide exactly what information to send to other routers; more important, it must attempt to select the best route for reaching other destinations from the candidates it learns about from other routers. In addition, if a router is going to adapt to changes in the network, it must be prepared to remove old or unusable information from its routing table. How it determines what is old or unusable adds to the complexity of the routing protocol. Unfortunately, the better a protocol handles the various different situations in a network, the more complex it is likely to be. This complexity tends to lead to errors in the protocol’s implementation, or differences in how vendors interpret the protocol.
In order to communicate information about the topology of the network, routers must periodically send messages to each other using a dynamic routing protocol. These messages must be sent across network segments just like any other packets. But unlike other packets in the network, these packets do not contain any information to or from a user. Instead, they contain information that is only useful to the routers. Thus, from the users’ point of view, these packets are pure overhead. On a low-speed link, these messages can consume much of the available bandwidth, especially if the network is large or unstable.
Finally, some or all of the machines in a network may be unable to speak any dynamic routing protocol, or they may not speak a common protocol. If that is the case, static routing may be your only option.
With all the disadvantages listed of both static and dynamic routing, you may be wondering what the best choice is. Only you can say for sure what is best for your network, but there is a reasonable middle ground that limits the complexity of dynamic routing without sacrificing its scalability. This middle ground is a hybrid scheme, in which part of the network uses static routing and part uses dynamic routing.

Hybrid Routing Schemes
In a hybrid routing scheme, some parts of the network use static routing, and some parts use dynamic routing. Which parts use static or dynamic routing is not important, and many options are possible. One of the most common hybrid schemes is to use static routing on the fringes of the network (what I have called the access networks) and to use dynamic routing in the core and distribution networks. The advantage of using static routing in the access networks is that these networks are where your user machines are typically located; these machines often have little or no support for dynamic routing. Additionally, access networks often have only one or two router attachments, so the burden of configuring static routing is limited. It may even be possible to define nothing more than a default route on these stub networks. Because of the limited connections to these networks, you usually don’t need to reconfigure routing on a stub network when it gets moved to a new place in the network.
On the other hand, distribution and core networks often have many router connections, and therefore many different routes to maintain. Therefore, routers in these components of the network usually can’t get by with a default route. Routers (and hosts) in the central parts of the network need complete routing information for the entire network. Furthermore, routers in the core and distribution networks usually need to be informed of changes in the connectivity of access networks. While it is certainly possible to inform each router manually when an change occurs, it is usually easier and more practical to allow a dynamic routing protocol to propagate the changes.
Another advantage of using static routes in your access networks is control. Depending on the structure of your network administration, you might not be able to control what happens in access networks. These may be handled by departmental LAN coordinators that do not report to you. When this is the case, it is often simpler to configure static routing with the access networks, and only run the dynamic routing protocol between routers and machines over which you have direct control. Because a dynamic routing protocol implies a certain level of trust, it is often safer not to use a dynamic routing protocol with such departmentally controlled access networks. In short, when dealing with routers not under your direct control, it is best to use static routing where you can, and to use dynamic routing only where you must.
Another type of hybrid routing structure to consider is based on network bandwidth issues rather than on administrative control. In this type of hybrid structure, you would run dynamic routing protocols on your high-speed LAN and WAN links, and use static routing for connections that cross lower-speed links. As an example, consider a multi-campus network at a university. Within each campus, there may be multiple routers, interconnected by Ethernets, FDDI, and other high-speed links. However, the link between the campuses may well be a 56 kbps WAN link. If the two campuses have separate network address spaces, it is unlikely that the routes between the campuses will change. In this case, the only advantage to using dynamic routing between the campuses is that packets that cannot be delivered to a machine on the other campus because of an internal network failure can be stopped before they traverse the low-speed link. However, this is the exceptional case. The normal case is that internal network operation is stable.
With this in mind, it is reasonable to ask how much bandwidth the dynamic routing protocol is taking on the low-speed link. While most routing protocols are designed to minimize the impact of the routing updates on the link, the overhead is non-zero. It may be better to use dynamic routing within each campus, but to use static routing for the inter-campus link, where bandwidth is at a premium.
Static routing between campuses connected by a slow link may even be worthwhile if the campuses share a common address space (perhaps a single class B-sized network aggregate). However, more work may be necessary. The problem with a common address space is that changes on one campus typically need to be visible to the dynamic routing protocol on the other campus. One solution to this problem is to divide the address space between the two (or more) campuses so that each is its own smaller aggregate, as shown in the following table. If you can divide the address space, you can simplify static routing between the campuses by working with the aggregates.
Two campuses sharing a common address space
Two campuses sharing a common address space
In the figure, Router1 only needs a static route for the aggregate 172.16.128.0/17. Likewise, Router5 only needs a static route for the aggregate 172.16.0.0/17. This allows each campus to allocate subnets in their portion of the common address space independently, and yet keep static routing between the campuses simple.
A final problem with our multi-campus hybrid routing scheme occurs when the inter-campus link moves between routers. For example, what happens if the link is moved from Router1 to Router3? Router configurations on Campus 2 are unaffected, since the same IP addresses for the serial link can continue to be used, and the changes necessary on Campus 1 need not be extensive. Clearly, Router1 and Router3 must know of the change. After all, even without routing to deal with, they need to have interface configuration changes made. But does Router2 need to be reconfigured to know that the link to Campus 2 has moved? Not if the routers are all configured to include information about their static routes in the dynamic routing protocol.
Most routers have some ability to propagate information from one routing source to another. We usually think in terms of exchanging routing information between two dynamic routing protocols, but passing information about static routes into a dynamic routing protocol is really just a special case. We won’t go into the details here of how this is done because it will be easier to explain once we have talked about the dynamic routing protocols and how to configure them, but you should be aware that including static routes in your dynamic routing protocol updates is an easy way to confine configuration of static routes to a minimum of routers.
Now that we have covered static, dynamic, and hybrid routing schemes, you should have a plan for where you would like to use dynamic routing, and where you will use static routing. The next step is to think more about dynamic routing protocols, and decide which are appropriate to use.
To be Continued…

No comments:

Post a Comment