无效的命令名称“ Agent / LeachAgent”

时间:2018-07-30 14:14:35

标签: tcl ns2

我尝试为LEACH协议实现一个简单的方案,但出现此错误:

 Creating Sensors ... 
    invalid command name "Agent/LeachAgent"
        while executing
    "Agent/LeachAgent create _o2340 "
        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 Agent/LeachAgent"
        ("for" body line 3)
        invoked from within
    "for {set i 1} {$i <= $val(nsn)} {incr i} {

        set agent($i) [new Agent/LeachAgent]
        $ns attach-agent $node_($i) $agent($i)
        $agent($i) set packetSize_..."
        (file "newleach3.tcl" line 187)

我使用ubuntu 16.04ns-allinone-2.35。第一次运行tcl文件时,没有出现此错误。

2 个答案:

答案 0 :(得分:0)

更改脚本以使用Agent/RCAgent/LeachAgent作为类名:

set agent($i) [new Agent/RCAgent/LeachAgent]

据我所见,Agent/LeachAgent中没有ns-allinone-2.35

答案 1 :(得分:0)

在我的方案中,我未能成功编写用于附加Leach协议的正确代码,但我发现mannasim具有Mannasim脚本生成器(MSG)。它是TCL仿真脚本易于创建的前端。