0% found this document useful (0 votes)
38 views65 pages

CN - Module 4 Part 1 2024

Introduction, General Idea, Least-Cost Routing, Distance Vector Routing, Link-State Routing, Path-Vector Routing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
38 views65 pages

CN - Module 4 Part 1 2024

Introduction, General Idea, Least-Cost Routing, Distance Vector Routing, Link-State Routing, Path-Vector Routing.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 65

By

Dr. Jagadamba G
Dept. of ISE, Siddaganga Institute of Technology, Tumakuru
UNICAST ROUTING

20.1. Introduction
20.2 Routing Algorithms
20.3 Unicast Routing Protocols
INTRODUCTION

• Routing is the process of path selection in any network.


• Various methods are there in building the routing: Static and
dynamic routing.
Static routing
 Routing table is created, maintained and updated by network
administrator manually.
 A static route to every network must be configured on every router for
the full connectivity.
 This is adoptable only in small networks not on the larger network.
 As router does not share any details on their with each other, reduces
the CPU utilization and saves the bandwidth.
 It is not fault tolerant, as any changes to the routing infrastructure(in
the case of link failure or new network addition) requires manual
intervention.
 It is totally secured as any changes are updated only through network
administration.
Dynamic routing
 It is created, maintained and updated by routing protocol running on
the router
 The best route choice is made by routing protocol on the router and
not the network administrator
 Ex: RIP(Routing Information protocol, OSPF(Open shortest path
routing protocol)
 Routers share routing information with each other, hence CPU
utilization and Bandwidth usage is increased.
Popular routing protocols

Routing protocols can be classified as : Intradomain and Interdomain


routing protocols

Intradomain Interdomain
• It is a protocol in which • It is the protocol in which
Routing algorithm works only Routing algorithm works within
within the domains (only in and between domains (among
autonomous network) autonomous network) .
• In interdomain routing • While in intradomain routing
Interior-gateway protocols such Exterior-gateway protocols such
as RIP(Resource/ Routing as BGP(Border Gateway
information protocol-Distance Protocol-Path Vector) are being
Vector) and OSPF(open shortest get used in case of IntraDomain
path first-Link sate) are being Routing.
used
INTRODUCTION

• In an internet, the goal of the network layer is to deliver a


datagram from its source to its destination or destinations.
• If a datagram is destined for only one destination (one-to- one
delivery), we have unicast routing.
• If the datagram is destined for several destinations (one- to-many
delivery), we have multicast routing.
• A router uses a forwarding table to route packets in internet.
• To make the forwarding tables of the router, the Internet needs
routing protocols that will be active all the time in the
background and update the forwarding tables.
20.1 Unicast Routing
● Unicast routing in the Internet, with a large number of routers and
a huge number of hosts, can be done only by using hierarchical
routing: routing in several steps using different routing algorithms.
● In unicast routing, a packet is routed, hop by hop, from its source to
its destination by the help of forwarding tables.
• The source host needs no forwarding table because it delivers
its packet to the default router in its local network.
• The destination host needs no forwarding table either because
it receives the packet from its default router in its local
network.
• This means that only the routers that glue together the networks in
the internet need forwarding tables.
• Now routing a packet from its source to its destination means
routing the packet from a source router (the default router of
the source host) to a destination router (the router connected to
the destination network).
An Internet as a Graph

• To find the best route, an internet can be modeled as a graph.


• A graph in computer science is a set of nodes and edges (lines)
that connect the nodes.
• To model an internet as a graph, we can think of each router
as a node and each network between a pair of routers as
an edge.
• An internet is, in fact, modeled as a weighted graph, in which
each edge is associated with a cost.
An Internet as a Graph
Least-Cost Routing
● When an internet is modeled as a weighted graph, one of the
ways to interpret the best route from the source router to the
destination router is to find the least cost between the two.
● In other words, the source router chooses a route to the
destination router in such a way that the total cost for the
route is the least cost among all possible routes.
● Here each router needs to find the least-cost route
between itself and all the other routers to be able to route a
packet
Least-Cost Trees
● If there are N routers in an internet, there are (N −1) least-cost paths from
each router to any other router.
● This means we need N ×(N −1) least-cost paths for the whole internet.
● A better way to see all of these paths is to combine them in a least-cost tree.
● A least-cost tree is a tree with the source router as the root that spans the
whole graph (visits all other nodes) and in which the path between the root
and any other node is the shortest.
Least-Cost Trees Properties

1 The least-cost route from X to Y in X’s tree is the


inverse of the least-cost route from Y to X in Y’s
tree; the cost in both directions is the same.
2 Instead of travelling from X to Z using X’s tree, we
can travel from X to Y using X’s tree and continue from
Y to Z using Y’s tree.
Eg : A → B→E→F→G
(A → B→ E) (E → F→ G).
20.2 ROUTING ALGORITHMS

Distance-Vector Routing- Background


 Goes with the name Bellman-Ford algorithm
 Started using in ARPANET
 Later in Internet
 Now it is not used
20.2 ROUTING ALGORITHMS

Distance-Vector Routing
• In distance-vector routing, each node creates a one
dimensional array (a vector) containing the distance(cost)
to all other nodes and distributes the same infor mation to
its immediate neighbors.
• We can say that in distance-vector routing, a router
continuously tells all of its neighbors what it knows
about the whole internet for every T seconds.
• Ever y routing table entries has: Destination,
Distance/cost, Next hop
Bellman-Ford Equation

Where Dij is the shortest distance and Cij is the cost between nodes i and j

we can think of (a → y), (b → y), and (c → y) as previously


established least-cost paths and (x → y) as the new least-cost
path. We can say that the Bellman-Ford equation enables us to
build a new least-cost path from previously established least-cost
paths.
Distance Vectors

• A distance vector is a rationale for the distance vector routing.


• A least cost tree is a combination of least cost paths from the root of the
tree to all the destinations.
• These paths are graphically glued together for the tree.
• The distance vector routing unglues these paths and creates a distance
vector, a one dimensional array to represent the tree.
Distance Vectors
How is this vector created?
● Each node in an internet, when it is booted, creates a very
rudimentary distance vector with the minimum information
the node can obtain from its neighborhood.
● The node sends some greeting messages out of its interfaces
and discovers the identity of the immediate neighbors and
the distance between itself and each neighbor.
● Unknown cells value are set to infinity.
● These initial vectors are created asynchronously.
● After each node has created its vector, it sends a copy
of the vector to all its immediate neighbors.
● Then update the distance vectors using the Bellman-
Ford equation
First Distance Vectors
Updating Distance Vectors
First event: B receives a copy of A’s vector.
Second event: B receives a copy of E’s vector.

https://www.youtube.com/watch?v=q72LA1pXoiU
Updating Distance Vectors

A B C D E F G

Destinati Distance Hop G


on
Tutorial 6 :
Simple steps for Distance Vectors
Step-01:

Each router prepares its routing table. By their local knowledge. each router
knows about-
•All the routers present in the network
•Distance to its neighboring routers

Step-02:

•Each router exchanges its distance vector with its neighboring routers.
•Each router prepares a new routing table using the distance vectors it has
obtained from its neighbors.
•This step is repeated for (n-2) times if there are n routers in the network.
•After this, routing tables converge / become stable.
Tutorial 4 : Exercises - Explanation for Distance Vectors step wise

Example: Consider-
• There is a network consisting of 4 routers.
• The weights are mentioned on the edges.
• Weights could be distances or costs or delays.
Step-01:
• Each router prepares its routing table using its local knowledge.
• Routing table prepared by each router is shown below-
Router A Router B
Destination Distance Next Hop Destination Distance Next Hop

A 0 A A 2 A
B 2 B B 0 B
C ∞ – C 3 C
D 1 D D 7 D

Router C Router D
Destination Distance Next Hop Destination Distance Next Hop
A ∞ – A 1 A
B 3 B B 7 B
C 0 C C 11 C
D 11 D D 0 D
Tutorial 4 : Exercises
Step-02:
• Each router exchanges its distance vector obtained in Step-01 with its neighbours.
• After exchanging the distance vectors, each router prepares a new routing table.

Router A

• Router A receives distance vectors from its neighbors B and D.


• Router A prepares a new routing table as-

Destination Distance Next Hop

• Cost of reaching destination B from router A = min { 2+0 , 1+7 } = 2 via B. A 0 A


• Cost of reaching destination C from router A = min { 2+3 , 1+11 } = 5 via B. B 2 B
• Cost of reaching destination D from router A = min { 2+7 , 1+0 } = 1 via D. C 5 B
D 1 D
Tutorial 4 : Exercises
Step-02:
• Each router exchanges its distance vector obtained in Step-01 with its neighbours.
• After exchanging the distance vectors, each router prepares a new routing table.

Router B

• Router B receives distance vectors from its neighbors A, C and D.


• Router B prepares a new routing table as-

Destinati
Distance Next Hop
on
• Cost of reaching destination A from router B = min { 2+0 , 3+∞ , 7+1 } = 2 via A. A 2 A
• Cost of reaching destination C from router B = min { 2+∞ , 3+0 , 7+11 } = 3 via C. B 0 B
• Cost of reaching destination D from router B = min { 2+1 , 3+11 , 7+0 } = 3 via A. C 3 C
D 3 A
Tutorial 4 : Exercises
Step-02:
• Each router exchanges its distance vector obtained in Step-01 with its neighbours.
• After exchanging the distance vectors, each router prepares a new routing table.

Router C

• Router C receives distance vectors from its neighbors B and D.


• Router C prepares a new routing table as-

Destinatio
Distance Next Hop
n
A 5 B
• Cost of reaching destination A from router C = min { 3+2 , 11+1 } = 5 via B. B 3 B
• Cost of reaching destination B from router C = min { 3+0 , 11+7 } = 3 via B.
C 0 C
• Cost of reaching destination D from router C = min { 3+7 , 11+0 } = 10 via B.
D 10 B
Tutorial 4 : Exercises
Step-02:
• Each router exchanges its distance vector obtained in Step-01 with its neighbours.
• After exchanging the distance vectors, each router prepares a new routing table.

Router D

• Router D receives distance vectors from its neighbors A, B and C.


• Router D prepares a new routing table as-

Destinatio
Distance Next Hop
n
A 1 A
• Cost of reaching destination A from router D = min { 1+0 , 7+2 , 11+∞ } = 1 via A.
B 3 A
• Cost of reaching destination B from router D = min { 1+2 , 7+0 , 11+3 } = 3 via A.
• Cost of reaching destination C from router D = min { 1+∞ , 7+3 , 11+0 } = 10 via B. C 10 B
D 0 D
Tutorial 4 : Exercises
Step-03:
• Each router exchanges its distance vector obtained in Step-02 with its neighboring routers.
• After exchanging the distance vectors, each router prepares a new routing table.

Router A

• Router A receives distance vectors from its neighbors B and D.


• Router A prepares a new routing table as-

Destinatio
Distance Next Hop
n
A 0 A
• Cost of reaching destination B from router A = min { 2+0 , 1+3 } = 2 via B. B 2 B
• Cost of reaching destination C from router A = min { 2+3 , 1+10 } = 5 via B. C 5 B
• Cost of reaching destination D from router A = min { 2+3 , 1+0 } = 1 via D.
D 1 D
Tutorial 4 : Exercises
Step-03:
• Each router exchanges its distance vector obtained in Step-02 with its neighbouring routers.
• After exchanging the distance vectors, each router prepares a new routing table.

Router B

• Router B receives distance vectors from its neighbors A, C and D.


• Router B prepares a new routing table as-

Destinati Next
Distance
on Hop
A 2 A
• Cost of reaching destination A from router B = min { 2+0 , 3+5 , 3+1 } = 2 via A. B 0 B
• Cost of reaching destination C from router B = min { 2+5 , 3+0 , 3+10 } = 3 via C. C 3 C
• Cost of reaching destination D from router B = min { 2+1 , 3+10 , 3+0 } = 3 via A. D 3 A
Tutorial 4 : Exercises
Step-03:
• Each router exchanges its distance vector obtained in Step-02 with its neighbouring routers.
• After exchanging the distance vectors, each router prepares a new routing table.

Router C

• Router C receives distance vectors from its neighbours B and D.


• Router C prepares a new routing table as-

Destin Distanc Next


ation e Hop
A 5 B
• Cost of reaching destination A from router C = min { 3+2 , 10+1 } = 5 via B. B 3 B
• Cost of reaching destination B from router C = min { 3+0 , 10+3 } = 3 via B.
C 0 C
• Cost of reaching destination D from router C = min { 3+3 , 10+0 } = 6 via B.
D 6 B
Tutorial 4 : Exercises
Step-03:
• Each router exchanges its distance vector obtained in Step-02 with its neighbouring routers.
• After exchanging the distance vectors, each router prepares a new routing table.
Router D
• Router D receives distance vectors from its neighbours A, B and C.
• Router D prepares a new routing table as-

Destin Distan Next


• Cost of reaching destination A from router D = min { 1+0 , 3+2 , 10+5 } = 1 via A.
ation ce Hop
• Cost of reaching destination B from router D = min { 1+2 , 3+0 , 10+3 } = 3 via A. A 1 A
• Cost of reaching destination C from router D = min { 1+5 , 3+3 , 10+0 } = 6 via A. B 3 A
C 6 A
D 0 D
Tutorial 4 : Exercises 2

A B C D E S

S
Distance-Vector Routing Algorithm
Distance_Vector_Routing ( )
{// Initialize (create initial vectors for the node)
D[myself ] =0
for (y =1 to N){
if (y is a neighbor)
D[y] =c[myself ][y]
else
D[y] =∞
}
Distance-Vector Routing Algorithm
send vector {D[1], D[2], ..., D[N]} to all neighbors
// Update (improve the vector with the vector received from a neighbor)
repeat (forever) {
wait (for a vector Dw from a neighbor w or any change in the link)
for (y =1 to N) {

D[y] =min [D[y], (c[myself ][w] +D w [y ])] // Bellman-Ford equation


}
if (any change in the vector)
send vector {D[1], D[2], ..., D[N]} to all neighbors
}
} // End of Distance Vector
What happens when Link Failure occurs?
Distance Vectors

• Apart from this, the distance vector routing has some


problems:
1. Fast response to good news(ex: if any node gets
into the network)
2. Slow response to bad news(ex: if any node or
link fails in the network)
3. Too many messages to update
Count to Infnity
• A problem with distance-vector routing is that any
decrease in cost (good news) propagates quickly, but any
increase in cost (bad news) will propagate slowly.
• For a routing protocol to work properly, if a link is broken
(cost becomes infinity), every other router should be aware of it
immediately, but in distance-vector routing, this takes some
time.
• The problem is referred to as count to infinity.
• Let us consider an example of two node loop to know
the problem of count to infinity
Two-Node Loop
•At the beginning, both nodes A and B know how to reach node X. But suddenly, the
link between A and X fails.

•Node A changes its table. If A can send its table to B immediately, everything is
fine.
•However, the system becomes unstable if B sends
its routing table to A before receiving A’s routing
table.

•Node A receives the update and, assuming that B


has found a way to reach X, immediately updates
its routing table.

•Now A sends its new update to B. Now B thinks


that something has been changed around A and
updates its routing table.

•The cost of r eaching X increases gr adually until


it r eaches infinity.
22
Two-Node Loop

• At this moment, both A and B know that X cannot be reached.


However, during this time the system is not stable.
• Node A thinks that the route to X is via B; node B thinks that
the r oute to X is via A.
• If A receives a packet destined for X, it goes to B and then comes
back to A. Similarly, if B receives a packet destined for X, it goes to A
and comes back to B.
• Packets bounce between A and B, creating a two-node loop
problem- Defining Infinity
• The first obvious solution is to redefine infinity to a smaller
number, such as 16.
Split Horizon

• Instead of flooding the table through each interface, each


node sends only part of its table through each interface.

• Taking information from a node, modifying it, and sending it


back to the same node is what creates the confusion.

• As node B thinks that the optimum route to reach X is


via A, it does not need to advertise this piece of
information to A; the information has actually come
from A

• Node B eliminates the last line of its forwarding table before it


sends it to A. In this case, node A keeps the value of infinity as
the distance to X.
23
Split Horizon and Poison Reverse
● The split horizon strategy can be combined with the poison
reverse strategy.

● Node B can still advertise the value for X, but if the source
of information is A, it can replace the distance with infinity
as a warning: “Do not use this value; what I know about
this route comes from you.”

23
Link-State Routing
● This method uses the term link-state to define the
characteristic of a link (an edge) that represents a network in
the internet.
● In this algorithm the cost associated with an edge defines the
state of the link.
● Links with lower costs are preferred to links with higher
costs; if the cost of a link is infinity, it means that the link
does not exist or has been broken.
● To create a least-cost tree with this method, each node needs
to have a complete map of the network, which is represented
using a Link-State Database (LSDB).
● The LSDB can be represented as a two-dimensional
array(matrix) in which the value of each cell defines the
cost of the corresponding link.
Link-State Database

Link State Distance Vector


Complete Topology Local Topology
Flooding Exchange
Global Decentralized
Tell the world about neighbours Tell the neighbours about the world
Building a LSDB
● LSDB is created by a process called flooding.
● Each node can send some greeting messages to all its
immediate neighbors to collect two pieces of information for
each neighboring node: the identity of the node and the cost
of the link.
● The combination of these two pieces of information is
called the LS packet (LSP); the LSP is sent out of each
interface
● When a node receives an LSP from one of its interfaces, it
compares the LSP with the copy it may already have.
● If the newly arrived LSP is older than the one it has (found
by checking the sequence number), it discards the LSP.
● If it is newer or the first one received, the node discards
the old LSP (if there is one) and keeps the received one.
Building a LSDB
● It then sends a copy of it out of each interface except the one
from which the packet arrived.
● This guarantees that flooding stops somewhere in the network.

● After receiving all new LSPs, each node creates the


comprehensive LSDB
Comparison
● In the distance-vector routing algorithm,
– each router tells its neighbors what it knows about the
whole internet;
● In the link-state routing algorithm,
– each router tells the whole internet what it knows about
its neighbors.

Link state is used in intradomain routing


Formation of Least-Cost Trees

Dijkstra algorithm is used to build the routing table


I.e., to create a least-cost tree for each node
1.The node chooses itself as the root of the tree, creating a tree
with a single node, and sets the total cost of each node based
on the information in the LSDB.
2.The node selects one node, among all nodes not in the tree,
which is closest to the root, and adds this to the tree. After this
node is added to the tree, the cost of all other nodes not in the
tree needs to be updated because the paths may have been
changed.
3. The node repeats step 2 until all nodes are added to the tree.
Dijkstra algorithm
Dijkstra’s Algorithm
● Initialization
Example 1
Routing table for node A
Each router must do the following:
1. Discover its neighbors, learn their network address.

2. Measure the delay or cost to each of its neighbors.

3. Construct a packet telling all it has just learned.

4. Send this packet to all other routers.

5. Compute the shortest path to every other router.

A complete topology is developed. Then Dijkstra’s Algorithm can be used


to compute the shortest path.
Following 5 steps are followed to implement it.
1. Learning about the Neighbors
2. Measuring Line Cost.
3. Building Link State Packets.
4. Distributing the Link State Packets.
5. Computing the New Routes.
Example 2 for Building Link State Packets

Age/TTL
Example 3 (alternative representation of table)

1. Initially

2. Step for vector = Source= b


Example 3

3. Step for vector = a

4. Step for vector = c


Example 3

5. Step for vector = d

6. Step for vector = e


Example 3

7. Step for vector = f


Path-Vector Routing
• A path-vector routing protocol is a network routing protocol
which maintains the path information that gets updated
dynamically. Updates that have looped through the network and
returned to the same node are easily detected and discarded.
• In some cases routing is not based on least cost but may be
based on other considerations -like avoiding a particular router
• To respond to these demands, a third routing algorithm,
called path-vector (PV) routing has been devised.
• The best route is determined by the source using the policy it
imposes on the route.
• In other words, the source can control the path.
• Path-vector routing is not actually used in an internet, and is
mostly designed to route a packet between ISPs
Spanning Trees
• In path-vector routing, the path from a source to all
destinations is also determined by the best spanning tree.

• The spanning tree should have:


 Single path between each pair of nodes
 No loops, so can support broadcast easily

• Some common policies are


 The best spanning tree, however, is not the least-cost tree; it
is the tree determined by the source when it imposes its
own policy.
 minimum number of nodes to be visited to avoid some nodes as
the middle node in a route.
 Each source creates its own spanning tree that meets its policy.
Spanning trees in path-vector routing

● The policy imposed by all sources is to use the minimum number of


nodes to reach a destination.
1. The spanning tree A and E
– communication does not pass through D as a middle node.
2. The spanning tree B
– communication does not pass through C as a middle node.
Creation of Spanning Trees
● The spanning trees are made gradually and asynchronously,
by each node.
● When a node is booted, it creates a path vector based on the
information it can obtain about its immediate neighbor.
● A node sends greeting messages to its immediate neighbors to
collect these pieces of information.
Path vectors made at booting time
Updating path vectors
● Each node, when it receives a path vector from a neighbor,
updates its path vector using an equation similar to the
Bellman-Ford, but applying its own policy instead of looking
for the least cost.
● We can define this equation as
Path(x, y) = best {Path(x, y), [(x +Path( v , y)]}
for all v ’s in the internet.
● In this equation, the operator (+) means to add x to the
beginning of the path.
● If Path (v, y) includes x, that path is discarded to avoid a loop
in the path.
● In other words, x does not want to visit itself when it selects a
path to y.
C receives a copy of B’s vector

● Node C receives a copy of B’s vector, which improves its


vector: now it knows how to reach node A.
C receives a copy of D’s vector

● node C receives a copy of D’s vector, which does not change


its vector.
Path-Vector Algorithm

You might also like