- Home Page of ProjectGuideline.com ›
- Forums ›
- Get Help to do your B.E., and M.E., M.Tech., & M.S., Project in Ns2 ›
- error in ns2 program
iam doing project in ns2 ………..
so i have did one program …..but some error occurring …..so can you please anyone help me to correct this error ………..
my program of udp is
#Create a simulator object
set ns [new Simulator]
$ns color 1 Blue
$ns color 1 Red
$ns color 2 White
#Open the nam trace file
set nf [open out.nam w]
$ns namtrace-all $nf
#Define a ‘finish’ procedure
proc finish {} {
global ns nf
$ns flush-trace
#Close the trace file
close $nf
#Execute nam on the trace file
exec nam out.nam &
exit 0
}
#Create four nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
#Create links between the nodes
$ns duplex-link $n0 $n1 0.2Mb 10ms DropTail
$ns duplex-link $n0 $n2 0.2Mb 10ms DropTail
$ns duplex-link $n1 $n3 0.2Mb 10ms DropTail
$ns duplex-link $n2 $n3 0.2Mb 10ms DropTail
set udp [new Agent/UDP]
$udp set class_ 1
set sink [new Agent / Null]
$ns attach-agent $n0 $udp
$ns attach-agent $n3 $sink
$ns connect $udp $sink
set cbr [new Application / Trafic / CBR]
$cbr set packetSize _ 1000
$cbr attach-agent $udp
$ns at 1.0 “$cbr start”
$ns at 29.0 “$cbr stop”
$ns at 30.0 “finish”
proc finish {} {
global _ns tracefd namtrace
close $tracefd
close $namtrace
}
puts “starting simulation…”
$ns run
Hi
I believe you were able to fix your problem by your own, just a reminder that you didnt state the error you were getting but you just copy and paste your tcl script! so no wonder why you didn’t get any help! so please ensure next time that you state the error clearly so that it make it easy for others to help you!
Regards
======================
Viva Linux — (^_^)
“you know nothing until you start sharing it! “