EC310 Lecture 15

advertisement
EC310 Lesson 28: Routing Part II
Objectives:
(a) Describe the fundamental algorithms used to construct routing tables.
(b) Describe how a routing table is developed using link state routing.
(c) Describe how a routing table is developed using distance vector routing.
(d) Identify the relative advantages and disadvantages of link state routing and distance vector routing.
Up until this point we have talked about simple examples where one router is the only path to one network. In
reality, things are much different. Often there can be multiple paths from one network to another. The question
is not just how to get from Point A to Point B, but how to get there using a good route.
I. What is a Good Route?
1. Routing Algorithms. A routing algorithm tells a router which outgoing line an incoming packet should be
placed on. For IP packets, the routing decision is made from scratch for each packet that arrives. A routing
algorithm should endeavor to satisfy the following attributes:

Correctness—packets should be routed to the proper destination.

Simplicity—algorithms should clean and simple so that packets are routed quickly to their destinations.
Unwieldy Rube Goldberg-type algorithms are to be avoided.

Robustness—algorithms should adapt to changes in the network's topology caused by router or link
failures.

Stability—the algorithm should converge to a specific solution; packets should not be left aimlessly
circulating in loops around the network.

Optimality—if there are multiple ways to get from Point A to Point B, the algorithm should provide the
optimal path through the network.
Routing is accomplished by routing protocols which establish routing tables in each router. The router consults
its table to determine how to route packets.
1
2. Networks as Graphs. To develop routing algorithms we model a computer network as a graph: the nodes
of the graph are the routers. An edge in a graph represents a communication link between two routers.
On each edge between two routers, we assign a weight. This weight might be distance, cost, queuing delay, or
some other factor of interest. Our problem: Find the path from a given source node to a destination node which
minimizes the total weight.
If our weights represent:
distance
cost
queuing delay
then we are interested in:
shortest path
cheapest path
fastest path
3. Routing with Partial Information Routing is somewhat complicated by the fact that decisions are based on
partial information. But we encounter such situations every day. Consider driving down a road: Not every road
sign lists every destination. But, usually there is a default! (In road travel, the default is: If your destination is
not listed on the sign, keep driving straight.) When taken as a whole, routing tables (like road signs) must be
consistent and complete. It is important that:


all explicit directions correctly point to a shortest path
all shortest paths for all destinations be explicitly noted in the tables
Note that routers make local routing decisions – i.e., they decide the next place to send a packet addressed to a
specific destination. But they must make this decision based on some understanding of the global network
picture. So, each router needs global information about the network. It is somewhat confusing, so the point
bears repeating: Routers make local routing decisions based on global information.
Recall that routing protocols establish routing tables in each router, and, as a simplification, we can say that these
tables have the following format:
Destination address
Address of the next element on the best path to the destination
When a packet shows up at a router, the router refers to the routing table to decide where to send the packet.
To get an idea of what a routing table should look like for a larger network than those we have treated up to this
point, consider the network shown below on the left. Suppose the weight of each link is one. The question is:
What should the routing table be for Router 1? The answer to this question is shown on the right.
8
7
Routing Table for Router 1:
destination
2
3
4
5
6
7
8
9
10
1
3
5
9
2
4
10
6
2
next element
2
3
2
3
3
3
3
3
2
Example 1
Consider the network shown below, where the numbers on the edges indicate the cost of using that edge. For
example, the cost of using the link from Router A to Router B is 1, whereas the cost of using the link from
Router A to Router D is 4.
(a) Draw the routing table for Router A.
B
C
3
1
2
A
1
F
1
4
4
1
D
E
Solution:
Destination
B
C
D
E
F
Next Hop
(b) If all routers have the correct routing tables, what is the path that an IP packet travels from Node A
to Node F? (Note that to state a path, you just need to state the sequence of routers encountered
along the path; for example, one possible path from Router A to Router F is A-D-E-F.
Solution:
(c) What is the total cost of the path you selected in Part (b) above?
Solution:
II. Routing Protocols
So, now that we know what routing tables should look like, we ask the question: How do routing tables actually
get put together? You likely solved the preceding example by looking down on the network and performing a
visual analysis of the picture. Routers do not have the ability to hover over a picture of the network, and they
do not have human visual skills at their disposal for use in analyzing a diagram.
3
Routers use routing protocols to build their routing tables. Routing protocols are intended to:

Communicate network topology information to each router.

Determine how individual routers will use this information to make routing decisions (i.e., determine
how individual routers will use this information to construct routing tables like the one shown above).
We will discuss two routing methodologies: Link State Routing and Distance Vector Routing.
1. Link State Routing
A. Two key ideas:

Each router learns the full network topology. That is, each router learns a complete picture of the
network graph–the routers, the links and the link weights.

Knowing the complete network picture, each router independently computes the optimal routes to
each destination and constructs a routing table.
B. Learning the topology.
The first bullet above says “routers learn the full network topology.” So, in link state routing, how do
routers come to know the network topology? Here's how!

Each router learns its neighbors’ addresses by sending "Hello" packets to which its neighbors reply.

Each router determines the weight of each of its links. For example, if these weights represent time
delays, the routers might determine how long it takes to receive a reply, and use that as the weight.
If the weight is a cost, the router might “know” the costs associated with each link based on data
entered by a network administrator.

Each router then transmits packets that tell information about that individual router's links.
For instance, in the picture below, Router 26 sends a packet that essentially says:
My name is Router 26
18
Router 18 is connected to me and the weight of the
edge joining us is 4
4
Router 35 is connected to me and the weight of the
edge joining us is 2
26
Router 51 is connected to me and the weight of the
edge joining us is 3
3
2
35
51
4
Or, somewhat more formally, it transmits a packet that conveys the following table.
18
35
51
26 _____
4
2
3
By sending this packet, a router informs the network about the status, or state, of each of its links.
Hence, this methodology is called Link State Routing and these packets are called Link State Packets
(LSPs). This info will then be used by others to construct routing tables.
These LSPs are distributed to all other routers using "controlled flooding": When a router receives a
LSP, it gives it to all of its neighbors. A router keeps track of which LSPs it has seen, and only floods
them the first time they arrive.
Now…think about this: After each router has sent its LSP, and after each LSP has circulated to all the
other routers, then does each router have a full and complete picture of the network topology? The
answer is Yes!
But what then—we still don't have routing tables in each router? Answer: Each router runs Dijkstra’s
Algorithm. This is a well-known algorithm which solves this problem (the details of which we skip).
It is important that the fundamental idea be understood: In link state routing:

Each router, in its LSP, sends information about its neighbors only.

The information in this LSP is sent to all other routers.
An
Aside
Do routers really have names like 'Router 26'? Yes! In the Internet's OSPF
routing protocol, a router identifies itself to all other routers using a unique IP
address called a Router ID. Additionally, in every OSPF message a router
sends it will include its Router ID so that other routers know who originated
the message and where they can be reached. For this reason it is very important
that the IP address assigned as the Router ID is always available.
As you know, hardware (like your trusty drill rifle) is prone to failure. Therefore, a special software interface
called the loopback interface is assigned the Router ID. The loopback interface, because it is enabled
in software, is always active regardless if one or two hardware interfaces on a router stop working. This ensures
routers can always find each other to communicate when needed.
What are the routers talking about with each other and why do they need to communicate so often? There are a
number of internal measures routers use in order increase efficiency and prevent unnecessary information from
clogging up the network, such as electing a Designated Router (DR) and Backup Designated Router (BDR) and
managing Link State Updates (LSU).
To learn more about OSPF, see http://www.ietf.org/rfc/rfc2328.txt.
5
Because of time constraints in EC312, we just say:
An
Aside
Each router runs Dijkstra’s Algorithm. This is a well-known algorithm
which solves this problem (the details of which we skip).
You should know, though, that the algorithm is truly one of the all-time-beauts in
network theory.
The algorithm solves the problem: Find the shortest path from Node X to every other node in an arbitrary
network where the edges have nonnegative weights associated with them. The algorithm is not hard, but would
require a full period (perhaps) to fully explain it. Many reasonably good explanations can be found on the web.
An explanation (not so good) can be found in your text in Chapter 20.
Dijkstra's Algorithm has two interesting (non-technical) facts associated with it.
First, the algorithm was published in 1959. We realize that to the average midshipmen, the year 1959 might as
well be 1659, but—truth be told—1959 is really not that long ago! It is fascinating to think that the basic
problem of determining the shortest path in a network eluded the great minds throughout history—Euclid,
Euler, Newton, Leibniz, Descartes, Fermat, Hilbert—not to be discovered until 1959.
Second, the algorithm was published in a journal article that was strikingly brief. The paper presenting this
earth-shattering result was slightly over two pages long. Just two pages! Next time your History prof tells you
that your paper needs to be 10 pages to say anything of value, reply: "WRONG! Haven't you heard of Dijkstra!"
Dijkstra had a number of interesting personal idiosyncrasies. Despite the fact that he invented the field of
structured computer programming and contributed a key concept (the semaphore) to the study of operating
systems, he limited his own use of computers. Until the time he retired from academe in 2000 he wrote all his
papers by hand, used only the chalkboard for teaching, and strictly limited his computer use to web
browsing and email. He passed away in 2002 at age 72.
Example 2
Given the following network map with the weights of edges between routers:
(a) Construct the Link State Packet (LSP) that Router C would send to Router B.
Solution:
Router
Weight
(b) After Router G runs Dijkstra's Algorithm, what would be the optimal route from router G to router B, and
what would be the total cost of this route?
Solution:
6
C. Topology changes. What if a link dies? For instance, in the picture on page 4 above, what if the link
connecting Router 18 to Router 26 should die?
In link state routing, whenever a router detects a change in the state of its links, it sends a new link state
packet. Thus, if the link connecting Router 18 to Router 26 should die, Router 26 will transmit a new
LSP with the entries:
35
51
26 _____
2
3
Note that Router 18 will also detect the loss of a connection to Router 26 and transmit a new LSP as
well. These new LSP's will then propagate to all other routers via controlled flooding.
You might be wondering: Won't there now be conflicting information in the other routers? For instance,
there will now be two pieces of information from Router 26:

The old LSP from Router 26 that had info about the link to Router 18:
18
35
51

26 _____
4
2
3
and the revised LSP without info about router 18:
35
51
26 _____
2
3
Which of these should another router in the network choose to use to build its network picture and run
Dijkstra's Algorithm?
To solve this perplexing predicament, yielding a righteous resolution to this difficult dilemma, and thus
causing midshipmen merriment, each LSP has a sequence number. That is, a Router stamps its first
LSP with sequence number 1, its second LSP with sequence number 2, and so forth. Higher sequence
numbers override lower sequence numbers. So, when other routers in the network receive a new LSP
from Router 26, they will notice that it has a higher sequence number than the previous LSP, and they
will delete the previous (outdated) LSP.
Okay…each router has to send LSPs when the router first is connected to the network, and also has to
send LSPs whenever the network topology changes. Are there any other times that routers send LSPs?
The answer is Yes! All routers also send LSPs periodically, just to make sure all routers are “on the
same page.”
Where is link state routing used in the Internet? The Internet’s Open Shortest Path First (OSPF)
protocol uses link-state routing. (Open refers to the fact that the standard is “open,” i.e., published, nonpropriety.)
7
2. Distance Vector Routing The other routing methodology is Distance Vector Routing (also variously called
Bellman - Ford Routing or Ford - Fulkerson Routing)
A. Basic Idea. Each router maintains a table:
Destination router
My guess of best distance
Which outgoing line

Each router learns its immediate (1-hop) neighbors and the distance to them.

Each router shares its knowledge about the entire network with its neighbors. This table is called
a vector of distances, or, a distance vector. These tables are exchanged with neighbors only.

When a router receives a distance vector from a neighbor, it uses that information to update its
own distance vector.

Routers send distance vectors periodically, whether or not changes have occurred.
To consider how the distance vector algorithm works, let's consider the network shown below.
A
B
2
C
D
4
3
Initially, each of the four routers exchanges a Hello Packet with its neighbors, learning who their
neighbors are, and the distance to their neighbors. For example, Router B receives a Hello Packet from
Router A and Router C, learning that these two routers are a distance of 2 and 4 away, respectively.
After this initial exchange, each of the four routers builds an initial routing table:
A
B
2
B 2
C
D
4
A 2
C 4
3
B 4
D 3
C
3
Now, every router shares its table with its neighbors.
Consider this exchange from Router A's perspective. Router A receives from Router B the distance
vector shown above.
Hey, Router A, I have an entry in my table for Router C.
Router C is a distance of 4 away from me.
A
B
2
C
D
4
3
Hey, Router A, you're a genius.
But, Router B, you are a distance of 2 away from me, so…
Router C must be a distance of 6 away from me!!!
8
So, Router A changes its routing table to:
A
B
2
C
D
4
3
B 2
C 6
Now, consider the matter from Router B's perspective. Router C tells Router B: "Router D is a distance
of 3 away from me." Router B then reasons: "Router C is a distance of 4 away from me, and Router D
is a distance of 3 away from Router C, so Router D must be a distance of 7 away from me." So, Router
B changes its routing table to:
A
B
2
B 2
C 6
C
D
4
3
A 2
C 4
D 7
In a like manner, Router C and Router D change their routing tables based on the initial exchange.
Thus, after the initial exchange of packets is complete, the distance vectors are:
A
B
2
B 2
C 6
C
D
4
A 2
C 4
D 7
3
A 6
B 4
D 3
B 7
C 3
But… matters are not done yet! Now that routers have reconstituted their distance vectors, they
exchange them again! Note that distance vectors are exchanged with neighbors only. So, Router B tells
Router A: "Router D is 7 away from me." Router A then reasons: "Router D must be 9 away from me."
After all Routers reevaluate their distance vectors, we have this:
A
B
2
B 2
C 6
D 9
C
D
4
A 2
C 4
D 7
3
A 6
B 4
D 3
A 9
B 7
C 3
Hopefully this example convinces you that even though distance vectors are only exchanged with
immediate neighbors, information about the full network will eventually percolate to all routers.
9
But you are likely wondering: Okay… all the routers have distance vectors, but how do they use them
for routing? To fill in this last piece of the distance-vector puzzle, let's show a more complex example
(taken from the Tanenbaum text).
B. Distance Vector Routing
Consider the network shown on the left below. Further, suppose that for this scenario the weights used
in the network represent time delays. Obviously, we would like data to be routed with minimal delay.
You are Router J. Notice that you have four neighbors: A, I, H and K. Your delay to A is 8, your
delay to I is 10, your delay to H is 12 and your delay to K is 6. You receive the distance vectors shown
below on the right (the first column is the received distance vector from Router A, the second is from
Router I, the third from Router H and the last column is the received distance vector from Router K.
Distance Vector Routing
Your goal: Write down your new estimates of distances to all nodes, and annotate your distance vector
showing the next router on the best path to each destination.
From, Tanenbaum, Computer Networks, 3rd ed
Figure 5-9.(a) A subnet. (b) Input from A, I, H, K, and the
To seenew
how you
would accomplish
this,J.
let's focus on how you (Router J) would determine the best way
routing
table for
to route a packet to Router F.

Networks:
Your neighbor Router A is 8 away from
you. Routing
Router A says to you: "I can get to F in 23" 21
Thus, if
you use Router A as your next hop to Router F, you will get to Router F with a delay of 31.

Your neighbor Router I is 10 away from you. Router I says to you: "I can get to F in 20" Thus, if
you use Router I as your next hop to Router F, you will get to Router F with a delay of 30.

Your neighbor Router H is 12 away from you. Router H says to you: "I can get to F in 19" Thus, if
you use Router H as your next hop to Router F, you will get to Router F with a delay of 31.

Your neighbor Router K is 6 away from you. Router K says to you: "I can get to F in 40" Thus, if
you use Router K as your next hop to Router F, you will get to Router F with a delay of 46.
10
Comparing these four values, you (Router J) conclude that the best way to route a packet to Router F is
to send it to Router I. The total delay from Router J to Router F will be 30.
Example 3
You are Router J. Notice that you have four neighbors: A, I, H and K. Your delay to A is 8, your delay to I is
10, your delay to H is 12 and your delay to K is 6. You receive the distance vectors shown below on the right
(the first column is the received distance vector from Router A, the second is from Router I, the third from
Router H and the last column is the received distance vector from Router K.
Distance Vector Routing
Write down your new estimates of distances to all nodes, and annotate your distance vector showing the next
router on the best path to each destination.
From, Tanenbaum, Computer Networks, 3rd ed
Figure
Solution:5-9.(a) A subnet. (b) Input from A, I, H, K, and the
new routing table forTotal
J. Delay
Destination
Next Hop
Networks: Routing
A
B
C
D
E
F
G
H
I
J
K
L
11
21
Figure 22.17 Two-node instability
C. The “Count to Infinity” Problem in Distance Vector Routing
Consider the three-node network
shown below. Atop Node A and Node B, we show the entry in their routing table for Node X. Node X
is a distance of 2 away from Node A. Node X is a distance of 6 away from Node B. All is well.
Figure 22.17 Two-node instability
Then Node X dies. Node A does not receive a Hello packet and realizes Node X must have died. It
adjusts its routing table to show that Node X is unreachable (a distance of infinity away).
Figure 22.17 Two-node instability
Then, something weird happens, and it has nothing to do with the fact that the At Hoc alert announcing
the active shooter drill ended at 1046 did not actually get promulgated until 1245. Rather, this happens:
Router A receives a distance vector from Router B saying "I can reach Router X in a distance of 6."
Then…what do you do as Router A? You know that Router B is a distance of 4 away from you… and
he's saying that he can 22.34
reach X in a distance of 6… You update your routing table!
Figure 22.17 Two-node instability
2.34
22.34
Then you share your distance vector with B, and she updates her routing entry for X:
This exchange continues22.34
back and forth, until the cows come home, or until the cows come home blue in
the face, or until the cows come home blue in the face on a cold day in hell.
Forouzan, Data Communications and Networking, McGraw Hill, 2007
How can we limit or mitigate this instability? One proposed solution is to set some finite number =  .
If we set, for example, 30   , then after seven distance vector exchanges in the example above, both
Router A and Router B would have concluded that Router X was unreachable.
Most distance vector routing uses a hop-count metric, which means that the weight on each edge is equal
to one. To avoid the count-to-infinity problem, many algorithms set 16   .
12
3. Routing Protocol Summary
Distance Vector Routing:
o Is easy to implement
o In a static environment, the algorithm will correctly compute shortest paths to all
destinations.
But...
o In a dynamic environment route computations might not stabilize and/or might be
incorrect
o The algorithm does not scale well
Link State Routing:
o Each router does its own calculations (Dijkstra) independent of other routers.
o Convergence is better because calculations are local
o Better scalability
But...
o
Uses flooding.
Example 4
In the event that router G experienced a fatal power supply failure, which protocol would be best suited to
recovering from this failure and sharing correct routing information?
(a) Link State Routing
(b) Distance Vector Routing
(c) Both protocols are robust and would be unaffected by this anomaly.
Solution:
ITSD
Assistant Professor Patrick Vincent
Help us improve these notes! Send comments, corrections and clarifications to vincent@usna.edu
13
Problems
Problem 1.
(a)
Compare how well link-state algorithms and distance vector algorithms respond in the event of a router
failure.
(b)
Suppose a network uses distance vector routing. What would happen if a router sent a distance vector
with all zeros?
(c)
Describe the “count-to-infinity” problem. (Use a picture is you find it helpful.)
(d)
In distance vector routing, each router receives distance vectors from (choose one):
(i)
Every router in the network
(ii)
Its one-hop neighbors
(iii) DHCP
(iv)
The table set up by the network administrator
(v)
Messages exchanged using ARP
Problem 2.
Consider the network shown below which uses distance vector routing. You are router C. You have just
received the following distance vectors:
from B: (4, 0, 8, 13, 7, 2)
from D: (17, 11, 6, 0, 8, 10)
from E: (8, 6, 2, 10, 0, 4).
Your distances to B, D and E are 7, 4 and 6, respectively. What is your new routing table (include the distance
and next hop for each destination)?
B
C
A
D
E
F
14
Download