Netcom Mid-Term Nupoor Raj 19BCE2145 Slot:L1+L2 Faculty:Abdul Gaffar H
Netcom Mid-Term Nupoor Raj 19BCE2145 Slot:L1+L2 Faculty:Abdul Gaffar H
Nupoor Raj
19BCE2145
Slot:L1+L2
Faculty:Abdul Gaffar H
Algorithm:
● Step-1: The node is taken and chosen as a root node of the tree, this creates the tree
with a single node, and now set the total cost of each node to some value based on the
information in Link State Database
● Step-2: Now the node selects one node, among all the nodes not in the tree like
structure, which is nearest to the root, and adds this to the tree.The shape of the tree
gets changed .
● Step-3: After this node is added to the tree, the cost of all the nodes not in the tree
needs to be updated because the paths may have been changed.
● Step-4: The node repeats Step 2. and Step 3. until all the nodes are added in the tree
Code:
#include <stdio.h>
#include <string.h>
int main()
int count,src_router,i,j,k,w,v,min;
int cost_matrix[100][100],dist[100],last[100];
int flag[100];
scanf("%d",&count);
for(i=0;i<count;i++)
{
for(j=0;j<count;j++)
printf("\n%d->%d:",i,j);
scanf("%d",&cost_matrix[i][j]);
if(cost_matrix[i][j]<0)cost_matrix[i][j]=1000;
scanf("%d",&src_router);
for(v=0;v<count;v++)
flag[v]=0;
last[v]=src_router;
dist[v]=cost_matrix[src_router][v];
flag[src_router]=1;
for(i=0;i<count;i++)
min=1000;
for(w=0;w<count;w++)
if(!flag[w])
if(dist[w]<min)
{
v=w;
min=dist[w];
flag[v]=1;
for(w=0;w<count;w++)
if(!flag[w])
if(min+cost_matrix[v][w]<dist[w])
dist[w]=min+cost_matrix[v][w];
last[w]=v;
for(i=0;i<count;i++)
printf("\n%d==>%d:Path taken:%d",src_router,i,i);
w=i;
while(w!=src_router)
printf("\n<--%d",last[w]);w=last[w];
}
Output:
B) AIM: Identify the tool that provides a list of network hops between two
systems? Run the identify command and highlight the output of the command
with an appropriate result and discussion.
Answer:
ALGORITHM:
Traceroute sends packets with TTL values that gradually increase from packet to packet,
starting with TTL value of one. Routers decrement TTL values of packets by one when routing
and discard packets whose TTL value has reached zero, returning the ICMP error message ICMP
Time Exceeded.
Traceroute is a computer network diagnostic tool for displaying the route (path), and measuring
transit delays, of packets across an Internet Protocol (IP) network.The first column corresponds
to the hop count. The second column represents the address of that hop and after that, you see
three space-separated time in milliseconds. The traceroute command sends three packets to the
hop and each of the time refers to the time taken by the packet to reach the hop.
● -m max_ttl Option: Set the max number of hops for the packet to reach the
destination.Default value is 30.
Syntax:
$traceroute -m 5 google.com
● -f first_ttl Option: Start from the first_ttl hop (instead from 1).
Syntax:
$ traceroute -f 10 google.com
● packetlen Option: The full packet length. Default len is 60 byte packets.
Syntax:
$traceroute google.com 100