Skip to document

Routing Algorithms

COMPLETE ROUTING ALGORITHM FROM SCRATCH
Course

Computer Networks (DOCS_OE_03)

10 Documents
Students shared 10 documents in this course
Academic year: 2021/2022
Uploaded by:

Comments

Please sign in or register to post comments.

Preview text

5 ROUTING ALGORITHMS

The main function of the network layer is routing packets from the source ma-

chine to the destination machine. In most networks, packets will require multiple

hops to make the journey. The only notable exception is for broadcast networks,

but even here routing is an issue if the source and destination are not on the same

network segment. The algorithms that choose the routes and the data structures

that they use are a major area of network layer design.

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. The latter case is sometimes called session routing because a

route remains in force for an entire session (e., while logged in over a VPN).

Islamic University of Science and Technology

Computer Networks Notes

It is sometimes useful to make a distinction between routing, which is making

the decision which routes to use, and forwarding, which is what happens when a

packet arrives. One can think of a router as having two processes inside it. One

of them handles each packet as it arrives, looking up the outgoing line to use for it

in the routing tables. This process is forwarding. The other process is responsi-

ble for filling in and updating the routing tables. That is where the routing algo-

rithm comes into play.

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 effi-

ciency. Correctness and simplicity hardly require comment, but the need for

robustness may be less obvious at first. Once a major network comes on the air, it

may be expected to run continuously for years without system-wide failures. Dur-

ing that period there will be hardware and software failures of all kinds. Hosts,

routers, and lines will fail repeatedly, and the topology will change many times.

The routing algorithm should be able to cope with changes in the topology and

traffic without requiring all jobs in all hosts to be aborted. Imagine the havoc if

the network needed to be rebooted every time some router crashed!

Stability is also an important goal for the routing algorithm. There exist rout-

ing algorithms that never converge to a fixed set of paths, no matter how long they

run. A stable algorithm reaches equilibrium and stays there. It should converge

quickly too, since communication may be disrupted until the routing algorithm

has reached equilibrium.

Fairness and efficiency may sound obvious—surely no reasonable person

would oppose them—but as it turns out, they are often contradictory goals. As a

simple example of this conflict, look at Fig. 5-5. Suppose that there is enough

traffic between A and A′, between B and B′, and between C and C′ to saturate the

horizontal links. To maximize the total flow, the X to X′ traffic should be shut off

altogether. Unfortunately, X and X′ may not see it that way. Evidently, some

compromise between global efficiency and fairness to individual connections is

needed.

Before we can even attempt to find trade-offs between fairness and efficiency,

we must decide what it is we seek to optimize. Minimizing the mean packet delay

is an obvious candidate to send traffic through the network effectively, but so is

maximizing total network throughput. Furthermore, these two goals are also in

conflict, since operating any queueing system near capacity implies a long queue-

ing delay. As a compromise, many networks attempt to minimize the distance a

packet must travel, or simply reduce the number of hops a packet must make. Ei-

ther choice tends to improve the delay and also reduce the amount of bandwidth

consumed per packet, which tends to improve the overall network throughput as

well.

Routing algorithms can be grouped into two major classes: nonadaptive and

adaptive. Nonadaptive algorithms do not base their routing decisions on any

then the optimal path from J to K also falls along the same route. To see this, call

the part of the route from I to J r 1 and the rest of the route r 2. If a route better

than r 2 existed from J to K, it could be concatenated with r 1 to improve the route

from I to K, contradicting our statement that r 1 r 2 is optimal.

As a direct consequence of the optimality principle, we can see that the set of

optimal routes from all sources to a given destination form a tree rooted at the

destination. Such a tree is called a sink tree and is illustrated in Fig. 5-6(b),

where the distance metric is the number of hops. The goal of all routing algo-

rithms is to discover and use the sink trees for all routers.

####### B

####### A

####### F

####### D E

####### C

####### J

####### N

####### O

####### I

####### H

####### G

####### L

####### M

####### K

####### (a)

####### B

####### A

####### F

####### D E

####### C

####### J

####### N

####### O

####### I

####### H

####### G

####### L

####### M

####### K

####### (b)

Figure 5-6. (a) A network. (b) A sink tree for router B.

Note that a sink tree is not necessarily unique; other trees with the same path

lengths may exist. If we allow all of the possible paths to be chosen, the tree be-

comes a more general structure called a DAG (Directed Acyclic Graph). DAGs

have no loops. We will use sink trees as a convenient shorthand for both cases.

Both cases also depend on the technical assumption that the paths do not interfere

with each other so, for example, a traffic jam on one path will not cause another

path to divert.

Since a sink tree is indeed a tree, it does not contain any loops, so each packet

will be delivered within a finite and bounded number of hops. In practice, life is

not quite this easy. Links and routers can go down and come back up during oper-

ation, so different routers may have different ideas about the current topology.

Also, we have quietly finessed the issue of whether each router has to individually

acquire the information on which to base its sink tree computation or whether this

information is collected by some other means. We will come back to these issues

shortly. Nevertheless, the optimality principle and the sink tree provide a bench-

mark against which other routing algorithms can be measured.

5.2 Shortest Path Algorithm

Let us begin our study of routing algorithms with a simple technique for com-

puting optimal paths given a complete picture of the network. These paths are the

ones that we want a distributed routing algorithm to find, even though not all rout-

ers may know all of the details of the network.

The idea is to build a graph of the network, with each node of the graph

representing a router and each edge of the graph representing a communication

line, or link. To choose a route between a given pair of routers, the algorithm just

finds the shortest path between them on the graph.

The concept of a shortest path deserves some explanation. One way of

measuring path length is the number of hops. Using this metric, the paths ABC

and ABE in Fig. 5-7 are equally long. Another metric is the geographic distance

in kilometers, in which case ABC is clearly much longer than ABE (assuming the

figure is drawn to scale).

####### A D

####### 1

####### 2

####### 6

####### G

####### 4

####### (a)

F (∞, −) D (∞,−)

####### A

####### B 7 C

####### 2

####### H

####### 3 3

####### 2

####### E 2 F

####### 1

####### 22

####### 6

####### G

####### 4

####### A

####### (c)

####### A

####### B (2, A) C (9, B)

H (∞, −)

####### E (4, B)

####### G (6, A)

A F (6, E) D (∞,−)

####### (e)

####### A

####### B (2, A) C (9, B)

####### H (9, G)

####### E (4, B)

####### G (5, E)

A F (6,E) D (∞,−)

####### (f)

####### A

####### B (2, A) C (9, B)

####### H (8, F)

####### E (4, B)

####### G (5, E)

A F (6, E) D (∞,1)

####### (d)

####### A

####### B (2, A) C (9, B)

H (∞, −)

####### E (4, B)

####### G (5, E)

A F (∞, −) D (∞, −)

####### H

####### E

####### G

####### (b)

B (2, A) C (∞, −)
H (∞, −)
E (∞, −)

####### G (6, A)

Figure 5-7. The first six steps used in computing the shortest path from A to D.
The arrows indicate the working node.

AXYZE (for some X and Y). There are two possibilities: either node Z has already

been made permanent, or it has not been. If it has, then E has already been probed

(on the round following the one when Z was made permanent), so the AXYZE path

has not escaped our attention and thus cannot be a shorter path.

Now consider the case where Z is still tentatively labeled. If the label at Z is

greater than or equal to that at E, then AXYZE cannot be a shorter path than ABE.

If the label is less than that of E, then Z and not E will become permanent first, al-

lowing E to be probed from Z.

This algorithm is given in Fig. 5-8. The global variables n and dist describe

the graph and are initialized before shortest path is called. The only difference

between the program and the algorithm described above is that in Fig. 5-8, we

compute the shortest path starting at the terminal node, t, rather than at the source

node, s.

Since the shortest paths from t to s in an undirected graph are the same as the

shortest paths from s to t, it does not matter at which end we begin. The reason

for searching backward is that each node is labeled with its predecessor rather

than its successor. When the final path is copied into the output variable, path,

the path is thus reversed. The two reversal effects cancel, and the answer is pro-

duced in the correct order.

5.2 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 obviously 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 net-

work.

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 be-

fore. A better technique for damming the flood is to have routers keep track of

which packets have been flooded, to avoid sending them out a second time. One

way to achieve this goal is to have the source router put a sequence number in

each 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.

#define MAX NODES 1024 /* maximum number of nodes */

#define INFINITY 1000000000 /* a number larger than every maximum path */

int n, dist[MAX NODES][MAX NODES]; /* dist[i][j] is the distance from i to j */

void shortest path(int s, int t, int path[])

{ struct state { /* the path being worked on */

int predecessor; /* previous node */

int length; /* length from source to this node */

enum {permanent, tentative} label; /* label state */

} state[MAX NODES];
int i, k, min;

struct state *p;

for (p = &state[0]; p < &state[n]; p++) { /* initialize state */

p->predecessor = −1;
p->length = INFINITY;
p->label = tentative;
}
state[t].length = 0; state[t].label = permanent;

k = t; /* k is the initial working node */

do { /* Is there a better path from k? */

for (i = 0; i < n; i++) /* this graph has n nodes */

if (dist[k][i] != 0 && state[i].label == tentative) {
if (state[k].length + dist[k][i] < state[i].length) {
state[i].predecessor = k;
state[i].length = state[k].length + dist[k][i];
}
}

/* Find the tentatively labeled node with the smallest label. */

k = 0; min = INFINITY;
for (i = 0; i < n; i++)
if (state[i].label == tentative && state[i].length < min) {
min = state[i].length;
k = i;
}
state[k].label = permanent;
} while (k != s);

/* Copy the path into the output array. */

i = 0; k = s;
do {path[i++] = k; k = state[k].predecessor; } while (k >= 0);
}
Figure 5-8. Dijkstra’s algorithm to compute the shortest path through a graph.

To prevent the list from growing without bound, each list should be aug-

mented by a counter, k, meaning that all sequence numbers through k have been

seen. When a packet comes in, it is easy to check if the packet has already been

router can measure it directly with special ECHO packets that the receiver just

timestamps and sends back as fast as it can.

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. Note that the old routing table is not

used in the calculation.

This updating process is illustrated in Fig. 5-9. 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.

####### (a)

####### A B C D

####### E

####### I J K L

####### F G

####### H

####### Router

####### 0

####### 12

####### 25

####### 40

####### 14

####### 23

####### 18

####### 17

####### 21

####### 9

####### 24

####### 29

####### 24

####### 36

####### 18

####### 27

####### 7

####### 20

####### 31

####### 20

####### 0

####### 11

####### 22

####### 33

####### 20

####### 31

####### 19

####### 8

####### 30

####### 19

####### 6

####### 0

####### 14

####### 7

####### 22

####### 9

####### 21

####### 28

####### 36

####### 24

####### 22

####### 40

####### 31

####### 19

####### 22

####### 10

####### 0

####### 9

####### 8

####### 20

####### 28

####### 20

####### 17

####### 30

####### 18

####### 12

####### 10

####### 0

####### 6

####### 15

####### A A I H I I H H I − K K

####### To A I H K Line

####### New estimated

####### delay from J

####### A B C D E F G H I J K L

####### JA JI JH JK

####### delay delay delay delay

####### is is is is

####### 8 10 12 6

####### New

####### routing

####### table

####### for J

####### Vectors received from

####### J's four neighbors

####### (b)

Figure 5-9. (a) A network. (b) Input from A, I, H, K, and the new routing table for J.

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.

The Count-to-Infinity Problem

The settling of routes to best paths across the network is called convergence.

Distance vector routing is useful as a simple technique by which routers can col-

lectively compute shortest paths, but it has a serious drawback in practice: al-

though it converges to the correct answer, it may do so slowly. In particular, it

reacts rapidly to good news, but leisurely to bad news. Consider a router whose

best route to destination X is long. If, on the next exchange, neighbor A suddenly

reports a short delay to X, the router just switches over to using the line to A to

send traffic to X. In one vector exchange, the good news is processed.

To see how fast good news propagates, consider the five-node (linear) net-

work of Fig. 5-10, where the delay metric is the number of hops. Suppose A is

down initially and all the other routers know this. In other words, they have all

recorded the delay to A as infinity.

####### A B C D E

  • • • •
    • • •

####### 4

####### 1

####### 1

####### 1

####### 1

####### 2

####### 2

####### 2

####### 3

####### 3

####### Initially

####### After 1 exchange

####### After 2 exchanges

####### After 3 exchanges

####### After 4 exchanges

####### A B C D E

####### 1 2 3 4

  • • • •

####### 2 3 4

####### 3 4

####### 4

####### 6

####### 3

####### 3

####### 5

####### 5

####### 4

####### 4

####### 6

####### 5

####### 5

####### 7 6 7 6

####### 7 8 7 8

####### Initially

####### After 1 exchange

####### After 2 exchanges

####### After 3 exchanges

####### After 4 exchanges

####### After 5 exchanges

####### After 6 exchanges

..
.

####### (a) (b)

Figure 5-10. The count-to-infinity problem.

When A comes up, the other routers learn about it via the vector exchanges.

For simplicity, we will assume that there is a gigantic gong somewhere that is

struck periodically to initiate a vector exchange at all routers simultaneously. At

the time of the first exchange, B learns that its left-hand neighbor has zero delay

to A. B now makes an entry in its routing table indicating that A is one hop away

to the left. All the other routers still think that A is down. At this point, the rout-

ing table entries for A are as shown in the second row of Fig. 5-10(a). On the next

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 al-

gorithm can be run at each router to find the shortest path to every other router.

Below we will consider each of these five steps in more detail.

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.

These names must be globally unique because when a distant router later hears

that three routers are all connected to F, it is essential that it can determine wheth-

er all three mean the same F.

When two or more routers are connected by a broadcast link (e., a switch,

ring, or classic Ethernet), the situation is slightly more complicated. Fig. 5-11(a)

illustrates a broadcast LAN to which three routers, A, C, and F, are directly con-

nected. Each of these routers is connected to one or more additional routers, as

shown.

####### Router

####### A

####### B

####### C

####### D E

####### C

####### D E

####### H

####### I

####### F

####### G G H

####### F I

####### N

####### A

####### B

####### LAN

####### (a) (b)

Figure 5-11. (a) Nine routers and a broadcast LAN. (b) A graph model of (a).

The broadcast LAN provides connectivity between each pair of attached rout-

ers. However, modeling the LAN as many point-to-point links increases the size

of the topology and leads to wasteful messages. A better way to model the LAN

is to consider it as a node itself, as shown in Fig. 5-11(b). Here, we have intro-

duced a new, artificial node, N, to which A, C, and F are connected. One desig-

nated router on the LAN is selected to play the role of N in the routing protocol.

The fact that it is possible to go from A to C on the LAN is represented by the

path ANC here.

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 automat-

ically, or configured by the network operator. A common choice is to make the

cost inversely proportional to the bandwidth of the link. For example, 1-Gbps

Ethernet may have a cost of 1 and 100-Mbps Ethernet a cost of 10. This makes

higher-capacity paths better choices.

If the network is geographically spread out, the delay of the links may be fac-

tored 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.

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 (to be de-

scribed later) and a list of neighbors. The cost to each neighbor is also given. An

example network is presented in Fig. 5-12(a) with costs shown as labels on the

lines. The corresponding link state packets for all six routers are shown in Fig. 5-

12(b).

####### B C

####### E F

####### A D

####### 1 6

####### 2

####### 8

####### 5 7

####### 4 3

####### (a)

####### A

####### Seq.

####### Age

####### B C D E F

####### B 4

####### E 5

####### Seq.

####### Age

####### A 4

####### C 2

####### Seq.

####### Age

####### B 2

####### D 3

####### Seq.

####### Age

####### C 3

####### F 7

####### Seq.

####### Age

####### A 5

####### C 1

####### Seq.

####### Age

####### B 6

####### D 7

####### F 6 E 1 F 8 E 8

####### Link State Packets

####### (b)

Figure 5-12. (a) A network. (b) The link state packets for this network.

compared. If they are equal, the duplicate is discarded. If they are different, the

older one is thrown out. To guard against errors on the links, all link state packets

are acknowledged.

The data structure used by router B for the network shown in Fig. 5-12(a) is

depicted in Fig. 5-13. Each row here corresponds to a recently arrived, but as yet

not fully processed, link state packet. The table records where the packet ori-

ginated, its sequence number and age, and the data. In addition, there are send

and acknowledgement flags for each of B’s three links (to A, C, and F, re-

spectively). The send flags mean that the packet must be sent on the indicated

link. The acknowledgement flags mean that it must be acknowledged there.

####### D 21 59 1 0 0 0 1 1

####### C 20 60 1 0 1 0 1 0

####### E 21 59 0 1 0 1 0 1

####### F 21 60 1 1 0 0 0 1

####### A 21 60 0 1 1 1 0 0

####### Source Seq. Age A C F A C F Data

####### Send flags ACK flags

Figure 5-13. The packet buffer for router B in Fig. 5-12(a).

In Fig. 5-13, the link state packet from A arrives directly, so it must be sent to

C and F and acknowledged to A, as indicated by the flag bits. Similarly, the pack-

et from F has to be forwarded to A and C and acknowledged to F.

However, the situation with the third packet, from E, is different. It arrives

twice, once via EAB and once via EFB. Consequently, it has to be sent only to C

but must be acknowledged to both A and F, as indicated by the bits.

If a duplicate arrives while the original is still in the buffer, bits have to be

changed. For example, if a copy of C’s state arrives from F before the fourth

entry in the table has been forwarded, the six bits will be changed to 100011 to in-

dicate that the packet must be acknowledged to F but not sent there.

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.

Compared to distance vector routing, 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. Also, the computation time

grows faster than kn, even with the most efficient data structures, an issue in large

networks. Nevertheless, in many practical situations, link state routing works

well because it does not suffer from slow convergence problems.

Link state routing is widely used in actual networks, so a few words about

some example protocols are in order. Many ISPs use the IS-IS (Intermediate

System-Intermediate System) link state protocol (Oran, 1990). It was designed

for an early network called DECnet, later adopted by ISO for use with the OSI

protocols and then modified to handle other protocols as well, most notably, IP.

OSPF (Open Shortest Path First) is the other main link state protocol. It was

designed by IETF several years after IS-IS and adopted many of the innovations

designed for IS-IS. These innovations include a self-stabilizing method of flood-

ing link state updates, the concept of a designated router on a LAN, and the meth-

od of computing and supporting path splitting and multiple metrics. As a conse-

quence, there is very little difference between IS-IS and OSPF. The most impor-

tant difference is that IS-IS can carry information about multiple network layer

protocols at the same time (e., IP, IPX, and AppleTalk). OSPF does not have

this feature, and it is an advantage in large multiprotocol environments. We will

go over OSPF in Sec. 5.6.

A general comment on routing algorithms is also in order. Link state, dis-

tance vector, and other algorithms rely on processing at all the routers to compute

routes. Problems with the hardware or software at even a small number of routers

can wreak havoc across the network. For example, if a router claims to have a

link it does not have or forgets a link it does have, the network graph will be

incorrect. If a router fails to forward packets or corrupts them while forwarding

them, the route will not work as expected. Finally, if it runs out of memory or

does the routing calculation wrong, bad things will happen. As the network grows

into the range of tens or hundreds of thousands of nodes, the probability of some

router failing occasionally becomes nonnegligible. The trick is to try to arrange to

limit the damage when the inevitable happens. Perlman (1988) discusses these

problems and their possible solutions in detail.

5.2 Hierarchical Routing

As networks grow in size, the router routing tables grow proportionally. Not

only is router memory consumed by ever-increasing tables, but more CPU time is

needed to scan them and more bandwidth is needed to send status reports about

them. At a certain point, the network may grow to the point where it is no longer

####### Region 1 Region 2

####### Region 3 Region 4 Region 5

####### 1B

####### 1A

####### 1C

####### 2A 2B

####### 2C

####### 5B 5C

####### 5A

####### 5E

####### 5D

####### 2D

####### 4A

####### 4B 4C

####### 3A

####### 3B

####### 1B 1

####### 1C 1

####### 1B 2

####### 1B 3

####### 1B 3

####### 1B 4

####### 1C 3

####### 1C 2

####### 1C 3

####### 1C 4

####### 1C 4

####### 1C 4

####### 1C 5

####### 1B 5

####### 1C 6

####### 1C 5

####### 1A – –

####### 1C

####### 2A

####### 2B

####### 2C

####### 2D

####### 3A

####### 3B

####### 4A

####### 4B

####### 4C

####### 5A

####### 5B

####### 5C

####### 5D

####### 5E

####### 1B

####### Dest. Line Hops

####### Full table for 1A

####### 1A

####### 1C

####### 2

####### 3

####### 4

####### 5

####### 1B

####### Dest. Line Hops

####### Hierarchical table for 1A

####### 1B 1

####### 1C 1

####### 1B 2

####### 1C 2

####### 1C 3

####### 1C 4

####### (a) (b) (c)

Figure 5-14. Hierarchical routing.

5.2 Broadcast Routing

In some applications, hosts need to send messages to many or all other hosts.

For example, a service distributing weather reports, stock market updates, or live

radio programs might work best by sending to all machines and letting those that

are interested read the data. Sending a packet to all destinations simultaneously is

called broadcasting. Various methods have been proposed for doing it.

One broadcasting method that requires no special features from the network is

for the source to simply send a distinct packet to each destination. Not only is the

method wasteful of bandwidth and slow, but it also requires the source to have a

complete list of all destinations. This method is not desirable in practice, even

though it is widely applicable.

An improvement is multidestination routing, in which each packet contains

either a list of destinations or a bit map indicating the desired destinations. When

a packet arrives at a router, the router checks all the destinations to determine the

set of output lines that will be needed. (An output line is needed if it is the best

route to at least one of the destinations.) The router generates a new copy of the

packet for each output line to be used and includes in each packet only those dest-

inations that are to use the line. In effect, the destination set is partitioned among

the output lines. After a sufficient number of hops, each packet will carry only

one destination like a normal packet. Multidestination routing is like using sepa-

rately addressed packets, except that when several packets must follow the same

route, one of them pays full fare and the rest ride free. The network bandwidth is

therefore used more efficiently. However, this scheme still requires the source to

know all the destinations, plus it is as much work for a router to determine where

to send one multidestination packet as it is for multiple distinct packets.

We have already seen a better broadcast routing technique: flooding. When

implemented with a sequence number per source, flooding uses links efficiently

with a decision rule at routers that is relatively simple. Although flooding is ill-

suited for ordinary point-to-point communication, it rates serious consideration for

broadcasting. However, it turns out that we can do better still once the shortest

path routes for regular packets have been computed.

The idea for reverse path forwarding is elegant and remarkably simple once

it has been pointed out (Dalal and Metcalfe, 1978). When a broadcast packet ar-

rives at a router, the router checks to see if the packet arrived on the link that is

normally used for sending packets toward the source of the broadcast. If so, there

is an excellent chance that the broadcast packet itself followed the best route from

the router and is therefore the first copy to arrive at the router. This being the

case, the router forwards copies of it onto all links except the one it arrived on. If,

however, the broadcast packet arrived on a link other than the preferred one for

reaching the source, the packet is discarded as a likely duplicate.

I F H J N A D E K G O M O C G D N H B L L B

####### A

####### E

####### H

####### B C

####### D

####### F

####### J

####### G

####### O

####### M

####### K

####### L

####### N

####### I

####### (a)

####### A

####### B C

####### D

####### G

####### J

####### O

####### F

####### I

####### E

####### H

####### K

####### L

####### M

####### N

####### (b) (c)

E K H

Figure 5-15. Reverse path forwarding. (a) A network. (b) A sink tree. (c) The
tree built by reverse path forwarding.

An example of reverse path forwarding is shown in Fig. 5-15. Part (a) shows

a network, part (b) shows a sink tree for router I of that network, and part (c)

shows how the reverse path algorithm works. On the first hop, I sends packets to

F, H, J, and N, as indicated by the second row of the tree. Each of these packets

arrives on the preferred path to I (assuming that the preferred path falls along the

sink tree) and is so indicated by a circle around the letter. On the second hop,

Was this document helpful?

Routing Algorithms

Course: Computer Networks (DOCS_OE_03)

10 Documents
Students shared 10 documents in this course
Was this document helpful?
5.2 ROUTING ALGORITHMS
The main function of the network layer is routing packets from the source ma-
chine to the destination machine. In most networks, packets will require multiple
hops to make the journey. The only notable exception is for broadcast networks,
but even here routing is an issue if the source and destination are not on the same
network segment. The algorithms that choose the routes and the data structures
that they use are a major area of network layer design.
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. The latter case is sometimes called session routing because a
route remains in force for an entire session (e.g., while logged in over a VPN).
Islamic University of Science and Technology
Computer Networks Notes