Computer
Network
TOPICS :
DISTANCE VECTOR ROUTING
DISTANCE VECTOR ROUTING WITH AN EXAMPLE
LINK STATE ROUTING
LINK STATE ROUTING WITH AN EXAMPLE
Distance Vector Routing
What is Distance Vector Routing ?
Distance Vector Routing is a routing algorithm used in
computer networks to help routers find the best path to send
data packets.
In distance vector routing, each router tells its neighbors
about the shortest distance (number of hops) to reach every
other router in the network.
Distance vector routing
with an example
• A, B, C, and D are routers.
• The numbers on the lines between them represent
costs (distance).
Link Cost
A→B 4
A→C 2
B→D 5
C→D 1
It’s a routing algorithm where each router shares its distance table
with its direct neighbors, and updates its table based on the
information received.
Each router tries to find the shortest path (minimum cost) to reach
every other router
How it Works (Example from Router A)
TO COST NEXT
A 0 A
B 4 B
C 2 C
• A is already at A → cost 0
• A can reach B directly with cost 4
• A can reach C directly with cost 2
• A doesn’t know about D yet
C Sends Info to A
C says:
“I can reach D in 1 unit”
So A thinks:
*If I go A → C (2) and C → D (1), total cost = 3
A updates its table to include D through C.
TO COST NEXT HOP
A 4 B
B 2 C
C 3 C
Now A knows:
•Best way to reach D is via C with a total cost of 3
Routers like A update their routing table based on
neighbor info
They choose shortest paths
This is called Distance Vector Routing
Link state routing
What is Link State Routing?
In Link State Routing, each router:
Learns the full map (topology) of the network.
Sends info about its directly connected neighbors to all other
routers.
Uses a shortest path algorithm (like Dijkstra’s) to find the best
path to every other router.
Link state routing with an
example
Routers:
•A, B, C, D (connected with costs like 1, 5, etc.)
Link State Sharing
Each router (B, C, D) sends its link information to A.
Example:
• B tells A: I’m connected to A and C with cost 1
• C tells A: I’m connected to B and D with cost 1
• D tells A: I’m connected to C with cost 1 and A with cost 5
A Builds the Map
Now A knows the full network structure.
A Calculates Shortest Path
To reach D, A has two options:
A → D (cost = 5)
A→B→C→D=1+1+1=3
So A chooses the best route using Dijkstra’s algorithm.
In Link State Routing :
Router A listens to what all routers say about their
links, draws the full map, and then chooses the
best path.