How to run ns3 files out side the scratch or in sub-folder in side the scratch

5,881 views
Skip to first unread message

Walid Ibrahim

unread,
Aug 22, 2012, 4:11:37 PM8/22/12
to ns-3-...@googlegroups.com
Hi all 

I want to reorganize the code I am writing so when I created a folder in the scratch so I collect the related scripts I wrote. But when I build the project these error appears.

is there a way to create a sub-folder in the scratch, or run scripts outside the scratch folder?

Walid

**** Build of configuration Debug for project ns-3.13 ****

/home/repos/ns-3-allinone/ns-3.13/waf build 
Traceback (most recent call last):
Waf: Entering directory `/home/repos/ns-3-allinone/ns-3.13/build'
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 96, in waf_entry_point
    run_commands()
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 148, in run_commands
    run_command(cmd_name)
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 141, in run_command
    ctx.execute()
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Scripting.py", line 336, in execute
    return execute_method(self)
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Build.py", line 102, in execute
    self.execute_build()
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Build.py", line 105, in execute_build
    self.recurse([self.run_dir])
  File "/home/repos/ns-3-allinone/ns-3.13/.waf-1.6.7-0a94702c61504c487a251b8d0a04ca9a/waflib/Context.py", line 127, in recurse
    user_function(self)
  File "/home/repos/ns-3-allinone/ns-3.13/wscript", line 725, in build
    add_scratch_programs(bld)
  File "/home/repos/ns-3-allinone/ns-3.13/wscript", line 628, in add_scratch_programs
    obj.find_sources_in_dirs('.')
AttributeError: 'task_gen' object has no attribute 'find_sources_in_dirs'

Till

unread,
Aug 22, 2012, 4:32:27 PM8/22/12
to ns-3-...@googlegroups.com
It's pretty easy.
If you want to have more modularized code, just create a new Module;). To do so, run "create-module.py <YOUR_PROJECT_NAME>" in the src-folder.
After the next configure/build, the files included in the Examples-folder are exetuable and the classes will be compiled.
I would recommend you to read http://www.nsnam.org/docs/release/3.13/manual/html/new-modules.html . That was the best introduction i found.
Regards,
Till 

Walid Ibrahim

unread,
Aug 22, 2012, 4:56:23 PM8/22/12
to ns-3-...@googlegroups.com
Thanks for your reply, 

I already create a new Module, and It is working fine, my question how can I run script in the module. 

I mean I created "myModule" in src which contain many files with helper files, then I created a testMyModule.cc in scratch folder to run myModule. 
then I run the testfile.cc using this command ./waf --run scratch/testMyModule

My question can I run the test module like this ./waf --run scratch/myModule/testMyModule?

Walid

Till

unread,
Aug 23, 2012, 3:59:56 AM8/23/12
to ns-3-...@googlegroups.com
Just take a look into the wscript-file in the examples-folder in your new module. The first parameter of "bld.create_ns3_program(..." is the ID, which identifies your example. So, ""bld.create_ns3_program('foo',..." means, that you can execute your example by "./waf --run foo".
Regards

Walid Ibrahim

unread,
Aug 23, 2012, 11:08:22 AM8/23/12
to ns-3-...@googlegroups.com
WOW that is Very Easy and Really Neat !!!!!

last question how I can run ./waf from any folder

and many thanks.

Walid

Till

unread,
Aug 23, 2012, 4:40:30 PM8/23/12
to ns-3-...@googlegroups.com
indeed, it's neat;).
Atm, i don't know a better way than do it by some alias in the shell;).
Regards

Nazia Trina.

unread,
Jan 23, 2017, 4:42:16 PM1/23/17
to ns-3-users
How can I run a module from scr ?
Like new-crn/src/cognitive
From git hub , I got the code and cognitive module is already created. Bt I can't run it .
https://github.com/abdulla-alali/CRE-NS3/tree/cognitive/utils
https://github.com/abdulla-alali/CRE-NS3/blob/cognitive/doc/manual/source/enable-tests.rst
Following link has the source

Tommaso Pecorella

unread,
Jan 23, 2017, 6:46:30 PM1/23/17
to ns-3-users
Hi,

you don't run a module, you run a script.
Start from the tutorial, it's much easier in that way.

T.
Reply all
Reply to author
Forward
0 new messages