Usually there is not only one road. There may be many possible routes. One route may be shorter, another may have less traffic, and another may pass through fewer cities.
Routers face almost the same problem. They receive packets and must decide: Which path should this packet follow to reach the destination?
Routing algorithms help routers make this decision.
A routing algorithm is a method used by routers to determine suitable paths for sending packets from a source network to a destination network.
Distance Vector routing learns destination distances from neighbouring routers and is based on the Bellman-Ford idea.
Link State routing distributes information about local links so routers can build a network topology database and run a shortest-path algorithm such as Dijkstra's algorithm.
What Is Routing?
Routing is the process of selecting a path through a network so that a packet can travel from its source toward its destination.
Suppose Router A wants to send a packet to a network connected behind Router C.
The router needs information that tells it which next hop should be used.
What Is a Routing Algorithm?
A routing algorithm is the logic used to calculate routes.
It helps a router answer questions such as:
- Which destination networks are reachable?
- Which next hop should be used?
- Which path has the lowest cost?
- What should happen if a link fails?
- When should an old route be replaced?
Why Do We Need Routing Algorithms?
A small network may have only one path.
But large networks can contain thousands of routers and many possible routes.
A router cannot simply guess where a packet should go.
It needs a systematic method to:
- Learn the network
- Find reachable destinations
- Select suitable paths
- React to failures
- Update the routing table
Properties of a Good Routing Algorithm
Correctness
The algorithm should calculate valid routes toward reachable destinations.
Simplicity
Routing logic should not create unnecessary complexity.
Robustness
It should continue working when links or routers change or fail.
Stability
Route calculations should eventually settle instead of constantly changing without reason.
Efficiency
Routing should avoid excessive memory, CPU and bandwidth overhead.
Adaptability
Dynamic algorithms should adjust when topology or network conditions change.
Routing Metrics
A routing algorithm needs some way to compare paths.
The value used to compare routes is called a metric.
Common routing metrics include:
- Hop count
- Bandwidth-related cost
- Delay
- Link cost
- Reliability
- Administrative policy
Classification of Routing Algorithms
Non-Adaptive Routing
Routes do not automatically change according to current network conditions.
Static routing is the common example.
Adaptive Routing
Routes can change when routers learn new topology or reachability information.
Distance Vector and Link State algorithms are important examples.
Static Routing
In static routing, routes are manually configured.
The router does not automatically calculate a new route simply because the network topology changes.
Advantages
- Simple for very small networks
- No routing update traffic
- Predictable route configuration
Limitations
- Difficult to manage in large networks
- Manual changes may be required after failures
- Poor scalability for frequently changing networks
Dynamic Routing
Dynamic routing allows routers to exchange or calculate routing information automatically.
If a route fails, the routers may calculate an alternative path.
Examples of routing protocols using dynamic techniques include:
- RIP
- OSPF
- IS-IS
- BGP
Adaptive vs Non-Adaptive Routing
| Point | Adaptive Routing | Non-Adaptive Routing |
|---|---|---|
| Route Change | Can change according to new network information | Does not automatically adapt |
| Updates | Routing information is learned dynamically | Usually configured manually |
| Failure Handling | Can calculate alternative routes | Administrator may need to change configuration |
| Example | Distance Vector, Link State | Static routing |
Shortest Path Routing
One common routing idea is to represent the network as a graph.
In this graph:
- Routers are represented as nodes.
- Links are represented as edges.
- Each link may have a cost.
The goal is to find a path whose total cost is minimum.
Representing a Network as a Graph
Consider the following link costs:
We will use this type of cost information to understand shortest-path calculation.
Dijkstra's Shortest Path Algorithm
Dijkstra's algorithm finds shortest paths from one source node to other nodes when link costs are non-negative.
Link State routing protocols commonly use a Shortest Path First calculation based on Dijkstra's algorithm.
Basic Idea
Dijkstra Algorithm Solved Example
Consider these links:
Source node is:
Shortest Paths
Routing Table Produced from the Shortest Paths
From router A, the first hop toward B, D and E is C.
Distance Vector Routing
Distance Vector routing follows a very simple idea.
A router does not need the complete network map.
Instead, it knows:
- How far a destination appears to be
- Which neighbour should be used to reach it
Routers exchange routing information with neighbouring routers.
How Distance Vector Routing Works
Bellman-Ford Equation in Distance Vector Routing
The basic Distance Vector idea can be written as:
Where:
- Dₓ(y) = router x's estimated cost to destination y
- c(x,v) = cost from router x to neighbour v
- Dᵥ(y) = neighbour v's advertised cost to destination y
Distance Vector Routing Example
Suppose:
Router A has two choices to reach C.
Direct Route
Route Through B
Therefore Router A selects:
Total Cost = 5
Distance Vector Routing Updates
Distance Vector protocols may send routing information to neighbours periodically.
They may also send triggered updates when important route changes occur, depending on the routing protocol.
Router A
Sends known destination costs to neighbouring router B.
Router B
Compares A's information with its current routing table.
Update
B changes a route if the newly calculated path is better or if route state changes require an update.
Count-to-Infinity Problem
Distance Vector routing can suffer from slow convergence after some failures.
The classic problem is called:
Suppose router A reaches destination X through B.
If the route to X fails, incorrect information may circulate between routers.
One router may believe another router still has a valid path.
Split Horizon
Split Horizon is used to reduce routing-loop problems.
The basic idea is:
Example:
If Router A learned route X from Router B, A should not tell B that X is reachable through A.
Route Poisoning
Route poisoning means advertising a failed route using an infinite or unreachable metric.
This tells neighbours:
Poison Reverse
Poison Reverse is related to Split Horizon.
Instead of simply not advertising the route back, a router advertises it back with an infinite metric.
Hold-Down Concept
Some Distance Vector systems use hold-down behaviour to reduce instability after route failures.
For a period of time, suspicious updates about a failed destination may be ignored or handled carefully.
The aim is to give the network time to remove old information.
RIP — Distance Vector Routing Protocol Example
RIP stands for:
RIP is a well-known Distance Vector routing protocol.
Important RIP Points
- Uses hop count as its basic metric.
- Lower hop count is preferred.
- Maximum usable hop count is 15.
- Hop count 16 means unreachable.
- It is mainly suitable for comparatively small networks.
Link State Routing
Link State routing uses a different idea.
Instead of telling neighbours only a list of destination distances, each router describes its own local links.
That information is distributed through the routing area or domain.
Routers build a common topology database and calculate shortest paths.
How Link State Routing Works
Neighbour Discovery
A Link State router must first know which routers are directly reachable on its links.
Routing protocols use neighbour discovery or hello-type mechanisms to identify neighbouring routers.
This creates the local view from which topology information is built.
Link Cost Measurement
Each link is given a cost.
The exact way the cost is calculated depends on the routing protocol.
A lower cost generally represents a more preferred path.
Link State Advertisement
A router creates information describing the state of its links.
This may include:
- Router identity
- Neighbour information
- Connected links
- Link cost
- Sequence information
The information is then distributed to other routers in the appropriate routing scope.
Flooding in Link State Routing
Flooding means distributing Link State information through the network so that relevant routers receive it.
A router receiving new Link State information forwards it appropriately to other neighbours.
Mechanisms such as sequence numbers and ageing help routers distinguish fresh information from old information.
Link State Database — LSDB
Routers collect the flooded Link State information into a topology database.
This is commonly called:
Routers in the same Link State routing scope aim to maintain a consistent view of that topology.
Shortest Path First — SPF Calculation
After building the LSDB, each router treats itself as the root of the network graph.
It then runs a shortest-path algorithm.
The result is a shortest-path tree.
OSPF — Link State Routing Protocol Example
OSPF stands for:
OSPF is a widely used Link State Interior Gateway Protocol.
Main Ideas
- Discovers neighbours.
- Exchanges Link State information.
- Builds an LSDB.
- Uses an SPF calculation.
- Supports hierarchical area design.
- Can react to topology changes more quickly than simple traditional Distance Vector designs.
Distance Vector vs Link State Routing
| Point | Distance Vector | Link State |
|---|---|---|
| Knowledge | Knows destination distance through neighbours | Builds a topology database |
| Information Shared | Routing distance information | State and cost of local links |
| Who Receives Information? | Mainly neighbours | Topology information is flooded through the routing scope |
| Algorithm Idea | Bellman-Ford | Dijkstra / SPF |
| Network View | No complete topology map required | Maintains topology database |
| Convergence | Can be slower in classic designs | Generally faster after topology information is synchronized |
| Loop Problem | More vulnerable to classic routing loops and count-to-infinity | Uses topology information and sequence mechanisms, reducing classic DV problems |
| Resource Requirement | Usually simpler | Requires more topology information and computation |
| Example | RIP | OSPF |
Advantages and Limitations
Distance Vector
Advantages- Simple concept
- Lower topology knowledge requirement
- Suitable for smaller environments
- Routing loops can occur
- Count-to-infinity problem
- Traditional convergence can be slow
Link State
Advantages- Detailed network topology knowledge
- Fast reaction to topology changes in well-designed implementations
- Efficient shortest-path calculation
- Suitable for larger routed networks
- More memory required
- More CPU needed for SPF calculations
- More complex protocol operation
What Is Routing Convergence?
Convergence means routers have processed a topology change and their routing information has reached a stable, consistent state.
For example:
Routing Loops
A routing loop occurs when routers repeatedly forward packets in a circle instead of toward the destination.
Example:
Routing loops waste:
- Bandwidth
- Router processing
- Buffer space
IP TTL or IPv6 Hop Limit eventually prevents an individual packet from looping forever, but routing protocols should still try to prevent the incorrect route itself.
Hierarchical Routing
A very large network becomes difficult to manage if every router must process every detail of the entire network.
Hierarchical routing divides a large routing system into smaller logical areas, regions or administrative domains.
Benefits
- Reduces routing information
- Improves scalability
- Allows route summarization
- Limits some topology information to smaller regions
OSPF areas are a common example of hierarchical routing inside an autonomous system.
Routing Protocol Examples
Solved Routing Numericals
Numerical 1: Find Path Cost
Suppose:
Find the cost of:
Numerical 2: Choose the Shortest Route
Router A has two possible paths to D.
Therefore:
Cost = 5
Numerical 3: Bellman-Ford Update
Router A wants to reach destination X.
A has:
Through B:
Through C:
So Router A selects:
Distance to X = 6
Numerical 4: RIP Reachability
A RIP route reaches a destination in 15 hops.
If the metric becomes 16:
Numerical 5: Dijkstra Shortest Route
Given:
Possible route:
Direct alternative through A:
Cost = 5
Common Exam Mistakes
Routing calculates or learns routes. Forwarding sends an individual packet using routing information.
Wrong. Shortest means minimum routing cost according to the selected metric.
Wrong. Classical Distance Vector operation mainly depends on information learned from neighbours.
Wrong. Link State routers build a topology database from flooded link-state information.
Wrong. Distance Vector is based on the Bellman-Ford idea. Dijkstra is associated with Link State shortest-path calculation.
Wrong. It is a classic Distance Vector problem.
Wrong. RIP treats 16 as unreachable.
Wrong. Split Horizon avoids advertising that route back through the interface from which it was learned.
Wrong. Flooding here refers to distributing routing topology information.
Wrong. BGP is generally classified as a Path Vector routing protocol.
40 Important Routing Algorithm Questions With Answers
20 Routing Algorithm MCQs With Answers
A. Select paths for packets
B. Change screen resolution
C. Create HTML pages
D. Compress images
A. Bellman-Ford
B. Prim only
C. Huffman coding
D. RSA
A. Dijkstra
B. Binary search only
C. Bubble sort
D. FIFO scheduling
A. Link State
B. Basic Distance Vector only
C. Static routing only
D. None
A. Distance Vector routing
B. Link State routing
C. Transport protocol
D. Application protocol
A. Link State routing
B. Distance Vector routing
C. Application protocol
D. Physical Layer protocol
A. Hop count
B. File size
C. MAC address
D. Port number
A. 15
B. 16
C. 255
D. Unlimited
A. Unreachable
B. Best route
C. Direct route
D. Zero cost
A. Distance Vector routing
B. Link State routing
C. Ethernet framing
D. TCP checksum
A. Routing loops
B. Screen flicker
C. Frame size
D. Encryption
A. Unreachable
B. Zero cost
C. Best route
D. Static
A. Link State Database
B. Local Switching Data Block
C. Link Signal Data Bus
D. Logical State Data Byte
A. Shortest Path First
B. Secure Packet Frame
C. Simple Path Format
D. Static Protocol Field
A. OSPF
B. RIP
C. HTTP
D. ARP only
A. Non-negative
B. Always negative
C. Text values only
D. MAC addresses
A. Distance Vector
B. Link State only
C. Circuit switching
D. Token passing
A. Routers reach a stable routing state
B. All packets are encrypted
C. Routers shut down
D. Frames become packets
A. Path Vector
B. Link State
C. Pure Distance Vector
D. Data Link protocol
A. Packet forwarding
B. Image compression
C. HTML rendering
D. Keyboard scanning
Frequently Asked Questions
What is a routing algorithm in simple words?
A routing algorithm is a method that helps routers decide which path packets should use to reach a destination network.
What is Distance Vector routing?
Distance Vector routing is a method where routers learn destination costs from neighbouring routers and choose the lowest-cost available route.
Which algorithm is used in Distance Vector routing?
Distance Vector routing is based on the Bellman-Ford shortest-path idea.
What is Link State routing?
Link State routing distributes information about local links so routers can build a topology database and calculate shortest paths.
Which algorithm is used in Link State routing?
Link State routing commonly uses Dijkstra's Shortest Path First algorithm.
What is the count-to-infinity problem?
It is a Distance Vector problem where routers can slowly increase a metric to a failed destination because incorrect route information continues circulating.
What is Split Horizon?
Split Horizon prevents a route from being advertised back through the same interface from which it was learned.
What is an LSDB?
LSDB means Link State Database. It stores topology information learned by Link State routers.
What is the main difference between RIP and OSPF?
RIP is a Distance Vector protocol using hop count, while OSPF is a Link State protocol that builds a topology database and runs an SPF calculation.
What is routing convergence?
Routing convergence is the process by which routers update their information after a topology change and eventually reach a stable routing state.
Is BGP a Link State protocol?
No. BGP is generally classified as a Path Vector routing protocol.
What does shortest path mean in routing?
It means the path with the minimum total routing metric or cost, not necessarily the shortest physical distance.
Quick Routing Algorithms Revision
Final Memory Trick:
Distance Vector = Ask your neighbours.
Link State = Build the complete map.
Dijkstra = Find the cheapest path on that map.
Bellman-Ford = Compare the cost through each neighbour.
