Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
25 views3 pages

Networking 11

The document outlines an experiment on Distance Vector Routing, including an algorithm and a program to compute routing tables for a network of routers. It involves inputting a cost matrix to determine the shortest paths and next hops for each router. The output displays the routing table for each router with destination, next hop, and cost information.

Uploaded by

Balaji Bala
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)
25 views3 pages

Networking 11

The document outlines an experiment on Distance Vector Routing, including an algorithm and a program to compute routing tables for a network of routers. It involves inputting a cost matrix to determine the shortest paths and next hops for each router. The output displays the routing table for each router with destination, next hop, and cost information.

Uploaded by

Balaji Bala
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/ 3

EXP NO:11

DATE:
Distance Vector Routing

AIM:

ALGORITHM:
PROGRAM:
n = int(input("Enter number of routers: "))
INF = 999
distance = []

print("Enter the cost matrix (use 999 for no direct link):")


for i in range(n):
row = list(map(int, input(f"Router {i} to others: ").split()))
distance.append(row)

routing_table = [[(distance[i][j], j) for j in range(n)] for i in range(n)]

for _ in range(n - 1):


for i in range(n):
for j in range(n):
for k in range(n):
if distance[i][j] > distance[i][k] + distance[k][j]:
distance[i][j] = distance[i][k] + distance[k][j]
routing_table[i][j] = (distance[i][j], k)

for i in range(n):
print(f"\nRouting table for Router {i}:")
print("Destination\tNext Hop\tCost")
for j in range(n):
if i != j:
cost, next_hop = routing_table[i][j]
print(f"{j}\t\t{next_hop}\t\t{cost}")
OUTPUT:

RESULT:

You might also like