0% found this document useful (1 vote)
1K views

NS2 Simulation Using Distance Vector Routing Protocol

This document sets up a network simulation using the NS2 simulator to test distance vector routing. It creates 4 nodes, connects them with links, and assigns routing protocols. It then generates TCP and CBR traffic between nodes to test the distance vector routing protocol. The simulation is run and output files are generated for analysis.

Uploaded by

Kavin Cavin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
1K views

NS2 Simulation Using Distance Vector Routing Protocol

This document sets up a network simulation using the NS2 simulator to test distance vector routing. It creates 4 nodes, connects them with links, and assigns routing protocols. It then generates TCP and CBR traffic between nodes to test the distance vector routing protocol. The simulation is run and output files are generated for analysis.

Uploaded by

Kavin Cavin
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

NS2 simulation using Distance Vector routing protocol

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 DV
$ns at 0.0 "$ftp start"
$ns at 0.0 "$cbr start"
$ns at 5.0 "finish"
$ns run

You might also like