在ns-3中查看当前有哪些程序可以执行

一、方法1: 在安装目录下:
$ ./waf --run non-program

注意 non-program 是随便起的一个名字,即当前不存在的一个程序名。
我安装的版本是 ns-3-dev ,gpf@guopengfei:~/repos/ns-3-allinone/ns-3-dev$ ./waf --run non-program

执行后,会提示你当前不存在 non-program ,并会列出当前可以运行的全部程序。

Waf: Entering directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
program 'non-program' not found; available programs are: ['main-callback', 'src/core/examples/main-callback', 'sample-simulator', 'src/core/examples/sample-simulator', 'main-ptr', 'src/core/examples/main-ptr', 'main-random-variable', 'src/core/examples/main-random-variable', 'sample-random-variable', 'src/core/examples/sample-random-variable', 'main-test-sync', 'src/core/examples/main-test-sync', 'main-packet-header', 'src/network/examples/main-packet-header', 'main-packet-tag', 'src/network/examples/main-packet-tag', 'main-simple', 'src/internet/examples/main-simple', 'main-propagation-loss', 'src/propagation/examples/main-propagation-loss', 'main-attribute-value',
...


这样,你就可以执行具体的程序,
比如:
./waf --run main-callback
结果:
Waf: Entering directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (3.826s)
invoke cbOne a=10, b=20
invoke cbTwo a=10



以及执行:
./waf --run src/core/examples/sample-simulator
结果:
Waf: Entering directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (3.633s)
ExampleFunction received event at 5s
RandomFunction received event at 11.6331s
Member method received event at 13s started at 5s


二、方法2,到程序的具体目录查看
我的ns-3安装在 ~/repos/ns-3-allinone/ns-3-dev目录下
具体可执行程序在 build/debug目录下
在build/debug下 exmples目录,scratch目录,src目录, utilis目录下,都有可执行的程序,用户可以查看。

比如,在我电脑中 build/debug/src/core/examples/目录下,有sample-random-variable可执行程序,

$  ./waf --run src/core/examples/sample-random-variable

结果:
Waf: Entering directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (3.687s)
0.816532

备注:
1. 程序的执行,是以 build/debug此目录为当前目录。
比如,我个人经常把自己编写的程序放在 ~/repos/ns-3-allinone/ns-3-dev/scratch目录中,
用./waf命令编译后,结果放在 ~/repos/ns-3-allinone/ns-3-dev/build/debug/scratch目录中。
执行的时候  $ ./waf --run scratch/my-program

2.在执行的时候,可以不输入目录,waf会自动定位该程序的位置,如:
./waf --run scratch-simulator
结果:
Waf: Entering directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
Waf: Leaving directory `/home/gpf/repos/ns-3-allinone/ns-3-dev/build'
'build' finished successfully (3.823s)
Scratch Simulator
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章