Docsity

Computer Networks and Internet Protocols: Routing Algorithms and Internetworking, Study notes of Computer Networks

Partial preview of the text

Download Computer Networks and Internet Protocols: Routing Algorithms and Internetworking and more Study notes Computer Networks in PDF only on Docsity!

COMPUTER NETWORKS & INTERNET PROTOCOLS

(R232PC51)

UNIT III The Network Layer Routing Algorithms, Inter networking, The Network Layer in The Internet

The Optimality Principle

Shortest Path Algorithm

Flooding

Distance Vector Routing

Link State Routing

Hierarchical Routing within a Network

Broadcast Routing

Multicast Routing

Anycast Routing

ROUTING ALGORITHMS IN A SINGLE NETWORK

The Optimality Principle

The Optimality Principle is a fundamental concept in routing used to
determine the best path for data transmission across a network.
This principle is the foundation for many routing algorithms, such as
Dijkstra’s algorithm and Bellman-Ford algorithm, which are designed
to compute shortest paths in a network.
Using the Optimality Principle, routing decisions can be made
efficiently because once the best path is determined for one part of the
network, it can be extended to build the complete best path.

Shortest Path Algorithm

The Shortest Path Algorithm is used in computer networks and graph theory to find the minimum cost (or distance) path between two nodes in a network. The Shortest Path Algorithm is a method used in networking and graph theory to determine the path between two nodes such that the total cost (distance, time, or weight) is minimized. In a computer network, each link between two routers is assigned a cost. The purpose of the algorithm is to select routes that minimize this cost, thereby ensuring efficient data transmission.

There are two main algorithms commonly used
  1. Dijkstra’s Algorithm – This algorithm is suitable when all link costs are non-negative. It works by progressively building the shortest path tree. Starting from the source node, it repeatedly chooses the node with the smallest tentative distance, updates distances to its neighbors, and finalizes paths. It is widely used in routing protocols such as OSPF (Open Shortest Path First).
  2. Bellman-Ford Algorithm – This algorithm can handle negative edge weights. It works by repeatedly relaxing all edges and updating the shortest distances. Although slower than Dijkstra’s algorithm, it is more versatile and is used in protocols like RIP (Routing Information Protocol).

How it works:

Set initial distances for all vertices: 0 for the source vertex, and infinity for all the other.Choose the unvisited vertex with the shortest distance from the start to be the current vertex. So the algorithm will always start with the source as the current vertex.For each of the current vertex's unvisited neighbor vertices, calculate the distance from the source and update the distance if the new, calculated, distance is lower. We are now done with the current vertex, so we mark it as visited. A visited vertex is not checked again. Go back to step 2 to choose a new current vertex, and keep repeatingthese steps until all vertices are visited In the end we are left with the shortest path from the source vertex to every other vertex in the graph. E RAMACHANDRA

Example

Relaxation : d[u]+c[u,v]<d[v]

d[v]=d[u]+c[u,v]
Bellman-Ford Algorithm

The Bellman-Ford algorithm is a graph-based algorithm used to find

the shortest paths from a single source vertex to all other vertices in a weighted graph. It is particularly useful for graphs with negative edge weights, as it can detect negative weight cycles. Relax every edge repeatedly. After at most |V|−1 full passes of relaxing all edges, all shortest-path distances are found.

EX - I (^) EX - II EX - III

Using flooding technique An incoming packet to A, will be sent to B, C and D. B will send the packet to C and E. C will send the packet to B, D and F. D will send the packet to C and F. E will send the packet to F. F will send the packet to C and E. EXAMPLE

Types of Flooding

Flooding may be of three types Uncontrolled flooding Here, each router unconditionally transmits the incoming data packets to all its neighbours. Controlled flooding They use some methods to control the transmission of packets to the neighbouring nodes. The two popular algorithms for controlled flooding are Sequence Number Controlled Flooding (SNCF) and Reverse Path Forwarding (RPF). Selective flooding Here, the routers don't transmit the incoming packets only along those paths which are heading towards approximately in the right direction, instead of every available paths.

Advantages

Simplicity – Easy to understand and implement since each router only
shares information with neighbors.
Low Overhead – Routers only send their routing tables periodically (not the
entire network graph).
Distributed Operation – No central controller is needed; each router
independently updates its table.
Good for Small Networks – Works efficiently when the network size is
limited.
Disadvantages

Slow Convergence – Takes time for all routers to learn about network changes, which can cause loops. Limited Scalability – Not suitable for large networks because routing tables grow and updates become inefficient. Inefficient Updates – Routers send full tables instead of only the changed routes.