Distance Vector
Distance Vector
(Chapter 5 in Huitema)
E7310/comnet 1
Distance Vector Routing Principles
E7310/comnet 2
An Example
E7310/comnet 3
Distance vector routing idea
E7310/comnet 4
Generation of routing tables starts when all
routers send their DVs on all interfaces
Let’s look at reception in Node B.
First the table of B is:
1 2 From node B to … Link Distance
A B C
A=0 B - 0
A=0
E7310/comnet 5
B creates its own DV and
sends it to all neighbors
C to Link Distance
B=0, A=1 C - 0
A to Link Distance
1 2 B 2 1
A - 0 A B C
A 2 2
B 1 1 3 4 5
E to Link Distance
D E
A=2 > A=0 6 E - 0
B 4 1
A 4 2
E7310/comnet 6
D sends its distance vector to all neighbors
A to Link Distance
1 2
A - 0 A B C
B 1 1 3 4 5
D 3 1 E to Link Distance
D E
A=2 > A=0
6 E - 0
D=0, A=1 B 4 1
A 4 2
D 6 1
D = destination Legend:
R Routing table with entries (D,L,d)
d = distance + link cost R(D) Routing table entry for destination D
L = link of reception Rx(D) Field x of the entry for destination D
Yes
D⊂R
No
No L==Rl(D)
No
Yes d < Rd(D)
Yes
Add (D,L,d) to R Update R(D) = (D,L,d) Ignore
Note: this is simplified, shows only the principle!
E7310/comnet 10
A link breaks...
E7310/comnet 11
A round of updates starts on link failure
A=0,B=inf,D=1,C=inf,E=inf 3 4 5
D E
6
E7310/comnet 12
D, E and C update their routing tables
B=0, A=inf, D=inf, C=1, E=1
+1=
B=1, A=inf, D=inf, C=2, E=2
A=0, B=inf, D=1,C=inf, E=inf 1 2 C to Link Distance
+1 = A B C C - 0
A=1, B=inf, D=2,C=inf, E=inf
3 4 5 B 2 1
A 2 Inf.
D E
6 E 5 1
D 5 2
E7310/comnet 13
D, C, E generate their distance vectors...
B to Link Distance
B - 0
A to Link Distance A 1 Inf.
A - 0 D 4 2
B 1 Inf. C 2 1
D 3 1 E 4 1
C 3 3 1 2
A B C C=0,B=1,A=inf,E=1,D=2
E 3 2
3 4 5
D=0,A=1,B=inf,E=1,C=2 D 6
E E=0,B=1,A=inf,D=1,C=1
B=0,A=inf,D=2,C=1,E=1
A=0,B=inf,D=1,C=3,E=2 A B C
1 2
3 4 5
D=0,A=1,B=2,E=1,C=2 D E E=0,B=1,A=2,D=1,C=1
6
The result is that all nodes are able to communicate with all other nodes again.
E7310/comnet 15
Routing loops
B C
E7310/comnet 16
The DV-protocol may create a transient
routing loop
1 2 Let’s assume that cost of link 5 is 8.
A B C
3 4 5
8 A stable initial state for routes to C
would be:
D E
6 x to C
Link Distance
from x
A→C 1 2
B→C 2 1
Let’s just look at the first C→C - 0
link of each route. D→C 3 3
E→C 4 2
transient =E7310/comnet
hetkellinen, ohimenevä 17
Link 2 fails
x to C
Link Distance
from x
first Intermediate
arr iv e A→C 1 2
ens to state
happ
to B B→C 2 Inf.
o mA
DV fr B=0,A=1,D=2,C=3,E=1 C→C - 0
1 2 D→C 3 3
A=0,B=1,D=1,C=2,E=2 A B C
E→C 4 2
3 4 5
D E x to C
Link Distance
6 from x
A→C 1 42
All packets to C are sent to B.
B→C 1 3
B sends them to A. A sends
them back to B… until TTL=0. C→C - 0
(Bouncing effect) D→C 3 3
E→C 4 24
E7310/comnet 18
A and E send their distance vectors
x to C
Link Distance
from x
1 A→C 1 4
B→C 1 5
A=0,B=1,D=1,C=4,E=2 A 1 B 2 C C→C - 0
D→C 3 5
3 4 5 2
E→C 4 4
D E
6 B generates a new DV:
B=0,A=1,D=2,C=5,E=1
E7310/comnet 19
A sends a new distance vector
x to C
Link Distance
from x
1 A→C 1 6
B→C 1 7
A=0,B=1,D=1,C=6,E=2 A 1 B 2 C C→C - 0
D→C 3 7
3 4 5 E→C 4 6
2
D E
6
B generates a new DV
B=0,A=1,D=2,C=7,E=1
E7310/comnet 20
A sends a new distance vector
x to C
Link Distance
from x
1 A→C 1 8
B→C 1 9
A=0,B=1,D=1,C=8,E=2 A 1 B 2 C C→C - 0
D→C 3 9
3 4 5 E→C 4 8
2
D E
6
B generates a new DV
B=0,A=1,D=2,C=9,E=1
E7310/comnet 21
Finally the distance (0+8) sent by C is
accepted as a shorter distance by E
x to C
Link Distance
from x
1 A→C 1 10
B→C 1 11
A=0,B=1,D=1,C=10,E=2 A 1 B 2 C C→C - 0
D→C 3 11
3 4 5 E→C 5 8
2
D E
6
B generates a new DV
B=0,A=1,D=2,C=11,E=1
E generates a new DV
E=0,B=1,A=2,D=1,C=8
E7310/comnet 22
When E sends a new distance vector,
B and D learn a route to C
x to C
Link Distance
A 1 B
2
C
from x
A→C 1 10
3 4 5 B→C 4 9
C→C - 0
D E
6 D→C 6 9
E=0,B=1,A=2,D=1,C=8 E→C 5 8
E7310/comnet 23
B send its DV but the tables are already OK
x to C Link Distance
1 2 B=0,A=1,D=2,C=9,E=1
from x
A B C
A→C 1 10
3 4 5 B→C 4 9
C→C - 0
D E
6 D→C 6 9
E→C 5 8
• Each update round increased the costs by 2
• The process progresses in a random order, because it is
genuinely parallel in nature.
• During the process, the state of the network is bad. DV-
packets may be lost due to the overload created by bouncing
user messages
E7310/comnet 24
Questions
• What would be a reasonable goal for setting a link metric of
link 5 to a higher value than the rest of the links?
• What would be a good reason to set the link metric of link 5
to the value of 8, provided all other links are set to 1?
• If there is no good reason for the value of 8, what would be
the max reasonable value for some purpose?
The Bellman–Ford algorithm is an algorithm that computes shortest paths from a single source
vertex to all of the other vertices in a weighted digraph.[1]
It is slower than Dijkstra's algorithm for the same problem, but more versatile, as it is capable of
handling graphs in which some of the edge weights are negative numbers. The algorithm is usually named
after two of its developers, Richard Bellman and Lester Ford, Jr., who published it in 1958 and 1956,
respectively; however, Edward F. Moore also published the same algorithm in 1957, and for this
reason it is also sometimes called the Bellman–Ford–Moore algorithm.[1]
E7310/comnet 25
Counting to infinity
B C
E7310/comnet 26
Counting to infinity occurs when failures
break the network into isolated islands (1)
B C
E7310/comnet 31
The first method to avoid loops is to
send less information
The split horizon rule:
If node A sends to node X through node B, it does not A
make sense to advertise that B should reach X through A
⇒ A should not advertise to B its short distance to X
B
Implementation choices:
1. Split horizon
• A does not advertise its distance to X towards B at all
⇒ the loop of previous example can not occur
E7310/comnet 32
Split horizon example
A to Link Distance
A C
B 3 1 1
A - 0 3
D 3 2
C 1 1 B D
2
• Normally:
– A sends: A=0,B=1,C=1,D=2 Note that the DV sent on
• Split horizon: link 1 is different from the
one sent on link 3.
– A sends: A=0,C=1
• Split horizon with poisonous reverse:
– A sends: A=0,B=inf,C=1,D=inf
• Link 1 is broken,
and the network
1 2
has recovered. A B C
3 4 5
• All link costs = 1
D E
6
x to D
Link Distance
from x
B→D 4 2
C→D 5 2
E→D 6 1
E7310/comnet 34
Three-node loops are still possible (2)
x to D
Link Distance
from x
B→D 4 2
C→D 5 2
E→D 6 Inf.
E7310/comnet 35
Three-node loops are still possible (3)
E7310/comnet 36
Three-node loops are still possible (4)
3 4 5
C=0,B=1,A=inf,E=inf,D=inf
D E
6
• B generates its
poisoned distance B=0,A=inf,D=inf,C=inf,E=1
vectors 1 2
• The three node loop is A B C
ready
3 4 5
• On link 5 cost=4 is B=0,A=4,D=3,C=1,E=inf
advertised. C’s
knowledge about the D
6
E
distance to D
grows ...
• Routes to D do not x to D Link Distance
change except that the from x
costs keep growing,
nodes count to infinity. B→D 2 3
This finally breaks the C→D 5 2
loop. E→D 4 4
E7310/comnet 38
How often should a DV-protocol advertise?
E7310/comnet 39
The second method to avoid loops is
to use triggered updates
• A triggered update happens when an entry in the routing
table is modified (e.g. when a link breaks)
• Triggered updates reduce the probability of loops
• Triggered updates also speed up counting to infinity
• RIP advertises both
– when the refresh timer expires (periodical updates), and
– when a change occurs in an entry (triggered updates)
• Loops are still possible, e.g. because of packet loss
E7310/comnet 40
The Bellman-Ford algorithm
E7310/comnet 41
The Bellman-Ford algorithm
Definitions
• Definitions:
– Let N be the number of nodes and M the number of links.
– L is the link table with M rows, L[l].m - link metric
L[l].s - link source
L[l].d - link destination
– D is an N × N matrix, such that D[i,j] is the distance from i to j
– H is an N × N matrix, such that H[i,j] is the link that i uses to send
to j
D 1 .. i .. N
1 Both directions are presented
:
distance separately in the link matrix and
j from i distance matrix
to j
:
N Column i ≡ Distance vector of node i
E7310/comnet 42
The Bellman-Ford algorithm
Initialized distance and link matrices
From node i to node j
1 .. i .. N i
1 .. .. N
1 0 ∞ ∞ ∞ ∞ 1 -1 -1 -1 -1 -1
: ∞ 0 ∞ ∞ ∞ : -1 -1 -1 -1 -1
j ∞ ∞ 0 ∞ ∞ j -1 -1 -1 -1 -1
: ∞ ∞ ∞ 0 ∞ : -1 -1 -1 -1 -1
N ∞ ∞ ∞ ∞ 0 N -1 -1 -1 -1 -1
Distance matrix D Link matrix H
Column=Known distances at i Column=Routing table at i
E7310/comnet 43
The Bellman-Ford algorithm
Centralized algorithm
1. Initialization: (previous slide)
A D X
link l
i=A j=D k=X
Column H(i, …) is the routing table at i, destination (j) is the index to the column entry. D – distances matrix.
L is what we receive in the nodes: l marks the link on which we receive, .d marks the destination and
.m the distance we got for the destination.
This does not show link breaks etc other continuous changes. Only initial forming of the routing table based
on the idea that all elements work without faults. Algortihm on slide 55 has a bit more detail.
In a network, each i runs this for itself. In a centralized setting, a server must run this for nodes at the same time.
E7310/comnet 45
The Bellman-Ford algorithm
Properties
• First in D-matrix appear one hop link distances, then
two hop link distances, etc.
• Number of steps ≤ N
(because there cannot be a path longer than N)
• Each step requires N·M operations
⇒ Complexity: O(M·N2)
• In the distributed version the columns are processed
in parallel
⇒ Complexity of the distributed version: O(M·N)
E7310/comnet 46
RIP version 1
E7310/comnet 47
Routing Information Protocol (RIP)
RFC
1058
E7310/comnet 48
RIP metrics
E7310/comnet 49
RIP-protocol properties
E7310/comnet 50
RIP timers
• Refresh timer = 30 s
– The update for the entry is sent every 30 s
• Obsolescence timer = 180 s
– The distance is set to infinite if no update has been received within
180s
• A entry whose distance has been infinite for 60 s is deleted
• Advertisements are randomized to avoid bursts of updates
• A triggered update is delayed a random time 1-5 s
• Note: Defining fixed timers as part of a protocol is not
recommended today!
E7310/comnet 51
RIP message format
Command Version = 1
1 = Request
2 = Response
32 bits
E7310/comnet 52
RIP routing table entries
E7310/comnet 53
RIP routing table
A routing table entry contains (at least):
• Destination IP address (network)
• Distance (metric) to destination
• Next hop IP address
• “Recently updated” flag
• Several timers (refresh, obsolescence...)
E7310/comnet 54
Processing of Received Distance Vectors
Yes
D⊂R
No
No L==Rl(D)
No
Yes d < Rd(D)
Yes
Add (D,L,d) to R Update R(D) = (D,L,d)
E7310/comnet 56
RIP request messages
E7310/comnet 57
Silent nodes
• When only RIP was used, hosts could listen to routing traffic
and maintain their own routing tables
– Which router is closest to the destination?
– Which link, if several available?
• These where ”silent nodes”, that only listened to routing traffic
without sending
• Nowadays there are too many routing protocols
– RIP-2, OSPF, IGRP, ...
r ica l
Interior Gateway Routing Protocol (IGRP) Histo
E7310/comnet 58
RIP version 2
E7310/comnet 59
RIP version 2
• Why?
– Simple and lightweight alternative to OSPF and IS-IS
• RIP-2 is an update that is partially interoperable with RIP-1
– A RIP-1 router understands most of what a RIP-2 router is saying.
• Improvements
– Authentication
– Support for CIDR (Classless Inter-Domain Routing)
– Next hop – field
– Subnet mask
– Support for external routes
– Updates with multicast RFC RFC RFC
Intermediate System to Intermediate System (IS-IS) 1387 1388 1389
E7310/comnet 60
RIP version 2 message format
Version = 2 External routes are tagged Removed from standard
32 bits
E7310/comnet 62
Routing from one sub-net to another (2)
C
D
E7310/comnet 63
Route redistribution
E7310/comnet 64
Routing domain and next hop
AS X AS Y
A B C
D E F
Router with 2
routing Tables X and Y.
RIP1:
D advertises in AS X that the distance to F is f (the next hop is the advertising
router D).
RIP2 with next hop field:
D advertises in AS X that the distance to F is f and the next hop is E.
E7310/comnet 65
Support for local multicast
E7310/comnet 66
The synchronization problem
– why timers must be randomized
• Routers have a spontaneous tendency to synchronize their
send times.
– Traffic bursts increase the probability of packet loss
• Reason: send interval = constant + time of message packing
+ processing time of messages that are in the queue.
• Routers send at the same time ⇒ Longer processing time ⇒
Longer delay than of other routers ⇒ Sending instance
occurs at the same time as of other routers
• Solution: send instants are randomized between 15s ... 45s.
• Common problem in several distributed protocols
E7310/comnet 67
Acknowledged updates (extension)
E7310/comnet 68
Summary
E7310/comnet 69