invalid command name “Agent/LeachAgent”

2019-08-23 04:30发布

问题:

I try to implement a simple scenario for LEACH protocol but I get this error:

 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)

I use ubuntu 16.04 and ns-allinone-2.35 . when I ran my tcl file for the first time, i did not get this error.

回答1:

Change your script to use Agent/RCAgent/LeachAgent as class name:

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

From what I can see, there is no Agent/LeachAgent in ns-allinone-2.35.



回答2:

I was not successful in writing a correct code for attaching Leach protocol in my scenario, but I found that mannasim has a Mannasim Script Generator (MSG). It is a front-end for TCL simulation scripts easy creation.



标签: tcl ns2