0% found this document useful (0 votes)
387 views2 pages

EX - No 8. Simulation of Distance Vector/Link State Routing

The document describes simulating a link state routing algorithm using NS2. It involves each router sharing information about its neighbors with every other router when there is a change. The algorithm creates nodes, defines links between them, sets up UDP connections between nodes, applies CBR traffic, and uses a link state routing protocol to transmit data. The program implements this by creating the simulator, nodes, links, agents, and applications, attaching them, running the traffic, and using a link state routing protocol. The result is a simulation of the link state routing algorithm.

Uploaded by

Haru Harshu
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)
387 views2 pages

EX - No 8. Simulation of Distance Vector/Link State Routing

The document describes simulating a link state routing algorithm using NS2. It involves each router sharing information about its neighbors with every other router when there is a change. The algorithm creates nodes, defines links between them, sets up UDP connections between nodes, applies CBR traffic, and uses a link state routing protocol to transmit data. The program implements this by creating the simulator, nodes, links, agents, and applications, attaching them, running the traffic, and using a link state routing protocol. The result is a simulation of the link state routing algorithm.

Uploaded by

Haru Harshu
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/ 2

EX.No 8. Simulation of Distance Vector/Link State Routing.

b) SIMULATION OF LINK STATE ROUTING ALGORITHM


Aim:
To simulate and study the link state routing algorithm using simulation using NS2.
Link State Routing protocol
In link state routing, each router shares its knowledge of its neighborhood with every other
router in the
internet work. (i) Knowledge about Neighborhood: Instead of sending its entire routing table
a router sends
info about its neighborhood only. (ii) To all Routers: each router sends this information to
every other router
on the internet work not just to its neighbor .It does so by a process called flooding.
(iii)Information sharing
when there is a change: Each router sends out information about the neighbors when there is
change.

ALGORITHM:
1. Create a simulator object
2. Define different colors for different data flows
3. Open a nam trace file and define finish procedure then close the trace file, and execute
nam on trace file.
4. Create n number of nodes using for loop
5. Create duplex links between the nodes
6. Setup UDP Connection between n(0) and n(5)
7. Setup another UDP connection between n(1) and n(5)
8. Apply CBR Traffic over both UDP connections
9. Choose Link state routing protocol to transmit data from sender to receiver.
10. Schedule events and run the program.

Program:
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
}

set n0 [$ns node]


set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
$ns duplex-link $n0 $n1 10Mb 10ms DropTail
$ns duplex-link $n1 $n3 10Mb 10ms DropTail
$ns duplex-link $n2 $n1 10Mb 10ms DropTail

$ns duplex-link-op $n0 $n1 orient right-down


$ns duplex-link-op $n1 $n3 orient right
$ns duplex-link-op $n2 $n1 orient right-up

set tcp [new Agent/TCP]


$ns attach-agent $n0 $tcp

set ftp [new Application/FTP]


$ftp attach-agent $tcp

set sink [new Agent/TCPSink]


$ns attach-agent $n3 $sink

set udp [new Agent/UDP]


$ns attach-agent $n2 $udp

set cbr [new Application/Traffic/CBR]


$cbr attach-agent $udp

set null [new Agent/Null]


$ns attach-agent $n3 $null

$ns connect $tcp $sink


$ns connect $udp $null

$ns rtmodel-at 1.0 down $n1 $n3


$ns rtmodel-at 2.0 up $n1 $n3

$ns rtproto LS

$ns at 0.0 "$ftp start"


$ns at 0.0 "$cbr start"

$ns at 5.0 "finish"

$ns run

Result:
Thus the program for creating Simulation of Distance Vector/Link State
Routing was implemented.

You might also like