ns-3中的waff wiki函数没有获取参数

时间:2015-01-20 19:01:37

标签: waf ns-3

ns-3 模拟器documentation中,它们提供了一个简单的bash功能来缓解您的生活:

function waff {
   CWD="$PWD"
   cd $NS3DIR
   ./waf --cwd="$CWD" $*
   cd -
}

此函数应该执行位于ns-3根文件夹中但位于您实际所在文件夹内的 ./ waf 程序。

因此,在~/project$ waff --run first waf的情况下,waf将在〜/ project 文件夹中运行第一个脚本。

但是,如果我尝试通过向脚本的命令添加一个参数来运行任何模拟,例如~/project$ waff --run "first --PrintHelp",则会抛出错误

waf: error: no such option: --PrintHelp

只有当我从没有 waff 功能的根文件夹中运行脚本时,它才有效。

如何修改函数使其将$ *扩展为双逗号之间的参数?

2 个答案:

答案 0 :(得分:2)

好吧,我感到很尴尬,因为解决方案比预期的要容易。

如果使用DCE的人遇到同样的问题,就像报价$ *一样简单:

./waf --cwd="$CWD" $*

使用:

./waf --cwd="$CWD" "$*"

答案 1 :(得分:0)

这个函数适用于bash(假设您定义了环境变量$ NS3DIR):

function waff {
CWD="$PWD"
cd $NS3DIR >/dev/null
./waf --cwd="$CWD" "$@"
cd - >/dev/null
}

证明它的工作原理是:

$ waff --run "wifi-simple-adhoc --help"
Waf: Entering directory `/home'
Waf: Leaving directory `/home'
'build' finished successfully (2.013s)
ns3.22-wifi-simple-adhoc-debug [Program Arguments] [General Arguments]

Program Arguments:
    --phyMode:     Wifi Phy mode [DsssRate1Mbps]
    --rss:         received signal strength [-80]
    --packetSize:  size of application packet sent [1000]
    --numPackets:  number of packets generated [1]
    --interval:    interval (seconds) between packets [1]
    --verbose:     turn on all WifiNetDevice log components [false]

General Arguments:
    --PrintGlobals:              Print the list of globals.
    --PrintGroups:               Print the list of groups.
    --PrintGroup=[group]:        Print all TypeIds of group.
    --PrintTypeIds:              Print all TypeIds.
    --PrintAttributes=[typeid]:  Print all attributes of typeid.
    --PrintHelp:                 Print this help message.

$ waff --run wifi-simple-adhoc --command-template=" %s --help"
Waf: Entering directory `/home'
Waf: Leaving directory `/home'
'build' finished successfully (1.816s)
ns3.22-wifi-simple-adhoc-debug [Program Arguments] [General Arguments]

Program Arguments:
    --phyMode:     Wifi Phy mode [DsssRate1Mbps]
    --rss:         received signal strength [-80]
    --packetSize:  size of application packet sent [1000]
    --numPackets:  number of packets generated [1]
    --interval:    interval (seconds) between packets [1]
    --verbose:     turn on all WifiNetDevice log components [false]

General Arguments:
    --PrintGlobals:              Print the list of globals.
    --PrintGroups:               Print the list of groups.
    --PrintGroup=[group]:        Print all TypeIds of group.
    --PrintTypeIds:              Print all TypeIds.
    --PrintAttributes=[typeid]:  Print all attributes of typeid.
    --PrintHelp:                 Print this help message.