Question
a) Modify the distance-vector-routing pseudo-code such that each pair of neighboring nodes (p, q) has a cost for the directed edge (p, q) and a
a) Modify the distance-vector-routing pseudo-code such that each pair of neighboring nodes (p, q) has a cost for the directed edge (p, q) and a cost for the directed edge (q, p). Furthermore, have each node remember the cost vector received by its neighbor, and take advantage of this new information that it maintains.
b) Add split-horizon with poisoned-reverse to your pseudo-code in a) above.
Code: declarations:
node p
inp
G : set {g | g is a neighbor of p}
up : array [G] of boolean, {is my neighbor up? or dead?}
var
rtb : array [NID] of G, {routing table}
cost : array [NID] of integer, {cost to reach each node}
d : NID, {temporary variable}
c : array [NID] of integer {temporary variable}
param
g: element of G {g can be any neighbor}
Code: actions (data):
begin
event: receive data(d) from g
resp:
if d = p then skip {arrived}
else if d p cost[d] < then send data(d) to node rtb[d]
else if d p cost[d] = then skip {non reachable}
end if
Code: send distance vector action, and detect down neighbors action:
event: true {at anytime, send cost to all neighbors}
resp:
if up[g] then send update(cost) to node g
end if
event: ~up[g] {has the neighbor died?}
resp:
for every d do
if rtb[d] = g then cost[d] =
end if
end for
Code: receive distance vector:
event: receive update(c) from g then
resp: {compare costs to all destinations}
for every d do {for every destination, compare c[] and cost[]}
if d = p then cost[p] := 0
end if
if d p (rtb[d] = g c[d] + 1 < cost[d])
then {change routing table to point to g for dest. d}
rtb[d] := g;
cost[d] := c[d]+1 {I assume link cost of 1 for simplicity}
end if
end for
end {code}
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started