Assignment-05:-Simulation of Network With Specific Routing Protocols
Assignment-05:-Simulation of Network With Specific Routing Protocols
Link State Routing (LSR) is a dynamic routing method where routers share link status information rather than
entire routing tables. Unlike Distance Vector Routing, LSR enables routers to independently compute the
shortest paths using algorithms like Dijkstra’s Shortest Path First (SPF).
Key Concepts:
● Link State Advertisements (LSAs): Routers periodically broadcast LSAs containing link costs and
neighbor details.
● Flooding: LSAs are flooded across the network to ensure all routers have a synchronized view.
● Link State Database (LSDB): Each router maintains an LSDB to store received LSAs and build a
complete network topology.
● Routers use the SPF algorithm to determine optimal routes.
Shortest Path Calculation:
● Network Adaptability: Changes in topology trigger LSAs, prompting routers to update paths
dynamically.
Advantages:
Code:
set ns [new Simulator] set
nf [open out.nam w] $ns
namtrace-all $nf set tr
[open out.tr w] $ns trace-
all $tr
proc finish {} {
global nf ns tr
$ns flush-trace
close $tr
exec nam out.nam &
exit 0
}
$ns run
Output:
5.2 Distance Vector Routing Protocol
Aim:
To study simulation of networks with specific routing protocols distance vectors.
Theory:
Distance Vector Routing Protocol is based on the Bellman-Ford Algorithm, also known as the
Ford-Fulkerson Algorithm. It determines the shortest path from one node to another by sharing
distance information between neighboring routers.
Working Principle
1. Each router maintains a routing table containing the distance to all known destinations.
2. Routers exchange periodic updates with their directly connected neighbors.
3. Distance is measured in hops (i.e., the number of routers a packet must pass through).
4. The Bellman-Ford algorithm updates routing tables dynamically based on received
information.
5. Loop prevention mechanisms such as split horizon, hold-down timers, and route poisoning
are used to avoid routing loops.
Advantages:
Disadvantages:
Code:
set ns [new Simulator]
$ns rtproto LS
proc finish {} {
global ns nf tf
$ns flush-trace
close $tf close $nf
exec nam out.nam &
exit 0
}
$ns at 0.5 "$traffic_ftp2 start"
$ns rtmodel-at 1.0 down $node1 $node2
$ns rtmodel-at 2.0 up $node1 $node2
$ns at 3.0 "$traffic_ftp2 start"
$ns at 4.0 "$traffic_ftp2 stop"
$ns at 5.0 "finish"
$ns run
Output: