[ns] ERROR when run my fist tcl example

2011-08-31 Thread Bety Barreto Soares



 
# myfirst_ns.tcl
# create a simulator
set ns [new simulator]
 
create a trace file
set mytrace [open out.tr w]
$ns trace-all $mytrace
 
create a NAM trace file
set myNAM [open out.nam w]
$ns namtrace-all $myNAM
 
define a procedure finish
proc finish {} {
  global ns mytrace myNAM
  $ns flush-trace
  close $mytrace
  close $myNAM
  exec nam out.nam 
  exit 0
}
 
create nodes
set n0 [$ns node]
set n1 [$ns node]
set n2 [$ns node]
set n3 [$ns node]
set n4 [$ns node]
 
connect nodes with links
$ns duplex-link $n0 $n2 100Mb 5ms DropTail
$ns duplex-link $n1 $n2 100Mb 5ms DropTail
$ns duplex-link $n2 $n4 54Mb 10ms DropTail
$ns duplex-link $n2 $n3 54Mb 10ms DropTail
$ns duplex-link $n3 $n4 10Mb 15ms DropTail
$ns queue-limit $n2 n3 40
 
create a UDP agent
set udp [new Agent/UDP]
$ns attach-agent $n0 $udp
set null [new Agent/Null]
$ns attach-agent $n3 $null
$ns connect $udp $null
$udp set fid_1
 
create a CBR traffic source
set cbr [new Application/Traffic/CBR]
$cbr attach-agent $udp
$cbr set packetSize_1000
$cbr set rate_2Mb
 
create a TCP agent
set tcp [new Agent/TCP]
$ns attach-agent $n1 $tcp
set sink [new Agent/TCPSink]
$ns attach-agent $n4 $sink
$ns connect $tcp $sink
$tcp set fid_2
 
create an FTP session
set ftp [new Application/FTP]
$ftp attach-agent $tcp
 
schedule events
ns at 0.05 $ftp start
ns at 0.1 $cbr start
ns at 60.0 $ftp stop
ns at 60.5 $cbr stop
ns at 61 finish
}
 
# Start the simulation
$ns run
 
ON THE CYGWIN I RUN THE FILE
$ ns myfirst_ns.tcl
 
IT'S ERROR SHOW BELOW

 
$ myfirst_ns.tcl
invalid command
name simulator
while executing
simulator
create _o3
invoked from
within
catch$className
create $o $args msg
invoked from
within
if [catch
$className create $o $args msg] {
if [string match
_FAILED _SHADOW_OBJECT_$msg] {
delete $o
return
}
global errorInfo
error class
$..
 procedure new line 3
invoked from
within
new
simulator
invoked from
within
set ns [new
simulator]
file
myfirst_ns.tcl line3
 
 
 
 
How to solve this?please help me out..i’m
very new



Re: [ns] ERROR when run my fist tcl example

2011-08-31 Thread nicholas mbonimpa

Hi Soares,

Try writing simulator with capital S instead of small s.

Try this tutorial for your first experience. Run the examples in it. They'll
help you get used to the simulator.

http://www.isi.edu/nsnam/ns/tutorial/

Kind regards,

Nicholas Mbonimpa


On Wed, Aug 31, 2011 at 7:46 AM, Bety Barreto Soares betyb...@yahoo.comwrote:





 # myfirst_ns.tcl
 # create a simulator
 set ns [new simulator]

 create a trace file
 set mytrace [open out.tr w]
 $ns trace-all $mytrace

 create a NAM trace file
 set myNAM [open out.nam w]
 $ns namtrace-all $myNAM

 define a procedure finish
 proc finish {} {
   global ns mytrace myNAM
   $ns flush-trace
   close $mytrace
   close $myNAM
   exec nam out.nam 
   exit 0
 }

 create nodes
 set n0 [$ns node]
 set n1 [$ns node]
 set n2 [$ns node]
 set n3 [$ns node]
 set n4 [$ns node]

 connect nodes with links
 $ns duplex-link $n0 $n2 100Mb 5ms DropTail
 $ns duplex-link $n1 $n2 100Mb 5ms DropTail
 $ns duplex-link $n2 $n4 54Mb 10ms DropTail
 $ns duplex-link $n2 $n3 54Mb 10ms DropTail
 $ns duplex-link $n3 $n4 10Mb 15ms DropTail
 $ns queue-limit $n2 n3 40

 create a UDP agent
 set udp [new Agent/UDP]
 $ns attach-agent $n0 $udp
 set null [new Agent/Null]
 $ns attach-agent $n3 $null
 $ns connect $udp $null
 $udp set fid_1

 create a CBR traffic source
 set cbr [new Application/Traffic/CBR]
 $cbr attach-agent $udp
 $cbr set packetSize_1000
 $cbr set rate_2Mb

 create a TCP agent
 set tcp [new Agent/TCP]
 $ns attach-agent $n1 $tcp
 set sink [new Agent/TCPSink]
 $ns attach-agent $n4 $sink
 $ns connect $tcp $sink
 $tcp set fid_2

 create an FTP session
 set ftp [new Application/FTP]
 $ftp attach-agent $tcp

 schedule events
 ns at 0.05 $ftp start
 ns at 0.1 $cbr start
 ns at 60.0 $ftp stop
 ns at 60.5 $cbr stop
 ns at 61 finish
 }

 # Start the simulation
 $ns run

 ON THE CYGWIN I RUN THE FILE
 $ ns myfirst_ns.tcl

 IT'S ERROR SHOW BELOW


 $ myfirst_ns.tcl
 invalid command
 name simulator
 while executing
 simulator
 create _o3
 invoked from
 within
 catch$className
 create $o $args msg
 invoked from
 within
 if [catch
 $className create $o $args msg] {
 if [string match
 _FAILED _SHADOW_OBJECT_$msg] {
 delete $o
 return
 }
 global errorInfo
 error class
 $..
  procedure new line 3
 invoked from
 within
 new
 simulator
 invoked from
 within
 set ns [new
 simulator]
 file
 myfirst_ns.tcl line3




 How to solve this?please help me out..i’m
 very new