NS-2.27 and Leach

Wednesday, April 28, 2004

proc add-interface changed its signature

Problem:
The tcl code complains that the wrong number of arguments was inserted:

0 _o12 _o13 RCALinkLayer Mac/Sensor Queue/DropTail 100 Phy/WirelessPhy Antenna/OmniAntenna # _o5 {} {} {}
wrong # args: should be "_o17 self class proc channel pmodel lltype mactype qtype qlen iftype anttype topo inerrproc outerrproc fecproc"
(Object next line 1)
invoked from within
"_o17 next _o12 _o13 RCALinkLayer Mac/Sensor Queue/DropTail 100 Phy/WirelessPhy Antenna/OmniAntenna # _o5 {} {} {}"
("eval" body line 1)
invoked from within
"eval $self next $args"
(procedure "_o17" line 15)
(MobileNode/ResourceAwareNode add-interface line 15)
invoked from within
"$node add-interface $chan $prop $opt(ll) $opt(mac) $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) # $ns_ "" "" """
(procedure "leach-create-mobile-node" line 54)
invoked from within
"leach-create-mobile-node $i"
invoked from within
"if { [string compare $opt(rp) "dsr"] == 0} {
for {set i 0} {$i < $opt(nn) } {incr i} {
dsr-create-mobile-node $i
}
} elseif { [string compare $op..."
(file "./wireless-leach.tcl" line 246)


This is because the Node/MobileNode procedure add-interface in file tcl/lib/ns-mobilenode.tcl is different since 2.1b5. The documentation hasn't been keeping up either. The old signature is:

Node/MobileNode instproc add-interface { channel pmodel lltype mactype qtype qlen iftype anttype}

The new signature is:

Node/MobileNode instproc add-interface { channel pmodel lltype mactype qtype qlen iftype anttype topo inerrproc outerrproc fecproc}

As you can see, there are four extra arguments tacked on the end, but I have no idea what those argument are, much less their type. I'm guessing it's a topology object, some incoming error procedure, an outgoing error procedure, and a forward error correction procedure.

Fix:
I grepped for 'proc channel':

gen/ns_tcl.cc:Simulator instproc channel {val} {$self set channel_ $val}\ngen/ns_tcl.cc:Simulator instproc channelType {val} {$self set channelType_ $val}\nBinary file gen/ns_tcl.o matches
Binary file ns.exe matches
tcl/lib/ns-lib.tcl:Simulator instproc channel {val} {$self set channel_ $val}
tcl/lib/ns-lib.tcl:Simulator instproc channelType {val} {$self set channelType_ $val}


Which makes me guess that since the only object that has a channel procedure is simulator, I assume $topo takes a Simulator object. There is a Topography object in ns2. It makes more sense that this is what you pass in. I'll have to check if it has a channel procedure though.

Looking at the code within proc add-interface, I noticed the following lines were added:

if {$inerrproc != ""} {
set inerr_($t) [$inerrproc]
}
set outerr_($t) ""
if {$outerrproc != ""} {
set outerr_($t) [$outerrproc]
}
set fec_($t) ""
if {$fecproc != ""} {
set fec_($t) [$fecproc]
}


So I assume that I can pass in nothing and leach will still work, since it didn't need it before. Therefore, in mit/uAMPS/sims/uamps.tcl, I changed

$node add-interface $chan $prop $opt(ll) $opt(mac) $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant)

into:

$node add-interface $chan $prop $opt(ll) $opt(mac) $opt(ifq) $opt(ifqlen) $opt(netif) $opt(ant) $ns_$topo "" "" ""

0 Comments:

Post a Comment

<< Home