UNIT-III Part-1 Routing Algorithms
UNIT-III Part-1 Routing Algorithms
The network layer is concerned with getting the packets from the source all the way to the destination. Getting to
the destination may require making many hops at intermediate routers along the way.
This function clearly contrasts with that of the data link layer, which has the goal of just moving frames
from one end of a wire to the other. Thus, the network layer is the lowest layer that deals with end-to-end
transmission
To achieve its goals, the network layer must know about the topology of the network (i.e., the set of all
routers and links) and choose appropriate paths (Routes) through it, even for large networks. It must also
take care when choosing routes to avoid overloading some of the communication lines and routers while
leaving others idle.
Finally, when the source and destination are in different networks, new problems occur. It is up to the
network layer to deal with them.
1. NETWORK LAYER DESIGN ISSUES
Some of the issues that the designers of the network layer must grapple with.
1. Store-and-Forward Packet Switching
2. Services Provided to the Transport Layer
3. Implementation of Connectionless Service
4. Implementation of Connection-Oriented Service
5. Comparison of Virtual-Circuit and Datagram Networks
i. Store-and-Forward Packet Switching
Before starting to explain the details of the network layer, it is worth restating the context in which the
network layer protocols operate. This context can be seen in Figure (1). The major components of the network
are the ISP’s equipment (routers connected by transmission lines), shown inside the shaded oval, and the
customers’ equipment, shown outside the oval. Host H1 is directly connected to one of the ISP’s routers, A,
perhaps as a home computer that is plugged into a DSL modem. In contrast, H2 is on a LAN, which might be an
office Ethernet, with a router, F, owned and operated by the customer. This router has a leased line to the ISP’s
equipment. We have shown F as being outside the oval because it does not belong to the ISP.
2. ROUTING ALGORITHMS
The main function of the network layer is routing packets from the source machine to the destination machine.
In most networks, packets will require multiple hops to make the journey.
The routing algorithm is that part of the network layer software responsible for deciding which output line an
incoming packet should be transmitted on.
If the network uses datagrams internally, this decision must be made anew for every arriving data packet
since the best route may have changed since last time.
If the network uses virtual circuits internally, routing decisions are made only when a new virtual circuit is
being set up. Thereafter, data packets just follow the already established route.
Regardless of whether routes are chosen independently for each packet sent or only when new connections are
established, certain properties are desirable in a routing algorithm: correctness, simplicity, robustness, stability,
fairness, and efficiency.
Routing algorithms can be grouped into two major classes: Non-adaptive (Static Routing) and Adaptive
(Dynamic Routing).
Non-adaptive algorithms- Routers do not base their routing decisions on any measurements or estimates
of the current topology and traffic. Instead, the choice of the route to use to get from I to J (for all I and J)
is computed in advance, offline, and downloaded to the routers when the network is booted. This procedure
is sometimes called static routing. Because it does not respond to failures, static routing is mostly useful
for situations in which the routing choice is clear.
Adaptive algorithms- Routers change their routing decisions to reflect changes in the topology, and
sometimes changes in the traffic as well. These dynamic routing algorithms differ in where they get their
information (e.g., locally, from adjacent routers, or from all routers), when they change the routes (e.g.,
when the topology changes, or every ΔT seconds as the load changes), and what metric is used for
optimization (e.g., distance, number of hops, or estimated transit time)
Figure (5): The first six steps used in computing the shortest path from A to D. The
arrows indicate the working node.
iii. Flooding
When a routing algorithm is implemented, each router must make decisions based on local knowledge, not
the complete picture of the network. A simple local technique is flooding, in which every incoming packet
is sent out on every outgoing line except the one it arrived on.
Flooding generates vast numbers of duplicate packets, in fact, an infinite number unless some measures are
taken to damp the process. One such measure is to have a hop counter contained in the header of each packet
that is decremented at each hop, with the packet being discarded when the counter reaches zero. Ideally, the
hop counter should be initialized to the length of the path from source to destination. If the sender does not
know how long the path is, it can initialize the counter to the worst case, namely, the full diameter of the
network.
Flooding with a hop count can produce an exponential number of duplicate packets as the hop count grows
and routers duplicate packets they have seen before.
Another technique is, the source router put a sequence number in ach packet it receives from its hosts. Each
router then needs a list per source router telling which sequence numbers originating at that source have
already been seen. If an incoming packet is on the list, it is not flooded.
Flooding is not practical for sending most packets, but it does have some important uses.
1. It ensures that a packet is delivered to every node in the network. This may be wasteful if there is a single
destination that needs the packet, but it is effective for broadcasting information. In wireless networks,
all messages transmitted by a station can be received by all other stations within its radio range, which
is, in fact, flooding, and some algorithms utilize this property.
2. Flooding is tremendously robust. Even if large numbers of routers are blown to bits (e.g., in a military
network located in a war zone), flooding will find a path if one exists, to get a packet to its destination.
Flooding also requires little in the way of setup. The routers only need to know their neighbors. This
means that flooding can be used as a building block for other routing algorithms that are more efficient
but need more in the way of setup.
3. Flooding always chooses the shortest path because it chooses every possible path in parallel.
Consequently, no other algorithm can produce a shorter delay (if we ignore the overhead generated by
the flooding process itself).
iv. Distance Vector Routing
Computer networks generally use dynamic routing algorithms that are more complex than flooding, but more
efficient because they find shortest paths for the current topology.
A distance vector routing or Bellman-Ford algorithm operates by having each router maintain a table (i.e.,
a vector) giving the best known distance to each destination and which link to use to get there. These tables
are updated by exchanging information with the neighbors. Eventually, every router knows the best link to
reach each destination.
In distance vector routing, each router maintains a routing table indexed by, and containing one entry for each router
in the network. This entry has two parts: the preferred outgoing line to use for that destination and an estimate of
the distance to that destination.
As an example, assume that delay is used as a metric and that the router knows the delay to each of its
neighbors. Once every T msec, each router sends to each neighbor a list of its estimated delays to each destination.
It also receives a similar list from each neighbor. Imagine that one of these tables has just come in from neighbor X,
with Xi being X’s estimate of how long it takes to get to router i. If the router knows that the delay to X is m msec,
it also knows that it can reach router i via X in Xi + m msec. By performing this calculation for each neighbor, a
router can find out which estimate seems the best and use that estimate and the corresponding link in its new routing
table.
This updating process is illustrated in Figure (6). Part (a) shows a network. The first four columns of part (b)
show the delay vectors received from the neighbors of router J. A claims to have a 12-msec delay to B, a 25-
msec delay to C, a 40-msec delay to D, etc. Suppose that J has measured or estimated its delay to its
neighbors, A, I, H, and K, as 8, 10, 12, and 6 msec, respectively.
Consider how J computes its new route to router G. It knows that it can get to A in 8 msec, and furthermore
A claims to be able to get to G in 18 msec, so J knows it can count on a delay of 26 msec to G if it forwards
packets bound for G to A. Similarly, it computes the delay to G via I, H, and K as 41 (31 + 10), 18 (6 + 12),
and 37 (31 + 6) msec, respectively. The best of these values is 18, so it makes an entry in its routing table
that the delay to G is 18 msec and that the route to use is via H. The same calculation is performed for all
the other destinations, with the new routing table shown in the last column of the figure.
Figure (6): (a) A network. (b) Input from A, I, H, K, and the new routing table for J.
The primary problem distance vector routing algorithm is, it took too long to converge after the network
topology changed (due to the count-to-infinity problem). Consequently, it was replaced by an entirely new
algorithm, now called link state routing.
The idea behind link state routing is fairly simple and can be stated as five parts.
Each router must do the following things to make it work:
1. Discover its neighbors and learn their network addresses.
2. Set the distance or cost metric to each of its neighbors.
3. Construct a packet telling all it has just learned.
4. Send this packet to and receive packets from all other routers.
5. Compute the shortest path to every other router.
In effect, the complete topology is distributed to every router. Then Dijkstra’s algorithm can be run at
each router to find the shortest path to every other router.
1. Learning about the Neighbors
When a router is booted, its first task is to learn who its neighbors are. It accomplishes this goal by sending
a special HELLO packet on each point-to-point line. The router on the other end is expected to send back a reply
giving its name.
2. Setting Link Costs
The link state routing algorithm requires each link to have a distance or cost metric for finding shortest paths.
The cost to reach neighbors can be set automatically, or configured by the network operator.
If the network is geographically spread out, the delay of the links may be factored into the cost so that paths
over shorter links are better choices. The most direct way to determine this delay is to send over the line a special
ECHO packet that the other side is required to send back immediately. By measuring the round-trip time and
dividing it by two, the sending router can get a reasonable estimate of the delay.
3. Building Link State Packets
Once the information needed for the exchange has been collected, the next step is for each router to build a
packet containing all the data. The packet starts with the identity of the sender, followed by a sequence number
and age and a list of neighbors. The cost to each neighbor is also given. An example network is presented in Figure
(8a) with costs shown as labels on the lines. The corresponding link state packets for all six routers are shown in
Figure (8b).
Figure (8): (a) A network. (b) The link state packets for this network
Building the link state packets is easy. The hard part is determining when to build them. One possibility is
to build them periodically, that is, at regular intervals. Another possibility is to build them when some
significant event occurs, such as a line or neighbor going down or coming back up again or changing its
properties appreciably.
4. Distributing the Link State Packets
The trickiest part of the algorithm is distributing the link state packets. All of the routers must get all of the
link state packets quickly and reliably. If different routers are using different versions of the topology, the routes
they compute can have inconsistencies such as loops, unreachable machines, and other problems.
The fundamental idea is to use flooding to distribute the link state packets to all routers. To keep the flood
in check, each packet contains a sequence number that is incremented for each new packet sent. Routers keep track
of all the (source router, sequence) pairs they see. When a new link state packet comes in, it is checked against the
list of packets already seen. If it is new, it is forwarded on all lines except the one it arrived on. If it is a duplicate, it
is discarded. If a packet with a sequence number lower than the highest one seen so far ever arrives, it is rejected as
being obsolete as the router has more recent data.
If some refinements (overcoming the problems of flooding) are made to this algorithm, then this algorithm
will be more robust.
5. Computing the New Routes
Once a router has accumulated a full set of link state packets, it can construct the entire network graph because
every link is represented. Every link is, in fact, represented twice, once for each direction. The different directions
may even have different costs. The shortest-path computations may then find different paths from router A to B than
from router B to A.
Now Dijkstra’s algorithm can be run locally to construct the shortest paths to all possible destinations. The
results of this algorithm tell the router which link to use to reach each destination. This information is installed in
the routing tables, and normal operation is resumed.
When compared to DVR algorithm, link state routing requires more memory and computation.
For a network with n routers, each of which has k neighbors, the memory required to store the input data is
proportional to kn, which is at least as large as a routing table listing all the destinations.
The computation time grows faster than kn, even with the most efficient data structures, an issue in large
networks.
In many practical situations, link state routing works well because it does not suffer from slow convergence
problems like DVR algorithm.
When hierarchical routing is used, the routers are divided into what we will call regions. Each router knows
all the details about how to route packets to destinations within its own region but knows nothing about the internal
structure of other regions.
For huge networks, a two-level hierarchy may be insufficient; it may be necessary to group the regions into
clusters, the clusters into zones, the zones into groups, and so on, until we run out of names for aggregations.
Figure (9) gives a quantitative example of routing in a two-level hierarchy with five regions. The full routing
table for router 1A has 17 entries, as shown in Figure (9b). When routing is done hierarchically, as in Figure (9c),
there are entries for all the local routers, as before, but all other regions are condensed into a single router, so all
traffic for region 2 goes via the 1B-2A line, but the rest of the remote traffic goes via the 1C-3B line. Hierarchical
routing has reduced the table from 17 to 7 entries.
An interesting question is ‘‘how many levels should the hierarchy have?’’ For example, consider a network with
720 routers. If there is no hierarchy, each router needs 720 routing table entries. If the network is partitioned into 24
regions of 30 routers each, each router needs 30 local entries plus 23 remote entries for a total of 53 entries. If a
three-level hierarchy is chosen, with 8 clusters each containing 9 regions of 10 routers, each router needs 10 entries
for local routers, 8 entries for routing to other regions within its own cluster, and 7 entries for distant clusters, for a
total of 25 entries.
The routing goal in systems with mobile hosts is to make it possible to send packets to mobile hosts using
their fixed home addresses and have the packets efficiently reach them wherever they may be. The trick, of course,
is to find them.
The basic idea used for mobile routing in the Internet and cellular networks is: the mobile host needs to tell
a host at the home location where it is now. This host, which acts on behalf of the mobile host, is called the home
agent. Once it knows where the mobile host is currently located, it can forward packets so that they are delivered.