LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu
User Name
Password
Ubuntu This forum is for the discussion of Ubuntu Linux.

Notices


Reply
  Search this Thread
Old 03-22-2015, 04:51 AM   #1
Rita Ahmad
LQ Newbie
 
Registered: Mar 2015
Posts: 28
Blog Entries: 3

Rep: Reputation: Disabled
namtrace error in ns2


When I try to run ex1.tcl file, I get the following error:

rita@rita-S400CA:~/Desktop$ ns ex1.tcl
can't read "namtrace": no such variable
while executing
"$namtrace-all $nf"
(file "ex1.tcl" line 3)


ex1.tcl file contains:

set ns [new Simulator]
set nf [open out.nam w]
$namtrace-all $nf
proc finish {} {
global ns nf
$ns flush-trace
close $nf
exec nam out.nam &
exit 0
}
set n0 [$ns node]
set n1 [$ns node]
$ns duplex-link $n0 $n1 1Mb 10ms DropTail

$ns at 5.0 "finish"
$ns run

Any solution to this error?
 
Old 03-22-2015, 05:06 AM   #2
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,511

Rep: Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641Reputation: 3641
* http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html
"example1.tcl" http://www.isi.edu/nsnam/ns/tutorial.../example1a.tcl
Code:
#Create a simulator object
set ns [new Simulator]

#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 two nodes
set n0 [$ns node]
set n1 [$ns node]

#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail

#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run
 
Old 03-22-2015, 06:10 AM   #3
Rita Ahmad
LQ Newbie
 
Registered: Mar 2015
Posts: 28

Original Poster
Blog Entries: 3

Rep: Reputation: Disabled
namtrace error in ns2

Thanks a lot.


Quote:
Originally Posted by knudfl View Post
* http://www.isi.edu/nsnam/ns/tutorial/nsscript1.html
"example1.tcl" http://www.isi.edu/nsnam/ns/tutorial.../example1a.tcl
Code:
#Create a simulator object
set ns [new Simulator]

#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 two nodes
set n0 [$ns node]
set n1 [$ns node]

#Create a duplex link between the nodes
$ns duplex-link $n0 $n1 1Mb 10ms DropTail

#Call the finish procedure after 5 seconds of simulation time
$ns at 5.0 "finish"

#Run the simulation
$ns run
 
  


Reply

Tags
ns2



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ns2 error pravin120993 Linux - Newbie 1 09-24-2014 07:49 AM
NS2: Cygwin error "couldn't create signal error, win32 error 161" bhartideswal General 2 05-04-2013 02:22 AM
namtrace-all: not found er_jainamit Linux - Newbie 1 11-01-2012 04:41 AM
I got an error while running leach package in ns2.. help me to get out of this error. rkgowrishankar Linux - Software 1 02-07-2012 04:51 AM
ns2 error prashantpanse Linux - Newbie 0 09-26-2008 09:13 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Ubuntu

All times are GMT -5. The time now is 05:09 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration